]>
Commit | Line | Data |
---|---|---|
953ff289 DN |
1 | dnl ---------------------------------------------------------------------- |
2 | dnl This whole bit snagged from libgfortran. | |
3 | ||
4 | dnl Check whether the target supports __sync_*_compare_and_swap. | |
5 | AC_DEFUN([LIBGOMP_CHECK_SYNC_BUILTINS], [ | |
6 | AC_CACHE_CHECK([whether the target supports __sync_*_compare_and_swap], | |
6d26724a | 7 | libgomp_cv_have_sync_builtins, [ |
289a9f86 | 8 | AC_TRY_LINK([], [int foo; __sync_val_compare_and_swap(&foo, 0, 1);], |
6d26724a RW |
9 | libgomp_cv_have_sync_builtins=yes, libgomp_cv_have_sync_builtins=no)]) |
10 | if test $libgomp_cv_have_sync_builtins = yes; then | |
953ff289 DN |
11 | AC_DEFINE(HAVE_SYNC_BUILTINS, 1, |
12 | [Define to 1 if the target supports __sync_*_compare_and_swap]) | |
13 | fi]) | |
14 | ||
15 | dnl Check whether the target supports hidden visibility. | |
16 | AC_DEFUN([LIBGOMP_CHECK_ATTRIBUTE_VISIBILITY], [ | |
17 | AC_CACHE_CHECK([whether the target supports hidden visibility], | |
6d26724a | 18 | libgomp_cv_have_attribute_visibility, [ |
953ff289 DN |
19 | save_CFLAGS="$CFLAGS" |
20 | CFLAGS="$CFLAGS -Werror" | |
21 | AC_TRY_COMPILE([void __attribute__((visibility("hidden"))) foo(void) { }], | |
6d26724a RW |
22 | [], libgomp_cv_have_attribute_visibility=yes, |
23 | libgomp_cv_have_attribute_visibility=no) | |
953ff289 | 24 | CFLAGS="$save_CFLAGS"]) |
6d26724a | 25 | if test $libgomp_cv_have_attribute_visibility = yes; then |
953ff289 DN |
26 | AC_DEFINE(HAVE_ATTRIBUTE_VISIBILITY, 1, |
27 | [Define to 1 if the target supports __attribute__((visibility(...))).]) | |
28 | fi]) | |
29 | ||
30 | dnl Check whether the target supports dllexport | |
31 | AC_DEFUN([LIBGOMP_CHECK_ATTRIBUTE_DLLEXPORT], [ | |
32 | AC_CACHE_CHECK([whether the target supports dllexport], | |
6d26724a | 33 | libgomp_cv_have_attribute_dllexport, [ |
953ff289 DN |
34 | save_CFLAGS="$CFLAGS" |
35 | CFLAGS="$CFLAGS -Werror" | |
36 | AC_TRY_COMPILE([void __attribute__((dllexport)) foo(void) { }], | |
6d26724a RW |
37 | [], libgomp_cv_have_attribute_dllexport=yes, |
38 | libgomp_cv_have_attribute_dllexport=no) | |
953ff289 | 39 | CFLAGS="$save_CFLAGS"]) |
6d26724a | 40 | if test $libgomp_cv_have_attribute_dllexport = yes; then |
953ff289 DN |
41 | AC_DEFINE(HAVE_ATTRIBUTE_DLLEXPORT, 1, |
42 | [Define to 1 if the target supports __attribute__((dllexport)).]) | |
43 | fi]) | |
44 | ||
45 | dnl Check whether the target supports symbol aliases. | |
46 | AC_DEFUN([LIBGOMP_CHECK_ATTRIBUTE_ALIAS], [ | |
47 | AC_CACHE_CHECK([whether the target supports symbol aliases], | |
6d26724a | 48 | libgomp_cv_have_attribute_alias, [ |
953ff289 | 49 | AC_TRY_LINK([ |
953ff289 | 50 | void foo(void) { } |
8887708e | 51 | extern void bar(void) __attribute__((alias("foo")));], |
6d26724a RW |
52 | [bar();], libgomp_cv_have_attribute_alias=yes, libgomp_cv_have_attribute_alias=no)]) |
53 | if test $libgomp_cv_have_attribute_alias = yes; then | |
953ff289 DN |
54 | AC_DEFINE(HAVE_ATTRIBUTE_ALIAS, 1, |
55 | [Define to 1 if the target supports __attribute__((alias(...))).]) | |
56 | fi]) | |
57 | ||
58 | sinclude(../libtool.m4) | |
efe33ced | 59 | sinclude(../config/cet.m4) |
953ff289 DN |
60 | dnl The lines below arrange for aclocal not to bring an installed |
61 | dnl libtool.m4 into aclocal.m4, while still arranging for automake to | |
62 | dnl add a definition of LIBTOOL to Makefile.in. | |
63 | ifelse(,,,[AC_SUBST(LIBTOOL) | |
64 | AC_DEFUN([AM_PROG_LIBTOOL]) | |
65 | AC_DEFUN([AC_LIBTOOL_DLOPEN]) | |
66 | AC_DEFUN([AC_PROG_LD]) | |
67 | ]) | |
68 | ||
69 | dnl ---------------------------------------------------------------------- | |
70 | dnl This whole bit snagged from libstdc++-v3. | |
71 | ||
72 | dnl | |
73 | dnl LIBGOMP_ENABLE | |
74 | dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING) | |
75 | dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, permit a|b|c) | |
76 | dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, SHELL-CODE-HANDLER) | |
77 | dnl | |
78 | dnl See docs/html/17_intro/configury.html#enable for documentation. | |
79 | dnl | |
80 | m4_define([LIBGOMP_ENABLE],[dnl | |
81 | m4_define([_g_switch],[--enable-$1])dnl | |
82 | m4_define([_g_help],[AC_HELP_STRING(_g_switch$3,[$4 @<:@default=$2@:>@])])dnl | |
83 | AC_ARG_ENABLE($1,_g_help, | |
84 | m4_bmatch([$5], | |
85 | [^permit ], | |
86 | [[ | |
87 | case "$enableval" in | |
88 | m4_bpatsubst([$5],[permit ])) ;; | |
89 | *) AC_MSG_ERROR(Unknown argument to enable/disable $1) ;; | |
90 | dnl Idea for future: generate a URL pointing to | |
91 | dnl "onlinedocs/configopts.html#whatever" | |
92 | esac | |
93 | ]], | |
94 | [^$], | |
95 | [[ | |
96 | case "$enableval" in | |
97 | yes|no) ;; | |
98 | *) AC_MSG_ERROR(Argument to enable/disable $1 must be yes or no) ;; | |
99 | esac | |
100 | ]], | |
101 | [[$5]]), | |
102 | [enable_]m4_bpatsubst([$1],-,_)[=][$2]) | |
103 | m4_undefine([_g_switch])dnl | |
104 | m4_undefine([_g_help])dnl | |
105 | ]) | |
106 | ||
107 | ||
108 | dnl | |
109 | dnl If GNU ld is in use, check to see if tricky linker opts can be used. If | |
110 | dnl the native linker is in use, all variables will be defined to something | |
111 | dnl safe (like an empty string). | |
112 | dnl | |
113 | dnl Defines: | |
114 | dnl SECTION_LDFLAGS='-Wl,--gc-sections' if possible | |
115 | dnl OPT_LDFLAGS='-Wl,-O1' if possible | |
116 | dnl LD (as a side effect of testing) | |
117 | dnl Sets: | |
118 | dnl with_gnu_ld | |
b39dea08 | 119 | dnl libgomp_ld_is_gold (possibly) |
953ff289 DN |
120 | dnl libgomp_gnu_ld_version (possibly) |
121 | dnl | |
122 | dnl The last will be a single integer, e.g., version 1.23.45.0.67.89 will | |
123 | dnl set libgomp_gnu_ld_version to 12345. Zeros cause problems. | |
124 | dnl | |
125 | AC_DEFUN([LIBGOMP_CHECK_LINKER_FEATURES], [ | |
126 | # If we're not using GNU ld, then there's no point in even trying these | |
127 | # tests. Check for that first. We should have already tested for gld | |
128 | # by now (in libtool), but require it now just to be safe... | |
129 | test -z "$SECTION_LDFLAGS" && SECTION_LDFLAGS='' | |
130 | test -z "$OPT_LDFLAGS" && OPT_LDFLAGS='' | |
131 | AC_REQUIRE([AC_PROG_LD]) | |
132 | AC_REQUIRE([AC_PROG_AWK]) | |
133 | ||
134 | # The name set by libtool depends on the version of libtool. Shame on us | |
135 | # for depending on an impl detail, but c'est la vie. Older versions used | |
136 | # ac_cv_prog_gnu_ld, but now it's lt_cv_prog_gnu_ld, and is copied back on | |
137 | # top of with_gnu_ld (which is also set by --with-gnu-ld, so that actually | |
138 | # makes sense). We'll test with_gnu_ld everywhere else, so if that isn't | |
139 | # set (hence we're using an older libtool), then set it. | |
140 | if test x${with_gnu_ld+set} != xset; then | |
141 | if test x${ac_cv_prog_gnu_ld+set} != xset; then | |
142 | # We got through "ac_require(ac_prog_ld)" and still not set? Huh? | |
143 | with_gnu_ld=no | |
144 | else | |
145 | with_gnu_ld=$ac_cv_prog_gnu_ld | |
146 | fi | |
147 | fi | |
148 | ||
149 | # Start by getting the version number. I think the libtool test already | |
150 | # does some of this, but throws away the result. | |
b39dea08 ILT |
151 | libgomp_ld_is_gold=no |
152 | if $LD --version 2>/dev/null | grep 'GNU gold'> /dev/null 2>&1; then | |
153 | libgomp_ld_is_gold=yes | |
154 | fi | |
953ff289 | 155 | changequote(,) |
c82852f7 | 156 | ldver=`$LD --version 2>/dev/null | |
c6c2d1bc | 157 | sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'` |
953ff289 DN |
158 | changequote([,]) |
159 | libgomp_gnu_ld_version=`echo $ldver | \ | |
160 | $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'` | |
161 | ||
162 | # Set --gc-sections. | |
163 | if test "$with_gnu_ld" = "notbroken"; then | |
164 | # GNU ld it is! Joy and bunny rabbits! | |
165 | ||
166 | # All these tests are for C++; save the language and the compiler flags. | |
167 | # Need to do this so that g++ won't try to link in libstdc++ | |
168 | ac_test_CFLAGS="${CFLAGS+set}" | |
169 | ac_save_CFLAGS="$CFLAGS" | |
170 | CFLAGS='-x c++ -Wl,--gc-sections' | |
171 | ||
172 | # Check for -Wl,--gc-sections | |
173 | # XXX This test is broken at the moment, as symbols required for linking | |
174 | # are now in libsupc++ (not built yet). In addition, this test has | |
175 | # cored on solaris in the past. In addition, --gc-sections doesn't | |
176 | # really work at the moment (keeps on discarding used sections, first | |
177 | # .eh_frame and now some of the glibc sections for iconv). | |
178 | # Bzzzzt. Thanks for playing, maybe next time. | |
179 | AC_MSG_CHECKING([for ld that supports -Wl,--gc-sections]) | |
180 | AC_TRY_RUN([ | |
181 | int main(void) | |
182 | { | |
183 | try { throw 1; } | |
184 | catch (...) { }; | |
185 | return 0; | |
186 | } | |
187 | ], [ac_sectionLDflags=yes],[ac_sectionLDflags=no], [ac_sectionLDflags=yes]) | |
188 | if test "$ac_test_CFLAGS" = set; then | |
189 | CFLAGS="$ac_save_CFLAGS" | |
190 | else | |
191 | # this is the suspicious part | |
192 | CFLAGS='' | |
193 | fi | |
194 | if test "$ac_sectionLDflags" = "yes"; then | |
195 | SECTION_LDFLAGS="-Wl,--gc-sections $SECTION_LDFLAGS" | |
196 | fi | |
197 | AC_MSG_RESULT($ac_sectionLDflags) | |
198 | fi | |
199 | ||
200 | # Set linker optimization flags. | |
201 | if test x"$with_gnu_ld" = x"yes"; then | |
202 | OPT_LDFLAGS="-Wl,-O1 $OPT_LDFLAGS" | |
203 | fi | |
204 | ||
205 | AC_SUBST(SECTION_LDFLAGS) | |
206 | AC_SUBST(OPT_LDFLAGS) | |
207 | ]) | |
208 | ||
209 | ||
210 | dnl | |
211 | dnl Add version tags to symbols in shared library (or not), additionally | |
212 | dnl marking other symbols as private/local (or not). | |
213 | dnl | |
214 | dnl --enable-symvers=style adds a version script to the linker call when | |
215 | dnl creating the shared library. The choice of version script is | |
216 | dnl controlled by 'style'. | |
217 | dnl --disable-symvers does not. | |
218 | dnl + Usage: LIBGOMP_ENABLE_SYMVERS[(DEFAULT)] | |
219 | dnl Where DEFAULT is either 'yes' or 'no'. Passing `yes' tries to | |
220 | dnl choose a default style based on linker characteristics. Passing | |
221 | dnl 'no' disables versioning. | |
222 | dnl | |
223 | AC_DEFUN([LIBGOMP_ENABLE_SYMVERS], [ | |
224 | ||
225 | LIBGOMP_ENABLE(symvers,yes,[=STYLE], | |
226 | [enables symbol versioning of the shared library], | |
bddd6626 | 227 | [permit yes|no|gnu*|sun]) |
953ff289 DN |
228 | |
229 | # If we never went through the LIBGOMP_CHECK_LINKER_FEATURES macro, then we | |
230 | # don't know enough about $LD to do tricks... | |
231 | AC_REQUIRE([LIBGOMP_CHECK_LINKER_FEATURES]) | |
bf382f5f RO |
232 | |
233 | # Turn a 'yes' into a suitable default. | |
234 | if test x$enable_symvers = xyes ; then | |
235 | # FIXME The following test is too strict, in theory. | |
236 | if test $enable_shared = no || test "x$LD" = x; then | |
237 | enable_symvers=no | |
6d28b933 | 238 | else |
bf382f5f RO |
239 | if test $with_gnu_ld = yes ; then |
240 | enable_symvers=gnu | |
241 | else | |
242 | case ${target_os} in | |
243 | # Sun symbol versioning exists since Solaris 2.5. | |
244 | solaris2.[[5-9]]* | solaris2.1[[0-9]]*) | |
245 | enable_symvers=sun ;; | |
246 | *) | |
247 | enable_symvers=no ;; | |
248 | esac | |
249 | fi | |
6d28b933 RO |
250 | fi |
251 | fi | |
252 | ||
253 | # Check if 'sun' was requested on non-Solaris 2 platforms. | |
254 | if test x$enable_symvers = xsun ; then | |
255 | case ${target_os} in | |
256 | solaris2*) | |
257 | # All fine. | |
258 | ;; | |
259 | *) | |
260 | # Unlikely to work. | |
261 | AC_MSG_WARN([=== You have requested Sun symbol versioning, but]) | |
262 | AC_MSG_WARN([=== you are not targetting Solaris 2.]) | |
263 | AC_MSG_WARN([=== Symbol versioning will be disabled.]) | |
264 | enable_symvers=no | |
265 | ;; | |
266 | esac | |
953ff289 DN |
267 | fi |
268 | ||
269 | # Check to see if libgcc_s exists, indicating that shared libgcc is possible. | |
270 | if test $enable_symvers != no; then | |
271 | AC_MSG_CHECKING([for shared libgcc]) | |
272 | ac_save_CFLAGS="$CFLAGS" | |
273 | CFLAGS=' -lgcc_s' | |
274 | AC_TRY_LINK(, [return 0;], libgomp_shared_libgcc=yes, libgomp_shared_libgcc=no) | |
275 | CFLAGS="$ac_save_CFLAGS" | |
276 | if test $libgomp_shared_libgcc = no; then | |
277 | cat > conftest.c <<EOF | |
278 | int main (void) { return 0; } | |
279 | EOF | |
280 | changequote(,)dnl | |
281 | libgomp_libgcc_s_suffix=`${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \ | |
282 | -shared -shared-libgcc -o conftest.so \ | |
283 | conftest.c -v 2>&1 >/dev/null \ | |
284 | | sed -n 's/^.* -lgcc_s\([^ ]*\) .*$/\1/p'` | |
285 | changequote([,])dnl | |
286 | rm -f conftest.c conftest.so | |
287 | if test x${libgomp_libgcc_s_suffix+set} = xset; then | |
288 | CFLAGS=" -lgcc_s$libgomp_libgcc_s_suffix" | |
289 | AC_TRY_LINK(, [return 0;], libgomp_shared_libgcc=yes) | |
290 | CFLAGS="$ac_save_CFLAGS" | |
291 | fi | |
292 | fi | |
293 | AC_MSG_RESULT($libgomp_shared_libgcc) | |
294 | fi | |
295 | ||
296 | # For GNU ld, we need at least this version. The format is described in | |
297 | # LIBGOMP_CHECK_LINKER_FEATURES above. | |
298 | libgomp_min_gnu_ld_version=21400 | |
299 | # XXXXXXXXXXX libgomp_gnu_ld_version=21390 | |
300 | ||
301 | # Check to see if unspecified "yes" value can win, given results above. | |
302 | # Change "yes" into either "no" or a style name. | |
6d28b933 RO |
303 | if test $enable_symvers != no && test $libgomp_shared_libgcc = yes; then |
304 | if test $with_gnu_ld = yes; then | |
953ff289 DN |
305 | if test $libgomp_gnu_ld_version -ge $libgomp_min_gnu_ld_version ; then |
306 | enable_symvers=gnu | |
b39dea08 ILT |
307 | elif test $libgomp_ld_is_gold = yes ; then |
308 | enable_symvers=gnu | |
953ff289 DN |
309 | else |
310 | # The right tools, the right setup, but too old. Fallbacks? | |
311 | AC_MSG_WARN(=== Linker version $libgomp_gnu_ld_version is too old for) | |
312 | AC_MSG_WARN(=== full symbol versioning support in this release of GCC.) | |
313 | AC_MSG_WARN(=== You would need to upgrade your binutils to version) | |
314 | AC_MSG_WARN(=== $libgomp_min_gnu_ld_version or later and rebuild GCC.) | |
315 | if test $libgomp_gnu_ld_version -ge 21200 ; then | |
316 | # Globbing fix is present, proper block support is not. | |
317 | dnl AC_MSG_WARN([=== Dude, you are soooo close. Maybe we can fake it.]) | |
318 | dnl enable_symvers=??? | |
319 | AC_MSG_WARN([=== Symbol versioning will be disabled.]) | |
320 | enable_symvers=no | |
321 | else | |
322 | # 2.11 or older. | |
323 | AC_MSG_WARN([=== Symbol versioning will be disabled.]) | |
324 | enable_symvers=no | |
325 | fi | |
326 | fi | |
6d28b933 RO |
327 | elif test $enable_symvers = sun; then |
328 | : All interesting versions of Sun ld support sun style symbol versioning. | |
953ff289 DN |
329 | else |
330 | # just fail for now | |
331 | AC_MSG_WARN([=== You have requested some kind of symbol versioning, but]) | |
332 | AC_MSG_WARN([=== either you are not using a supported linker, or you are]) | |
333 | AC_MSG_WARN([=== not building a shared libgcc_s (which is required).]) | |
334 | AC_MSG_WARN([=== Symbol versioning will be disabled.]) | |
335 | enable_symvers=no | |
336 | fi | |
337 | fi | |
338 | ||
876080ff JJ |
339 | AC_CACHE_CHECK([whether the target supports .symver directive], |
340 | libgomp_cv_have_as_symver_directive, [ | |
341 | AC_TRY_COMPILE([void foo (void); __asm (".symver foo, bar@SYMVER");], | |
342 | [], libgomp_cv_have_as_symver_directive=yes, | |
343 | libgomp_cv_have_as_symver_directive=no)]) | |
344 | if test $libgomp_cv_have_as_symver_directive = yes; then | |
345 | AC_DEFINE(HAVE_AS_SYMVER_DIRECTIVE, 1, | |
346 | [Define to 1 if the target assembler supports .symver directive.]) | |
347 | fi | |
348 | ||
953ff289 | 349 | AM_CONDITIONAL(LIBGOMP_BUILD_VERSIONED_SHLIB, test $enable_symvers != no) |
6d28b933 RO |
350 | AM_CONDITIONAL(LIBGOMP_BUILD_VERSIONED_SHLIB_GNU, test $enable_symvers = gnu) |
351 | AM_CONDITIONAL(LIBGOMP_BUILD_VERSIONED_SHLIB_SUN, test $enable_symvers = sun) | |
953ff289 | 352 | AC_MSG_NOTICE(versioning on shared library symbols is $enable_symvers) |
6d28b933 RO |
353 | |
354 | if test $enable_symvers != no ; then | |
355 | case ${target_os} in | |
356 | # The Solaris 2 runtime linker doesn't support the GNU extension of | |
357 | # binding the same symbol to different versions | |
358 | solaris2*) | |
cc2de92d | 359 | ;; |
6d28b933 RO |
360 | # Other platforms with GNU symbol versioning (GNU/Linux, more?) do. |
361 | *) | |
362 | AC_DEFINE(HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT, 1, | |
363 | [Define to 1 if the target runtime linker supports binding the same symbol to different versions.]) | |
cc2de92d | 364 | ;; |
6d28b933 RO |
365 | esac |
366 | fi | |
953ff289 | 367 | ]) |