1 dnl ----------------------------------------------------------------------
2 dnl This whole bit snagged from libgfortran.
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],
8 AC_TRY_LINK([], [int foo, bar; bar = __sync_val_compare_and_swap(&foo, 0, 1);],
9 have_sync_builtins=yes, have_sync_builtins=no)])
10 if test $have_sync_builtins = yes; then
11 AC_DEFINE(HAVE_SYNC_BUILTINS, 1,
12 [Define to 1 if the target supports __sync_*_compare_and_swap])
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],
18 have_attribute_visibility, [
20 CFLAGS="$CFLAGS -Werror"
21 AC_TRY_COMPILE([void __attribute__((visibility("hidden"))) foo(void) { }],
22 [], have_attribute_visibility=yes,
23 have_attribute_visibility=no)
24 CFLAGS="$save_CFLAGS"])
25 if test $have_attribute_visibility = yes; then
26 AC_DEFINE(HAVE_ATTRIBUTE_VISIBILITY, 1,
27 [Define to 1 if the target supports __attribute__((visibility(...))).])
30 dnl Check whether the target supports dllexport
31 AC_DEFUN([LIBGOMP_CHECK_ATTRIBUTE_DLLEXPORT], [
32 AC_CACHE_CHECK([whether the target supports dllexport],
33 have_attribute_dllexport, [
35 CFLAGS="$CFLAGS -Werror"
36 AC_TRY_COMPILE([void __attribute__((dllexport)) foo(void) { }],
37 [], have_attribute_dllexport=yes,
38 have_attribute_dllexport=no)
39 CFLAGS="$save_CFLAGS"])
40 if test $have_attribute_dllexport = yes; then
41 AC_DEFINE(HAVE_ATTRIBUTE_DLLEXPORT, 1,
42 [Define to 1 if the target supports __attribute__((dllexport)).])
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],
48 have_attribute_alias, [
50 #define ULP STR1(__USER_LABEL_PREFIX__)
51 #define STR1(x) STR2(x)
54 extern void bar(void) __attribute__((alias(ULP "foo")));],
55 [bar();], have_attribute_alias=yes, have_attribute_alias=no)])
56 if test $have_attribute_alias = yes; then
57 AC_DEFINE(HAVE_ATTRIBUTE_ALIAS, 1,
58 [Define to 1 if the target supports __attribute__((alias(...))).])
61 sinclude(../libtool.m4)
62 dnl The lines below arrange for aclocal not to bring an installed
63 dnl libtool.m4 into aclocal.m4, while still arranging for automake to
64 dnl add a definition of LIBTOOL to Makefile.in.
65 ifelse(,,,[AC_SUBST(LIBTOOL)
66 AC_DEFUN([AM_PROG_LIBTOOL])
67 AC_DEFUN([AC_LIBTOOL_DLOPEN])
68 AC_DEFUN([AC_PROG_LD])
71 dnl ----------------------------------------------------------------------
72 dnl This whole bit snagged from libstdc++-v3.
76 dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING)
77 dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, permit a|b|c)
78 dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, SHELL-CODE-HANDLER)
80 dnl See docs/html/17_intro/configury.html#enable for documentation.
82 m4_define([LIBGOMP_ENABLE],[dnl
83 m4_define([_g_switch],[--enable-$1])dnl
84 m4_define([_g_help],[AC_HELP_STRING(_g_switch$3,[$4 @<:@default=$2@:>@])])dnl
85 AC_ARG_ENABLE($1,_g_help,
90 m4_bpatsubst([$5],[permit ])) ;;
91 *) AC_MSG_ERROR(Unknown argument to enable/disable $1) ;;
92 dnl Idea for future: generate a URL pointing to
93 dnl "onlinedocs/configopts.html#whatever"
100 *) AC_MSG_ERROR(Argument to enable/disable $1 must be yes or no) ;;
104 [enable_]m4_bpatsubst([$1],-,_)[=][$2])
105 m4_undefine([_g_switch])dnl
106 m4_undefine([_g_help])dnl
111 dnl If GNU ld is in use, check to see if tricky linker opts can be used. If
112 dnl the native linker is in use, all variables will be defined to something
113 dnl safe (like an empty string).
116 dnl SECTION_LDFLAGS='-Wl,--gc-sections' if possible
117 dnl OPT_LDFLAGS='-Wl,-O1' if possible
118 dnl LD (as a side effect of testing)
121 dnl libgomp_gnu_ld_version (possibly)
123 dnl The last will be a single integer, e.g., version 1.23.45.0.67.89 will
124 dnl set libgomp_gnu_ld_version to 12345. Zeros cause problems.
126 AC_DEFUN([LIBGOMP_CHECK_LINKER_FEATURES], [
127 # If we're not using GNU ld, then there's no point in even trying these
128 # tests. Check for that first. We should have already tested for gld
129 # by now (in libtool), but require it now just to be safe...
130 test -z "$SECTION_LDFLAGS" && SECTION_LDFLAGS=''
131 test -z "$OPT_LDFLAGS" && OPT_LDFLAGS=''
132 AC_REQUIRE([AC_PROG_LD])
133 AC_REQUIRE([AC_PROG_AWK])
135 # The name set by libtool depends on the version of libtool. Shame on us
136 # for depending on an impl detail, but c'est la vie. Older versions used
137 # ac_cv_prog_gnu_ld, but now it's lt_cv_prog_gnu_ld, and is copied back on
138 # top of with_gnu_ld (which is also set by --with-gnu-ld, so that actually
139 # makes sense). We'll test with_gnu_ld everywhere else, so if that isn't
140 # set (hence we're using an older libtool), then set it.
141 if test x${with_gnu_ld+set} != xset; then
142 if test x${ac_cv_prog_gnu_ld+set} != xset; then
143 # We got through "ac_require(ac_prog_ld)" and still not set? Huh?
146 with_gnu_ld=$ac_cv_prog_gnu_ld
150 # Start by getting the version number. I think the libtool test already
151 # does some of this, but throws away the result.
153 ldver=`$LD --version 2>/dev/null | head -1 | \
154 sed -e 's/GNU ld version \([0-9.][0-9.]*\).*/\1/'`
156 libgomp_gnu_ld_version=`echo $ldver | \
157 $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
160 if test "$with_gnu_ld" = "notbroken"; then
161 # GNU ld it is! Joy and bunny rabbits!
163 # All these tests are for C++; save the language and the compiler flags.
164 # Need to do this so that g++ won't try to link in libstdc++
165 ac_test_CFLAGS="${CFLAGS+set}"
166 ac_save_CFLAGS="$CFLAGS"
167 CFLAGS='-x c++ -Wl,--gc-sections'
169 # Check for -Wl,--gc-sections
170 # XXX This test is broken at the moment, as symbols required for linking
171 # are now in libsupc++ (not built yet). In addition, this test has
172 # cored on solaris in the past. In addition, --gc-sections doesn't
173 # really work at the moment (keeps on discarding used sections, first
174 # .eh_frame and now some of the glibc sections for iconv).
175 # Bzzzzt. Thanks for playing, maybe next time.
176 AC_MSG_CHECKING([for ld that supports -Wl,--gc-sections])
184 ], [ac_sectionLDflags=yes],[ac_sectionLDflags=no], [ac_sectionLDflags=yes])
185 if test "$ac_test_CFLAGS" = set; then
186 CFLAGS="$ac_save_CFLAGS"
188 # this is the suspicious part
191 if test "$ac_sectionLDflags" = "yes"; then
192 SECTION_LDFLAGS="-Wl,--gc-sections $SECTION_LDFLAGS"
194 AC_MSG_RESULT($ac_sectionLDflags)
197 # Set linker optimization flags.
198 if test x"$with_gnu_ld" = x"yes"; then
199 OPT_LDFLAGS="-Wl,-O1 $OPT_LDFLAGS"
202 AC_SUBST(SECTION_LDFLAGS)
203 AC_SUBST(OPT_LDFLAGS)
208 dnl Add version tags to symbols in shared library (or not), additionally
209 dnl marking other symbols as private/local (or not).
211 dnl --enable-symvers=style adds a version script to the linker call when
212 dnl creating the shared library. The choice of version script is
213 dnl controlled by 'style'.
214 dnl --disable-symvers does not.
215 dnl + Usage: LIBGOMP_ENABLE_SYMVERS[(DEFAULT)]
216 dnl Where DEFAULT is either 'yes' or 'no'. Passing `yes' tries to
217 dnl choose a default style based on linker characteristics. Passing
218 dnl 'no' disables versioning.
220 AC_DEFUN([LIBGOMP_ENABLE_SYMVERS], [
222 LIBGOMP_ENABLE(symvers,yes,[=STYLE],
223 [enables symbol versioning of the shared library],
226 # If we never went through the LIBGOMP_CHECK_LINKER_FEATURES macro, then we
227 # don't know enough about $LD to do tricks...
228 AC_REQUIRE([LIBGOMP_CHECK_LINKER_FEATURES])
229 # FIXME The following test is too strict, in theory.
230 if test $enable_shared = no ||
232 test x$libgomp_gnu_ld_version = x; then
236 # Check to see if libgcc_s exists, indicating that shared libgcc is possible.
237 if test $enable_symvers != no; then
238 AC_MSG_CHECKING([for shared libgcc])
239 ac_save_CFLAGS="$CFLAGS"
241 AC_TRY_LINK(, [return 0;], libgomp_shared_libgcc=yes, libgomp_shared_libgcc=no)
242 CFLAGS="$ac_save_CFLAGS"
243 if test $libgomp_shared_libgcc = no; then
244 cat > conftest.c <<EOF
245 int main (void) { return 0; }
248 libgomp_libgcc_s_suffix=`${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
249 -shared -shared-libgcc -o conftest.so \
250 conftest.c -v 2>&1 >/dev/null \
251 | sed -n 's/^.* -lgcc_s\([^ ]*\) .*$/\1/p'`
253 rm -f conftest.c conftest.so
254 if test x${libgomp_libgcc_s_suffix+set} = xset; then
255 CFLAGS=" -lgcc_s$libgomp_libgcc_s_suffix"
256 AC_TRY_LINK(, [return 0;], libgomp_shared_libgcc=yes)
257 CFLAGS="$ac_save_CFLAGS"
260 AC_MSG_RESULT($libgomp_shared_libgcc)
263 # For GNU ld, we need at least this version. The format is described in
264 # LIBGOMP_CHECK_LINKER_FEATURES above.
265 libgomp_min_gnu_ld_version=21400
266 # XXXXXXXXXXX libgomp_gnu_ld_version=21390
268 # Check to see if unspecified "yes" value can win, given results above.
269 # Change "yes" into either "no" or a style name.
270 if test $enable_symvers = yes; then
271 if test $with_gnu_ld = yes &&
272 test $libgomp_shared_libgcc = yes;
274 if test $libgomp_gnu_ld_version -ge $libgomp_min_gnu_ld_version ; then
277 # The right tools, the right setup, but too old. Fallbacks?
278 AC_MSG_WARN(=== Linker version $libgomp_gnu_ld_version is too old for)
279 AC_MSG_WARN(=== full symbol versioning support in this release of GCC.)
280 AC_MSG_WARN(=== You would need to upgrade your binutils to version)
281 AC_MSG_WARN(=== $libgomp_min_gnu_ld_version or later and rebuild GCC.)
282 if test $libgomp_gnu_ld_version -ge 21200 ; then
283 # Globbing fix is present, proper block support is not.
284 dnl AC_MSG_WARN([=== Dude, you are soooo close. Maybe we can fake it.])
285 dnl enable_symvers=???
286 AC_MSG_WARN([=== Symbol versioning will be disabled.])
290 AC_MSG_WARN([=== Symbol versioning will be disabled.])
296 AC_MSG_WARN([=== You have requested some kind of symbol versioning, but])
297 AC_MSG_WARN([=== either you are not using a supported linker, or you are])
298 AC_MSG_WARN([=== not building a shared libgcc_s (which is required).])
299 AC_MSG_WARN([=== Symbol versioning will be disabled.])
304 AM_CONDITIONAL(LIBGOMP_BUILD_VERSIONED_SHLIB, test $enable_symvers != no)
305 AC_MSG_NOTICE(versioning on shared library symbols is $enable_symvers)