OSDN Git Service

* dwarf2out.c (DWARF2_FRAME_REG_OUT): Move up in file.
[pf3gnuchains/gcc-fork.git] / libgomp / acinclude.m4
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],
5                  have_tls, [
6     AC_TRY_COMPILE([__thread int foo;],
7                    [], have_tls=$enable_tls, have_tls=no)])
8   if test $have_tls = yes; then
9     AC_DEFINE(HAVE_TLS, 1,
10               [Define to 1 if the target supports thread-local storage.])
11   fi])
12
13 dnl ----------------------------------------------------------------------
14 dnl This whole bit snagged from libgfortran.
15
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],
19                  have_sync_builtins, [
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])
25   fi])
26
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, [
31   save_CFLAGS="$CFLAGS"
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(...))).])
40   fi])
41
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, [
46   save_CFLAGS="$CFLAGS"
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)).])
55   fi])
56
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, [
61   AC_TRY_LINK([
62 #define ULP     STR1(__USER_LABEL_PREFIX__)
63 #define STR1(x) STR2(x)
64 #define STR2(x) #x
65 void foo(void) { }
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(...))).])
71   fi])
72
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])
81 ])
82
83 dnl ----------------------------------------------------------------------
84 dnl This whole bit snagged from libstdc++-v3.
85
86 dnl
87 dnl LIBGOMP_ENABLE
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)
91 dnl
92 dnl See docs/html/17_intro/configury.html#enable for documentation.
93 dnl
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,
98   m4_bmatch([$5],
99    [^permit ],
100      [[
101       case "$enableval" in
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"
106       esac
107      ]],
108    [^$],
109      [[
110       case "$enableval" in
111        yes|no) ;;
112        *) AC_MSG_ERROR(Argument to enable/disable $1 must be yes or no) ;;
113       esac
114      ]],
115    [[$5]]),
116   [enable_]m4_bpatsubst([$1],-,_)[=][$2])
117 m4_undefine([_g_switch])dnl
118 m4_undefine([_g_help])dnl
119 ])
120
121
122 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).
126 dnl
127 dnl Defines:
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)
131 dnl Sets:
132 dnl  with_gnu_ld
133 dnl  libgomp_gnu_ld_version (possibly)
134 dnl
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.
137 dnl
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])
146
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?
156       with_gnu_ld=no
157     else
158       with_gnu_ld=$ac_cv_prog_gnu_ld
159     fi
160   fi
161
162   # Start by getting the version number.  I think the libtool test already
163   # does some of this, but throws away the result.
164   changequote(,)
165   ldver=`$LD --version 2>/dev/null | head -1 | \
166          sed -e 's/GNU ld version \([0-9.][0-9.]*\).*/\1/'`
167   changequote([,])
168   libgomp_gnu_ld_version=`echo $ldver | \
169          $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
170
171   # Set --gc-sections.
172   if test "$with_gnu_ld" = "notbroken"; then
173     # GNU ld it is!  Joy and bunny rabbits!
174
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'
180
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])
189     AC_TRY_RUN([
190      int main(void)
191      {
192        try { throw 1; }
193        catch (...) { };
194        return 0;
195      }
196     ], [ac_sectionLDflags=yes],[ac_sectionLDflags=no], [ac_sectionLDflags=yes])
197     if test "$ac_test_CFLAGS" = set; then
198       CFLAGS="$ac_save_CFLAGS"
199     else
200       # this is the suspicious part
201       CFLAGS=''
202     fi
203     if test "$ac_sectionLDflags" = "yes"; then
204       SECTION_LDFLAGS="-Wl,--gc-sections $SECTION_LDFLAGS"
205     fi
206     AC_MSG_RESULT($ac_sectionLDflags)
207   fi
208
209   # Set linker optimization flags.
210   if test x"$with_gnu_ld" = x"yes"; then
211     OPT_LDFLAGS="-Wl,-O1 $OPT_LDFLAGS"
212   fi
213
214   AC_SUBST(SECTION_LDFLAGS)
215   AC_SUBST(OPT_LDFLAGS)
216 ])
217
218
219 dnl
220 dnl Add version tags to symbols in shared library (or not), additionally
221 dnl marking other symbols as private/local (or not).
222 dnl
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.
231 dnl
232 AC_DEFUN([LIBGOMP_ENABLE_SYMVERS], [
233
234 LIBGOMP_ENABLE(symvers,yes,[=STYLE],
235   [enables symbol versioning of the shared library],
236   [permit yes|no|gnu])
237
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 ||
243         test "x$LD" = x ||
244         test x$libgomp_gnu_ld_version = x; then
245   enable_symvers=no
246 fi
247
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"
252   CFLAGS=' -lgcc_s'
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; }
258 EOF
259 changequote(,)dnl
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'`
264 changequote([,])dnl
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"
270     fi
271   fi
272   AC_MSG_RESULT($libgomp_shared_libgcc)
273 fi
274
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
279
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;
285   then
286     if test $libgomp_gnu_ld_version -ge $libgomp_min_gnu_ld_version ; then
287       enable_symvers=gnu
288     else
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.])
299         enable_symvers=no
300       else
301         # 2.11 or older.
302         AC_MSG_WARN([=== Symbol versioning will be disabled.])
303         enable_symvers=no
304       fi
305     fi
306   else
307     # just fail for now
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.])
312     enable_symvers=no
313   fi
314 fi
315
316 AM_CONDITIONAL(LIBGOMP_BUILD_VERSIONED_SHLIB, test $enable_symvers != no)
317 AC_MSG_NOTICE(versioning on shared library symbols is $enable_symvers)
318 ])