1 dnl Check whether the target supports TLS.
2 AC_DEFUN([LIBGOMP_CHECK_TLS], [
3 LIBGOMP_ENABLE(tls, yes, [Use thread-local storage])
4 AC_CACHE_CHECK([whether the target supports thread-local storage],
6 AC_TRY_COMPILE([__thread int foo;],
7 [], have_tls=$enable_tls, have_tls=no)])
8 if test $have_tls = yes; then
10 [Define to 1 if the target supports thread-local storage.])
13 dnl ----------------------------------------------------------------------
14 dnl This whole bit snagged from libgfortran.
16 dnl Check whether the target supports __sync_*_compare_and_swap.
17 AC_DEFUN([LIBGOMP_CHECK_SYNC_BUILTINS], [
18 AC_CACHE_CHECK([whether the target supports __sync_*_compare_and_swap],
20 AC_TRY_LINK([], [int foo, bar; bar = __sync_val_compare_and_swap(&foo, 0, 1);],
21 have_sync_builtins=yes, have_sync_builtins=no)])
22 if test $have_sync_builtins = yes; then
23 AC_DEFINE(HAVE_SYNC_BUILTINS, 1,
24 [Define to 1 if the target supports __sync_*_compare_and_swap])
27 dnl Check whether the target supports hidden visibility.
28 AC_DEFUN([LIBGOMP_CHECK_ATTRIBUTE_VISIBILITY], [
29 AC_CACHE_CHECK([whether the target supports hidden visibility],
30 have_attribute_visibility, [
32 CFLAGS="$CFLAGS -Werror"
33 AC_TRY_COMPILE([void __attribute__((visibility("hidden"))) foo(void) { }],
34 [], have_attribute_visibility=yes,
35 have_attribute_visibility=no)
36 CFLAGS="$save_CFLAGS"])
37 if test $have_attribute_visibility = yes; then
38 AC_DEFINE(HAVE_ATTRIBUTE_VISIBILITY, 1,
39 [Define to 1 if the target supports __attribute__((visibility(...))).])
42 dnl Check whether the target supports dllexport
43 AC_DEFUN([LIBGOMP_CHECK_ATTRIBUTE_DLLEXPORT], [
44 AC_CACHE_CHECK([whether the target supports dllexport],
45 have_attribute_dllexport, [
47 CFLAGS="$CFLAGS -Werror"
48 AC_TRY_COMPILE([void __attribute__((dllexport)) foo(void) { }],
49 [], have_attribute_dllexport=yes,
50 have_attribute_dllexport=no)
51 CFLAGS="$save_CFLAGS"])
52 if test $have_attribute_dllexport = yes; then
53 AC_DEFINE(HAVE_ATTRIBUTE_DLLEXPORT, 1,
54 [Define to 1 if the target supports __attribute__((dllexport)).])
57 dnl Check whether the target supports symbol aliases.
58 AC_DEFUN([LIBGOMP_CHECK_ATTRIBUTE_ALIAS], [
59 AC_CACHE_CHECK([whether the target supports symbol aliases],
60 have_attribute_alias, [
62 #define ULP STR1(__USER_LABEL_PREFIX__)
63 #define STR1(x) STR2(x)
66 extern void bar(void) __attribute__((alias(ULP "foo")));],
67 [bar();], have_attribute_alias=yes, have_attribute_alias=no)])
68 if test $have_attribute_alias = yes; then
69 AC_DEFINE(HAVE_ATTRIBUTE_ALIAS, 1,
70 [Define to 1 if the target supports __attribute__((alias(...))).])
73 sinclude(../libtool.m4)
74 dnl The lines below arrange for aclocal not to bring an installed
75 dnl libtool.m4 into aclocal.m4, while still arranging for automake to
76 dnl add a definition of LIBTOOL to Makefile.in.
77 ifelse(,,,[AC_SUBST(LIBTOOL)
78 AC_DEFUN([AM_PROG_LIBTOOL])
79 AC_DEFUN([AC_LIBTOOL_DLOPEN])
80 AC_DEFUN([AC_PROG_LD])
83 dnl ----------------------------------------------------------------------
84 dnl This whole bit snagged from libstdc++-v3.
88 dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING)
89 dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, permit a|b|c)
90 dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, SHELL-CODE-HANDLER)
92 dnl See docs/html/17_intro/configury.html#enable for documentation.
94 m4_define([LIBGOMP_ENABLE],[dnl
95 m4_define([_g_switch],[--enable-$1])dnl
96 m4_define([_g_help],[AC_HELP_STRING(_g_switch$3,[$4 @<:@default=$2@:>@])])dnl
97 AC_ARG_ENABLE($1,_g_help,
102 m4_bpatsubst([$5],[permit ])) ;;
103 *) AC_MSG_ERROR(Unknown argument to enable/disable $1) ;;
104 dnl Idea for future: generate a URL pointing to
105 dnl "onlinedocs/configopts.html#whatever"
112 *) AC_MSG_ERROR(Argument to enable/disable $1 must be yes or no) ;;
116 [enable_]m4_bpatsubst([$1],-,_)[=][$2])
117 m4_undefine([_g_switch])dnl
118 m4_undefine([_g_help])dnl
123 dnl If GNU ld is in use, check to see if tricky linker opts can be used. If
124 dnl the native linker is in use, all variables will be defined to something
125 dnl safe (like an empty string).
128 dnl SECTION_LDFLAGS='-Wl,--gc-sections' if possible
129 dnl OPT_LDFLAGS='-Wl,-O1' if possible
130 dnl LD (as a side effect of testing)
133 dnl libgomp_gnu_ld_version (possibly)
135 dnl The last will be a single integer, e.g., version 1.23.45.0.67.89 will
136 dnl set libgomp_gnu_ld_version to 12345. Zeros cause problems.
138 AC_DEFUN([LIBGOMP_CHECK_LINKER_FEATURES], [
139 # If we're not using GNU ld, then there's no point in even trying these
140 # tests. Check for that first. We should have already tested for gld
141 # by now (in libtool), but require it now just to be safe...
142 test -z "$SECTION_LDFLAGS" && SECTION_LDFLAGS=''
143 test -z "$OPT_LDFLAGS" && OPT_LDFLAGS=''
144 AC_REQUIRE([AC_PROG_LD])
145 AC_REQUIRE([AC_PROG_AWK])
147 # The name set by libtool depends on the version of libtool. Shame on us
148 # for depending on an impl detail, but c'est la vie. Older versions used
149 # ac_cv_prog_gnu_ld, but now it's lt_cv_prog_gnu_ld, and is copied back on
150 # top of with_gnu_ld (which is also set by --with-gnu-ld, so that actually
151 # makes sense). We'll test with_gnu_ld everywhere else, so if that isn't
152 # set (hence we're using an older libtool), then set it.
153 if test x${with_gnu_ld+set} != xset; then
154 if test x${ac_cv_prog_gnu_ld+set} != xset; then
155 # We got through "ac_require(ac_prog_ld)" and still not set? Huh?
158 with_gnu_ld=$ac_cv_prog_gnu_ld
162 # Start by getting the version number. I think the libtool test already
163 # does some of this, but throws away the result.
165 ldver=`$LD --version 2>/dev/null | head -1 | \
166 sed -e 's/GNU ld version \([0-9.][0-9.]*\).*/\1/'`
168 libgomp_gnu_ld_version=`echo $ldver | \
169 $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
172 if test "$with_gnu_ld" = "notbroken"; then
173 # GNU ld it is! Joy and bunny rabbits!
175 # All these tests are for C++; save the language and the compiler flags.
176 # Need to do this so that g++ won't try to link in libstdc++
177 ac_test_CFLAGS="${CFLAGS+set}"
178 ac_save_CFLAGS="$CFLAGS"
179 CFLAGS='-x c++ -Wl,--gc-sections'
181 # Check for -Wl,--gc-sections
182 # XXX This test is broken at the moment, as symbols required for linking
183 # are now in libsupc++ (not built yet). In addition, this test has
184 # cored on solaris in the past. In addition, --gc-sections doesn't
185 # really work at the moment (keeps on discarding used sections, first
186 # .eh_frame and now some of the glibc sections for iconv).
187 # Bzzzzt. Thanks for playing, maybe next time.
188 AC_MSG_CHECKING([for ld that supports -Wl,--gc-sections])
196 ], [ac_sectionLDflags=yes],[ac_sectionLDflags=no], [ac_sectionLDflags=yes])
197 if test "$ac_test_CFLAGS" = set; then
198 CFLAGS="$ac_save_CFLAGS"
200 # this is the suspicious part
203 if test "$ac_sectionLDflags" = "yes"; then
204 SECTION_LDFLAGS="-Wl,--gc-sections $SECTION_LDFLAGS"
206 AC_MSG_RESULT($ac_sectionLDflags)
209 # Set linker optimization flags.
210 if test x"$with_gnu_ld" = x"yes"; then
211 OPT_LDFLAGS="-Wl,-O1 $OPT_LDFLAGS"
214 AC_SUBST(SECTION_LDFLAGS)
215 AC_SUBST(OPT_LDFLAGS)
220 dnl Add version tags to symbols in shared library (or not), additionally
221 dnl marking other symbols as private/local (or not).
223 dnl --enable-symvers=style adds a version script to the linker call when
224 dnl creating the shared library. The choice of version script is
225 dnl controlled by 'style'.
226 dnl --disable-symvers does not.
227 dnl + Usage: LIBGOMP_ENABLE_SYMVERS[(DEFAULT)]
228 dnl Where DEFAULT is either 'yes' or 'no'. Passing `yes' tries to
229 dnl choose a default style based on linker characteristics. Passing
230 dnl 'no' disables versioning.
232 AC_DEFUN([LIBGOMP_ENABLE_SYMVERS], [
234 LIBGOMP_ENABLE(symvers,yes,[=STYLE],
235 [enables symbol versioning of the shared library],
238 # If we never went through the LIBGOMP_CHECK_LINKER_FEATURES macro, then we
239 # don't know enough about $LD to do tricks...
240 AC_REQUIRE([LIBGOMP_CHECK_LINKER_FEATURES])
241 # FIXME The following test is too strict, in theory.
242 if test $enable_shared = no ||
244 test x$libgomp_gnu_ld_version = x; then
248 # Check to see if libgcc_s exists, indicating that shared libgcc is possible.
249 if test $enable_symvers != no; then
250 AC_MSG_CHECKING([for shared libgcc])
251 ac_save_CFLAGS="$CFLAGS"
253 AC_TRY_LINK(, [return 0;], libgomp_shared_libgcc=yes, libgomp_shared_libgcc=no)
254 CFLAGS="$ac_save_CFLAGS"
255 if test $libgomp_shared_libgcc = no; then
256 cat > conftest.c <<EOF
257 int main (void) { return 0; }
260 libgomp_libgcc_s_suffix=`${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
261 -shared -shared-libgcc -o conftest.so \
262 conftest.c -v 2>&1 >/dev/null \
263 | sed -n 's/^.* -lgcc_s\([^ ]*\) .*$/\1/p'`
265 rm -f conftest.c conftest.so
266 if test x${libgomp_libgcc_s_suffix+set} = xset; then
267 CFLAGS=" -lgcc_s$libgomp_libgcc_s_suffix"
268 AC_TRY_LINK(, [return 0;], libgomp_shared_libgcc=yes)
269 CFLAGS="$ac_save_CFLAGS"
272 AC_MSG_RESULT($libgomp_shared_libgcc)
275 # For GNU ld, we need at least this version. The format is described in
276 # LIBGOMP_CHECK_LINKER_FEATURES above.
277 libgomp_min_gnu_ld_version=21400
278 # XXXXXXXXXXX libgomp_gnu_ld_version=21390
280 # Check to see if unspecified "yes" value can win, given results above.
281 # Change "yes" into either "no" or a style name.
282 if test $enable_symvers = yes; then
283 if test $with_gnu_ld = yes &&
284 test $libgomp_shared_libgcc = yes;
286 if test $libgomp_gnu_ld_version -ge $libgomp_min_gnu_ld_version ; then
289 # The right tools, the right setup, but too old. Fallbacks?
290 AC_MSG_WARN(=== Linker version $libgomp_gnu_ld_version is too old for)
291 AC_MSG_WARN(=== full symbol versioning support in this release of GCC.)
292 AC_MSG_WARN(=== You would need to upgrade your binutils to version)
293 AC_MSG_WARN(=== $libgomp_min_gnu_ld_version or later and rebuild GCC.)
294 if test $libgomp_gnu_ld_version -ge 21200 ; then
295 # Globbing fix is present, proper block support is not.
296 dnl AC_MSG_WARN([=== Dude, you are soooo close. Maybe we can fake it.])
297 dnl enable_symvers=???
298 AC_MSG_WARN([=== Symbol versioning will be disabled.])
302 AC_MSG_WARN([=== Symbol versioning will be disabled.])
308 AC_MSG_WARN([=== You have requested some kind of symbol versioning, but])
309 AC_MSG_WARN([=== either you are not using a supported linker, or you are])
310 AC_MSG_WARN([=== not building a shared libgcc_s (which is required).])
311 AC_MSG_WARN([=== Symbol versioning will be disabled.])
316 AM_CONDITIONAL(LIBGOMP_BUILD_VERSIONED_SHLIB, test $enable_symvers != no)
317 AC_MSG_NOTICE(versioning on shared library symbols is $enable_symvers)