annotate libffi/acinclude.m4 @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 # mmap(2) blacklisting. Some platforms provide the mmap library routine
kono
parents:
diff changeset
2 # but don't support all of the features we need from it.
kono
parents:
diff changeset
3 AC_DEFUN([AC_FUNC_MMAP_BLACKLIST],
kono
parents:
diff changeset
4 [
kono
parents:
diff changeset
5 AC_CHECK_HEADER([sys/mman.h],
kono
parents:
diff changeset
6 [libffi_header_sys_mman_h=yes], [libffi_header_sys_mman_h=no])
kono
parents:
diff changeset
7 AC_CHECK_FUNC([mmap], [libffi_func_mmap=yes], [libffi_func_mmap=no])
kono
parents:
diff changeset
8 if test "$libffi_header_sys_mman_h" != yes \
kono
parents:
diff changeset
9 || test "$libffi_func_mmap" != yes; then
kono
parents:
diff changeset
10 ac_cv_func_mmap_file=no
kono
parents:
diff changeset
11 ac_cv_func_mmap_dev_zero=no
kono
parents:
diff changeset
12 ac_cv_func_mmap_anon=no
kono
parents:
diff changeset
13 else
kono
parents:
diff changeset
14 AC_CACHE_CHECK([whether read-only mmap of a plain file works],
kono
parents:
diff changeset
15 ac_cv_func_mmap_file,
kono
parents:
diff changeset
16 [# Add a system to this blacklist if
kono
parents:
diff changeset
17 # mmap(0, stat_size, PROT_READ, MAP_PRIVATE, fd, 0) doesn't return a
kono
parents:
diff changeset
18 # memory area containing the same data that you'd get if you applied
kono
parents:
diff changeset
19 # read() to the same fd. The only system known to have a problem here
kono
parents:
diff changeset
20 # is VMS, where text files have record structure.
kono
parents:
diff changeset
21 case "$host_os" in
kono
parents:
diff changeset
22 vms* | ultrix*)
kono
parents:
diff changeset
23 ac_cv_func_mmap_file=no ;;
kono
parents:
diff changeset
24 *)
kono
parents:
diff changeset
25 ac_cv_func_mmap_file=yes;;
kono
parents:
diff changeset
26 esac])
kono
parents:
diff changeset
27 AC_CACHE_CHECK([whether mmap from /dev/zero works],
kono
parents:
diff changeset
28 ac_cv_func_mmap_dev_zero,
kono
parents:
diff changeset
29 [# Add a system to this blacklist if it has mmap() but /dev/zero
kono
parents:
diff changeset
30 # does not exist, or if mmapping /dev/zero does not give anonymous
kono
parents:
diff changeset
31 # zeroed pages with both the following properties:
kono
parents:
diff changeset
32 # 1. If you map N consecutive pages in with one call, and then
kono
parents:
diff changeset
33 # unmap any subset of those pages, the pages that were not
kono
parents:
diff changeset
34 # explicitly unmapped remain accessible.
kono
parents:
diff changeset
35 # 2. If you map two adjacent blocks of memory and then unmap them
kono
parents:
diff changeset
36 # both at once, they must both go away.
kono
parents:
diff changeset
37 # Systems known to be in this category are Windows (all variants),
kono
parents:
diff changeset
38 # VMS, and Darwin.
kono
parents:
diff changeset
39 case "$host_os" in
kono
parents:
diff changeset
40 vms* | cygwin* | pe | mingw* | darwin* | ultrix* | hpux10* | hpux11.00)
kono
parents:
diff changeset
41 ac_cv_func_mmap_dev_zero=no ;;
kono
parents:
diff changeset
42 *)
kono
parents:
diff changeset
43 ac_cv_func_mmap_dev_zero=yes;;
kono
parents:
diff changeset
44 esac])
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46 # Unlike /dev/zero, the MAP_ANON(YMOUS) defines can be probed for.
kono
parents:
diff changeset
47 AC_CACHE_CHECK([for MAP_ANON(YMOUS)], ac_cv_decl_map_anon,
kono
parents:
diff changeset
48 [AC_TRY_COMPILE(
kono
parents:
diff changeset
49 [#include <sys/types.h>
kono
parents:
diff changeset
50 #include <sys/mman.h>
kono
parents:
diff changeset
51 #include <unistd.h>
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 #ifndef MAP_ANONYMOUS
kono
parents:
diff changeset
54 #define MAP_ANONYMOUS MAP_ANON
kono
parents:
diff changeset
55 #endif
kono
parents:
diff changeset
56 ],
kono
parents:
diff changeset
57 [int n = MAP_ANONYMOUS;],
kono
parents:
diff changeset
58 ac_cv_decl_map_anon=yes,
kono
parents:
diff changeset
59 ac_cv_decl_map_anon=no)])
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 if test $ac_cv_decl_map_anon = no; then
kono
parents:
diff changeset
62 ac_cv_func_mmap_anon=no
kono
parents:
diff changeset
63 else
kono
parents:
diff changeset
64 AC_CACHE_CHECK([whether mmap with MAP_ANON(YMOUS) works],
kono
parents:
diff changeset
65 ac_cv_func_mmap_anon,
kono
parents:
diff changeset
66 [# Add a system to this blacklist if it has mmap() and MAP_ANON or
kono
parents:
diff changeset
67 # MAP_ANONYMOUS, but using mmap(..., MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
kono
parents:
diff changeset
68 # doesn't give anonymous zeroed pages with the same properties listed
kono
parents:
diff changeset
69 # above for use of /dev/zero.
kono
parents:
diff changeset
70 # Systems known to be in this category are Windows, VMS, and SCO Unix.
kono
parents:
diff changeset
71 case "$host_os" in
kono
parents:
diff changeset
72 vms* | cygwin* | pe | mingw* | sco* | udk* )
kono
parents:
diff changeset
73 ac_cv_func_mmap_anon=no ;;
kono
parents:
diff changeset
74 *)
kono
parents:
diff changeset
75 ac_cv_func_mmap_anon=yes;;
kono
parents:
diff changeset
76 esac])
kono
parents:
diff changeset
77 fi
kono
parents:
diff changeset
78 fi
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 if test $ac_cv_func_mmap_file = yes; then
kono
parents:
diff changeset
81 AC_DEFINE(HAVE_MMAP_FILE, 1,
kono
parents:
diff changeset
82 [Define if read-only mmap of a plain file works.])
kono
parents:
diff changeset
83 fi
kono
parents:
diff changeset
84 if test $ac_cv_func_mmap_dev_zero = yes; then
kono
parents:
diff changeset
85 AC_DEFINE(HAVE_MMAP_DEV_ZERO, 1,
kono
parents:
diff changeset
86 [Define if mmap of /dev/zero works.])
kono
parents:
diff changeset
87 fi
kono
parents:
diff changeset
88 if test $ac_cv_func_mmap_anon = yes; then
kono
parents:
diff changeset
89 AC_DEFINE(HAVE_MMAP_ANON, 1,
kono
parents:
diff changeset
90 [Define if mmap with MAP_ANON(YMOUS) works.])
kono
parents:
diff changeset
91 fi
kono
parents:
diff changeset
92 ])
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 dnl ----------------------------------------------------------------------
kono
parents:
diff changeset
95 dnl This whole bit snagged from libstdc++-v3, via libatomic.
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97 dnl
kono
parents:
diff changeset
98 dnl LIBAT_ENABLE
kono
parents:
diff changeset
99 dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING)
kono
parents:
diff changeset
100 dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, permit a|b|c)
kono
parents:
diff changeset
101 dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, SHELL-CODE-HANDLER)
kono
parents:
diff changeset
102 dnl
kono
parents:
diff changeset
103 dnl See docs/html/17_intro/configury.html#enable for documentation.
kono
parents:
diff changeset
104 dnl
kono
parents:
diff changeset
105 m4_define([LIBAT_ENABLE],[dnl
kono
parents:
diff changeset
106 m4_define([_g_switch],[--enable-$1])dnl
kono
parents:
diff changeset
107 m4_define([_g_help],[AC_HELP_STRING(_g_switch$3,[$4 @<:@default=$2@:>@])])dnl
kono
parents:
diff changeset
108 AC_ARG_ENABLE($1,_g_help,
kono
parents:
diff changeset
109 m4_bmatch([$5],
kono
parents:
diff changeset
110 [^permit ],
kono
parents:
diff changeset
111 [[
kono
parents:
diff changeset
112 case "$enableval" in
kono
parents:
diff changeset
113 m4_bpatsubst([$5],[permit ])) ;;
kono
parents:
diff changeset
114 *) AC_MSG_ERROR(Unknown argument to enable/disable $1) ;;
kono
parents:
diff changeset
115 dnl Idea for future: generate a URL pointing to
kono
parents:
diff changeset
116 dnl "onlinedocs/configopts.html#whatever"
kono
parents:
diff changeset
117 esac
kono
parents:
diff changeset
118 ]],
kono
parents:
diff changeset
119 [^$],
kono
parents:
diff changeset
120 [[
kono
parents:
diff changeset
121 case "$enableval" in
kono
parents:
diff changeset
122 yes|no) ;;
kono
parents:
diff changeset
123 *) AC_MSG_ERROR(Argument to enable/disable $1 must be yes or no) ;;
kono
parents:
diff changeset
124 esac
kono
parents:
diff changeset
125 ]],
kono
parents:
diff changeset
126 [[$5]]),
kono
parents:
diff changeset
127 [enable_]m4_bpatsubst([$1],-,_)[=][$2])
kono
parents:
diff changeset
128 m4_undefine([_g_switch])dnl
kono
parents:
diff changeset
129 m4_undefine([_g_help])dnl
kono
parents:
diff changeset
130 ])
kono
parents:
diff changeset
131
kono
parents:
diff changeset
132 dnl
kono
parents:
diff changeset
133 dnl If GNU ld is in use, check to see if tricky linker opts can be used. If
kono
parents:
diff changeset
134 dnl the native linker is in use, all variables will be defined to something
kono
parents:
diff changeset
135 dnl safe (like an empty string).
kono
parents:
diff changeset
136 dnl
kono
parents:
diff changeset
137 dnl Defines:
kono
parents:
diff changeset
138 dnl SECTION_LDFLAGS='-Wl,--gc-sections' if possible
kono
parents:
diff changeset
139 dnl OPT_LDFLAGS='-Wl,-O1' if possible
kono
parents:
diff changeset
140 dnl LD (as a side effect of testing)
kono
parents:
diff changeset
141 dnl Sets:
kono
parents:
diff changeset
142 dnl with_gnu_ld
kono
parents:
diff changeset
143 dnl libat_ld_is_gold (possibly)
kono
parents:
diff changeset
144 dnl libat_gnu_ld_version (possibly)
kono
parents:
diff changeset
145 dnl
kono
parents:
diff changeset
146 dnl The last will be a single integer, e.g., version 1.23.45.0.67.89 will
kono
parents:
diff changeset
147 dnl set libat_gnu_ld_version to 12345. Zeros cause problems.
kono
parents:
diff changeset
148 dnl
kono
parents:
diff changeset
149 AC_DEFUN([LIBAT_CHECK_LINKER_FEATURES], [
kono
parents:
diff changeset
150 # If we're not using GNU ld, then there's no point in even trying these
kono
parents:
diff changeset
151 # tests. Check for that first. We should have already tested for gld
kono
parents:
diff changeset
152 # by now (in libtool), but require it now just to be safe...
kono
parents:
diff changeset
153 test -z "$SECTION_LDFLAGS" && SECTION_LDFLAGS=''
kono
parents:
diff changeset
154 test -z "$OPT_LDFLAGS" && OPT_LDFLAGS=''
kono
parents:
diff changeset
155 AC_REQUIRE([AC_PROG_LD])
kono
parents:
diff changeset
156 AC_REQUIRE([AC_PROG_AWK])
kono
parents:
diff changeset
157
kono
parents:
diff changeset
158 # The name set by libtool depends on the version of libtool. Shame on us
kono
parents:
diff changeset
159 # for depending on an impl detail, but c'est la vie. Older versions used
kono
parents:
diff changeset
160 # ac_cv_prog_gnu_ld, but now it's lt_cv_prog_gnu_ld, and is copied back on
kono
parents:
diff changeset
161 # top of with_gnu_ld (which is also set by --with-gnu-ld, so that actually
kono
parents:
diff changeset
162 # makes sense). We'll test with_gnu_ld everywhere else, so if that isn't
kono
parents:
diff changeset
163 # set (hence we're using an older libtool), then set it.
kono
parents:
diff changeset
164 if test x${with_gnu_ld+set} != xset; then
kono
parents:
diff changeset
165 if test x${ac_cv_prog_gnu_ld+set} != xset; then
kono
parents:
diff changeset
166 # We got through "ac_require(ac_prog_ld)" and still not set? Huh?
kono
parents:
diff changeset
167 with_gnu_ld=no
kono
parents:
diff changeset
168 else
kono
parents:
diff changeset
169 with_gnu_ld=$ac_cv_prog_gnu_ld
kono
parents:
diff changeset
170 fi
kono
parents:
diff changeset
171 fi
kono
parents:
diff changeset
172
kono
parents:
diff changeset
173 # Start by getting the version number. I think the libtool test already
kono
parents:
diff changeset
174 # does some of this, but throws away the result.
kono
parents:
diff changeset
175 libat_ld_is_gold=no
kono
parents:
diff changeset
176 if $LD --version 2>/dev/null | grep 'GNU gold'> /dev/null 2>&1; then
kono
parents:
diff changeset
177 libat_ld_is_gold=yes
kono
parents:
diff changeset
178 fi
kono
parents:
diff changeset
179 changequote(,)
kono
parents:
diff changeset
180 ldver=`$LD --version 2>/dev/null |
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 111
diff changeset
181 sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
111
kono
parents:
diff changeset
182 changequote([,])
kono
parents:
diff changeset
183 libat_gnu_ld_version=`echo $ldver | \
kono
parents:
diff changeset
184 $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
kono
parents:
diff changeset
185
kono
parents:
diff changeset
186 # Set --gc-sections.
kono
parents:
diff changeset
187 if test "$with_gnu_ld" = "notbroken"; then
kono
parents:
diff changeset
188 # GNU ld it is! Joy and bunny rabbits!
kono
parents:
diff changeset
189
kono
parents:
diff changeset
190 # All these tests are for C++; save the language and the compiler flags.
kono
parents:
diff changeset
191 # Need to do this so that g++ won't try to link in libstdc++
kono
parents:
diff changeset
192 ac_test_CFLAGS="${CFLAGS+set}"
kono
parents:
diff changeset
193 ac_save_CFLAGS="$CFLAGS"
kono
parents:
diff changeset
194 CFLAGS='-x c++ -Wl,--gc-sections'
kono
parents:
diff changeset
195
kono
parents:
diff changeset
196 # Check for -Wl,--gc-sections
kono
parents:
diff changeset
197 # XXX This test is broken at the moment, as symbols required for linking
kono
parents:
diff changeset
198 # are now in libsupc++ (not built yet). In addition, this test has
kono
parents:
diff changeset
199 # cored on solaris in the past. In addition, --gc-sections doesn't
kono
parents:
diff changeset
200 # really work at the moment (keeps on discarding used sections, first
kono
parents:
diff changeset
201 # .eh_frame and now some of the glibc sections for iconv).
kono
parents:
diff changeset
202 # Bzzzzt. Thanks for playing, maybe next time.
kono
parents:
diff changeset
203 AC_MSG_CHECKING([for ld that supports -Wl,--gc-sections])
kono
parents:
diff changeset
204 AC_TRY_RUN([
kono
parents:
diff changeset
205 int main(void)
kono
parents:
diff changeset
206 {
kono
parents:
diff changeset
207 try { throw 1; }
kono
parents:
diff changeset
208 catch (...) { };
kono
parents:
diff changeset
209 return 0;
kono
parents:
diff changeset
210 }
kono
parents:
diff changeset
211 ], [ac_sectionLDflags=yes],[ac_sectionLDflags=no], [ac_sectionLDflags=yes])
kono
parents:
diff changeset
212 if test "$ac_test_CFLAGS" = set; then
kono
parents:
diff changeset
213 CFLAGS="$ac_save_CFLAGS"
kono
parents:
diff changeset
214 else
kono
parents:
diff changeset
215 # this is the suspicious part
kono
parents:
diff changeset
216 CFLAGS=''
kono
parents:
diff changeset
217 fi
kono
parents:
diff changeset
218 if test "$ac_sectionLDflags" = "yes"; then
kono
parents:
diff changeset
219 SECTION_LDFLAGS="-Wl,--gc-sections $SECTION_LDFLAGS"
kono
parents:
diff changeset
220 fi
kono
parents:
diff changeset
221 AC_MSG_RESULT($ac_sectionLDflags)
kono
parents:
diff changeset
222 fi
kono
parents:
diff changeset
223
kono
parents:
diff changeset
224 # Set linker optimization flags.
kono
parents:
diff changeset
225 if test x"$with_gnu_ld" = x"yes"; then
kono
parents:
diff changeset
226 OPT_LDFLAGS="-Wl,-O1 $OPT_LDFLAGS"
kono
parents:
diff changeset
227 fi
kono
parents:
diff changeset
228
kono
parents:
diff changeset
229 AC_SUBST(SECTION_LDFLAGS)
kono
parents:
diff changeset
230 AC_SUBST(OPT_LDFLAGS)
kono
parents:
diff changeset
231 ])
kono
parents:
diff changeset
232
kono
parents:
diff changeset
233
kono
parents:
diff changeset
234 dnl
kono
parents:
diff changeset
235 dnl If GNU ld is in use, check to see if tricky linker opts can be used. If
kono
parents:
diff changeset
236 dnl the native linker is in use, all variables will be defined to something
kono
parents:
diff changeset
237 dnl safe (like an empty string).
kono
parents:
diff changeset
238 dnl
kono
parents:
diff changeset
239 dnl Defines:
kono
parents:
diff changeset
240 dnl SECTION_LDFLAGS='-Wl,--gc-sections' if possible
kono
parents:
diff changeset
241 dnl OPT_LDFLAGS='-Wl,-O1' if possible
kono
parents:
diff changeset
242 dnl LD (as a side effect of testing)
kono
parents:
diff changeset
243 dnl Sets:
kono
parents:
diff changeset
244 dnl with_gnu_ld
kono
parents:
diff changeset
245 dnl libat_ld_is_gold (possibly)
kono
parents:
diff changeset
246 dnl libat_gnu_ld_version (possibly)
kono
parents:
diff changeset
247 dnl
kono
parents:
diff changeset
248 dnl The last will be a single integer, e.g., version 1.23.45.0.67.89 will
kono
parents:
diff changeset
249 dnl set libat_gnu_ld_version to 12345. Zeros cause problems.
kono
parents:
diff changeset
250 dnl
kono
parents:
diff changeset
251 AC_DEFUN([LIBAT_CHECK_LINKER_FEATURES], [
kono
parents:
diff changeset
252 # If we're not using GNU ld, then there's no point in even trying these
kono
parents:
diff changeset
253 # tests. Check for that first. We should have already tested for gld
kono
parents:
diff changeset
254 # by now (in libtool), but require it now just to be safe...
kono
parents:
diff changeset
255 test -z "$SECTION_LDFLAGS" && SECTION_LDFLAGS=''
kono
parents:
diff changeset
256 test -z "$OPT_LDFLAGS" && OPT_LDFLAGS=''
kono
parents:
diff changeset
257 AC_REQUIRE([AC_PROG_LD])
kono
parents:
diff changeset
258 AC_REQUIRE([AC_PROG_AWK])
kono
parents:
diff changeset
259
kono
parents:
diff changeset
260 # The name set by libtool depends on the version of libtool. Shame on us
kono
parents:
diff changeset
261 # for depending on an impl detail, but c'est la vie. Older versions used
kono
parents:
diff changeset
262 # ac_cv_prog_gnu_ld, but now it's lt_cv_prog_gnu_ld, and is copied back on
kono
parents:
diff changeset
263 # top of with_gnu_ld (which is also set by --with-gnu-ld, so that actually
kono
parents:
diff changeset
264 # makes sense). We'll test with_gnu_ld everywhere else, so if that isn't
kono
parents:
diff changeset
265 # set (hence we're using an older libtool), then set it.
kono
parents:
diff changeset
266 if test x${with_gnu_ld+set} != xset; then
kono
parents:
diff changeset
267 if test x${ac_cv_prog_gnu_ld+set} != xset; then
kono
parents:
diff changeset
268 # We got through "ac_require(ac_prog_ld)" and still not set? Huh?
kono
parents:
diff changeset
269 with_gnu_ld=no
kono
parents:
diff changeset
270 else
kono
parents:
diff changeset
271 with_gnu_ld=$ac_cv_prog_gnu_ld
kono
parents:
diff changeset
272 fi
kono
parents:
diff changeset
273 fi
kono
parents:
diff changeset
274
kono
parents:
diff changeset
275 # Start by getting the version number. I think the libtool test already
kono
parents:
diff changeset
276 # does some of this, but throws away the result.
kono
parents:
diff changeset
277 libat_ld_is_gold=no
kono
parents:
diff changeset
278 if $LD --version 2>/dev/null | grep 'GNU gold'> /dev/null 2>&1; then
kono
parents:
diff changeset
279 libat_ld_is_gold=yes
kono
parents:
diff changeset
280 fi
kono
parents:
diff changeset
281 changequote(,)
kono
parents:
diff changeset
282 ldver=`$LD --version 2>/dev/null |
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 111
diff changeset
283 sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
111
kono
parents:
diff changeset
284 changequote([,])
kono
parents:
diff changeset
285 libat_gnu_ld_version=`echo $ldver | \
kono
parents:
diff changeset
286 $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
kono
parents:
diff changeset
287
kono
parents:
diff changeset
288 # Set --gc-sections.
kono
parents:
diff changeset
289 if test "$with_gnu_ld" = "notbroken"; then
kono
parents:
diff changeset
290 # GNU ld it is! Joy and bunny rabbits!
kono
parents:
diff changeset
291
kono
parents:
diff changeset
292 # All these tests are for C++; save the language and the compiler flags.
kono
parents:
diff changeset
293 # Need to do this so that g++ won't try to link in libstdc++
kono
parents:
diff changeset
294 ac_test_CFLAGS="${CFLAGS+set}"
kono
parents:
diff changeset
295 ac_save_CFLAGS="$CFLAGS"
kono
parents:
diff changeset
296 CFLAGS='-x c++ -Wl,--gc-sections'
kono
parents:
diff changeset
297
kono
parents:
diff changeset
298 # Check for -Wl,--gc-sections
kono
parents:
diff changeset
299 # XXX This test is broken at the moment, as symbols required for linking
kono
parents:
diff changeset
300 # are now in libsupc++ (not built yet). In addition, this test has
kono
parents:
diff changeset
301 # cored on solaris in the past. In addition, --gc-sections doesn't
kono
parents:
diff changeset
302 # really work at the moment (keeps on discarding used sections, first
kono
parents:
diff changeset
303 # .eh_frame and now some of the glibc sections for iconv).
kono
parents:
diff changeset
304 # Bzzzzt. Thanks for playing, maybe next time.
kono
parents:
diff changeset
305 AC_MSG_CHECKING([for ld that supports -Wl,--gc-sections])
kono
parents:
diff changeset
306 AC_TRY_RUN([
kono
parents:
diff changeset
307 int main(void)
kono
parents:
diff changeset
308 {
kono
parents:
diff changeset
309 try { throw 1; }
kono
parents:
diff changeset
310 catch (...) { };
kono
parents:
diff changeset
311 return 0;
kono
parents:
diff changeset
312 }
kono
parents:
diff changeset
313 ], [ac_sectionLDflags=yes],[ac_sectionLDflags=no], [ac_sectionLDflags=yes])
kono
parents:
diff changeset
314 if test "$ac_test_CFLAGS" = set; then
kono
parents:
diff changeset
315 CFLAGS="$ac_save_CFLAGS"
kono
parents:
diff changeset
316 else
kono
parents:
diff changeset
317 # this is the suspicious part
kono
parents:
diff changeset
318 CFLAGS=''
kono
parents:
diff changeset
319 fi
kono
parents:
diff changeset
320 if test "$ac_sectionLDflags" = "yes"; then
kono
parents:
diff changeset
321 SECTION_LDFLAGS="-Wl,--gc-sections $SECTION_LDFLAGS"
kono
parents:
diff changeset
322 fi
kono
parents:
diff changeset
323 AC_MSG_RESULT($ac_sectionLDflags)
kono
parents:
diff changeset
324 fi
kono
parents:
diff changeset
325
kono
parents:
diff changeset
326 # Set linker optimization flags.
kono
parents:
diff changeset
327 if test x"$with_gnu_ld" = x"yes"; then
kono
parents:
diff changeset
328 OPT_LDFLAGS="-Wl,-O1 $OPT_LDFLAGS"
kono
parents:
diff changeset
329 fi
kono
parents:
diff changeset
330
kono
parents:
diff changeset
331 AC_SUBST(SECTION_LDFLAGS)
kono
parents:
diff changeset
332 AC_SUBST(OPT_LDFLAGS)
kono
parents:
diff changeset
333 ])
kono
parents:
diff changeset
334
kono
parents:
diff changeset
335
kono
parents:
diff changeset
336 dnl
kono
parents:
diff changeset
337 dnl Add version tags to symbols in shared library (or not), additionally
kono
parents:
diff changeset
338 dnl marking other symbols as private/local (or not).
kono
parents:
diff changeset
339 dnl
kono
parents:
diff changeset
340 dnl --enable-symvers=style adds a version script to the linker call when
kono
parents:
diff changeset
341 dnl creating the shared library. The choice of version script is
kono
parents:
diff changeset
342 dnl controlled by 'style'.
kono
parents:
diff changeset
343 dnl --disable-symvers does not.
kono
parents:
diff changeset
344 dnl + Usage: LIBAT_ENABLE_SYMVERS[(DEFAULT)]
kono
parents:
diff changeset
345 dnl Where DEFAULT is either 'yes' or 'no'. Passing `yes' tries to
kono
parents:
diff changeset
346 dnl choose a default style based on linker characteristics. Passing
kono
parents:
diff changeset
347 dnl 'no' disables versioning.
kono
parents:
diff changeset
348 dnl
kono
parents:
diff changeset
349 AC_DEFUN([LIBAT_ENABLE_SYMVERS], [
kono
parents:
diff changeset
350
kono
parents:
diff changeset
351 LIBAT_ENABLE(symvers,yes,[=STYLE],
kono
parents:
diff changeset
352 [enables symbol versioning of the shared library],
kono
parents:
diff changeset
353 [permit yes|no|gnu*|sun])
kono
parents:
diff changeset
354
kono
parents:
diff changeset
355 # If we never went through the LIBAT_CHECK_LINKER_FEATURES macro, then we
kono
parents:
diff changeset
356 # don't know enough about $LD to do tricks...
kono
parents:
diff changeset
357 AC_REQUIRE([LIBAT_CHECK_LINKER_FEATURES])
kono
parents:
diff changeset
358
kono
parents:
diff changeset
359 # Turn a 'yes' into a suitable default.
kono
parents:
diff changeset
360 if test x$enable_symvers = xyes ; then
kono
parents:
diff changeset
361 # FIXME The following test is too strict, in theory.
kono
parents:
diff changeset
362 if test $enable_shared = no || test "x$LD" = x; then
kono
parents:
diff changeset
363 enable_symvers=no
kono
parents:
diff changeset
364 else
kono
parents:
diff changeset
365 if test $with_gnu_ld = yes ; then
kono
parents:
diff changeset
366 enable_symvers=gnu
kono
parents:
diff changeset
367 else
kono
parents:
diff changeset
368 case ${target_os} in
kono
parents:
diff changeset
369 # Sun symbol versioning exists since Solaris 2.5.
kono
parents:
diff changeset
370 solaris2.[[5-9]]* | solaris2.1[[0-9]]*)
kono
parents:
diff changeset
371 enable_symvers=sun ;;
kono
parents:
diff changeset
372 *)
kono
parents:
diff changeset
373 enable_symvers=no ;;
kono
parents:
diff changeset
374 esac
kono
parents:
diff changeset
375 fi
kono
parents:
diff changeset
376 fi
kono
parents:
diff changeset
377 fi
kono
parents:
diff changeset
378
kono
parents:
diff changeset
379 # Check if 'sun' was requested on non-Solaris 2 platforms.
kono
parents:
diff changeset
380 if test x$enable_symvers = xsun ; then
kono
parents:
diff changeset
381 case ${target_os} in
kono
parents:
diff changeset
382 solaris2*)
kono
parents:
diff changeset
383 # All fine.
kono
parents:
diff changeset
384 ;;
kono
parents:
diff changeset
385 *)
kono
parents:
diff changeset
386 # Unlikely to work.
kono
parents:
diff changeset
387 AC_MSG_WARN([=== You have requested Sun symbol versioning, but])
kono
parents:
diff changeset
388 AC_MSG_WARN([=== you are not targetting Solaris 2.])
kono
parents:
diff changeset
389 AC_MSG_WARN([=== Symbol versioning will be disabled.])
kono
parents:
diff changeset
390 enable_symvers=no
kono
parents:
diff changeset
391 ;;
kono
parents:
diff changeset
392 esac
kono
parents:
diff changeset
393 fi
kono
parents:
diff changeset
394
kono
parents:
diff changeset
395 # Check to see if libgcc_s exists, indicating that shared libgcc is possible.
kono
parents:
diff changeset
396 if test $enable_symvers != no; then
kono
parents:
diff changeset
397 AC_MSG_CHECKING([for shared libgcc])
kono
parents:
diff changeset
398 ac_save_CFLAGS="$CFLAGS"
kono
parents:
diff changeset
399 CFLAGS=' -lgcc_s'
kono
parents:
diff changeset
400 AC_TRY_LINK(, [return 0;], libat_shared_libgcc=yes, libat_shared_libgcc=no)
kono
parents:
diff changeset
401 CFLAGS="$ac_save_CFLAGS"
kono
parents:
diff changeset
402 if test $libat_shared_libgcc = no; then
kono
parents:
diff changeset
403 cat > conftest.c <<EOF
kono
parents:
diff changeset
404 int main (void) { return 0; }
kono
parents:
diff changeset
405 EOF
kono
parents:
diff changeset
406 changequote(,)dnl
kono
parents:
diff changeset
407 libat_libgcc_s_suffix=`${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
kono
parents:
diff changeset
408 -shared -shared-libgcc -o conftest.so \
kono
parents:
diff changeset
409 conftest.c -v 2>&1 >/dev/null \
kono
parents:
diff changeset
410 | sed -n 's/^.* -lgcc_s\([^ ]*\) .*$/\1/p'`
kono
parents:
diff changeset
411 changequote([,])dnl
kono
parents:
diff changeset
412 rm -f conftest.c conftest.so
kono
parents:
diff changeset
413 if test x${libat_libgcc_s_suffix+set} = xset; then
kono
parents:
diff changeset
414 CFLAGS=" -lgcc_s$libat_libgcc_s_suffix"
kono
parents:
diff changeset
415 AC_TRY_LINK(, [return 0;], libat_shared_libgcc=yes)
kono
parents:
diff changeset
416 CFLAGS="$ac_save_CFLAGS"
kono
parents:
diff changeset
417 fi
kono
parents:
diff changeset
418 fi
kono
parents:
diff changeset
419 AC_MSG_RESULT($libat_shared_libgcc)
kono
parents:
diff changeset
420 fi
kono
parents:
diff changeset
421
kono
parents:
diff changeset
422 # For GNU ld, we need at least this version. The format is described in
kono
parents:
diff changeset
423 # LIBAT_CHECK_LINKER_FEATURES above.
kono
parents:
diff changeset
424 libat_min_gnu_ld_version=21400
kono
parents:
diff changeset
425 # XXXXXXXXXXX libat_gnu_ld_version=21390
kono
parents:
diff changeset
426
kono
parents:
diff changeset
427 # Check to see if unspecified "yes" value can win, given results above.
kono
parents:
diff changeset
428 # Change "yes" into either "no" or a style name.
kono
parents:
diff changeset
429 if test $enable_symvers != no && test $libat_shared_libgcc = yes; then
kono
parents:
diff changeset
430 if test $with_gnu_ld = yes; then
kono
parents:
diff changeset
431 if test $libat_gnu_ld_version -ge $libat_min_gnu_ld_version ; then
kono
parents:
diff changeset
432 enable_symvers=gnu
kono
parents:
diff changeset
433 elif test $libat_ld_is_gold = yes ; then
kono
parents:
diff changeset
434 enable_symvers=gnu
kono
parents:
diff changeset
435 else
kono
parents:
diff changeset
436 # The right tools, the right setup, but too old. Fallbacks?
kono
parents:
diff changeset
437 AC_MSG_WARN(=== Linker version $libat_gnu_ld_version is too old for)
kono
parents:
diff changeset
438 AC_MSG_WARN(=== full symbol versioning support in this release of GCC.)
kono
parents:
diff changeset
439 AC_MSG_WARN(=== You would need to upgrade your binutils to version)
kono
parents:
diff changeset
440 AC_MSG_WARN(=== $libat_min_gnu_ld_version or later and rebuild GCC.)
kono
parents:
diff changeset
441 if test $libat_gnu_ld_version -ge 21200 ; then
kono
parents:
diff changeset
442 # Globbing fix is present, proper block support is not.
kono
parents:
diff changeset
443 dnl AC_MSG_WARN([=== Dude, you are soooo close. Maybe we can fake it.])
kono
parents:
diff changeset
444 dnl enable_symvers=???
kono
parents:
diff changeset
445 AC_MSG_WARN([=== Symbol versioning will be disabled.])
kono
parents:
diff changeset
446 enable_symvers=no
kono
parents:
diff changeset
447 else
kono
parents:
diff changeset
448 # 2.11 or older.
kono
parents:
diff changeset
449 AC_MSG_WARN([=== Symbol versioning will be disabled.])
kono
parents:
diff changeset
450 enable_symvers=no
kono
parents:
diff changeset
451 fi
kono
parents:
diff changeset
452 fi
kono
parents:
diff changeset
453 elif test $enable_symvers = sun; then
kono
parents:
diff changeset
454 : All interesting versions of Sun ld support sun style symbol versioning.
kono
parents:
diff changeset
455 else
kono
parents:
diff changeset
456 # just fail for now
kono
parents:
diff changeset
457 AC_MSG_WARN([=== You have requested some kind of symbol versioning, but])
kono
parents:
diff changeset
458 AC_MSG_WARN([=== either you are not using a supported linker, or you are])
kono
parents:
diff changeset
459 AC_MSG_WARN([=== not building a shared libgcc_s (which is required).])
kono
parents:
diff changeset
460 AC_MSG_WARN([=== Symbol versioning will be disabled.])
kono
parents:
diff changeset
461 enable_symvers=no
kono
parents:
diff changeset
462 fi
kono
parents:
diff changeset
463 fi
kono
parents:
diff changeset
464 if test $enable_symvers = gnu; then
kono
parents:
diff changeset
465 AC_DEFINE(LIBAT_GNU_SYMBOL_VERSIONING, 1,
kono
parents:
diff changeset
466 [Define to 1 if GNU symbol versioning is used for libatomic.])
kono
parents:
diff changeset
467 fi
kono
parents:
diff changeset
468
kono
parents:
diff changeset
469 AM_CONDITIONAL(LIBAT_BUILD_VERSIONED_SHLIB, test $enable_symvers != no)
kono
parents:
diff changeset
470 AM_CONDITIONAL(LIBAT_BUILD_VERSIONED_SHLIB_GNU, test $enable_symvers = gnu)
kono
parents:
diff changeset
471 AM_CONDITIONAL(LIBAT_BUILD_VERSIONED_SHLIB_SUN, test $enable_symvers = sun)
kono
parents:
diff changeset
472 AC_MSG_NOTICE(versioning on shared library symbols is $enable_symvers)
kono
parents:
diff changeset
473 ])