]> git.ipfire.org Git - thirdparty/gcc.git/blame - libitm/acinclude.m4
libitm: Remove unused PAGE_SIZE macros
[thirdparty/gcc.git] / libitm / acinclude.m4
CommitLineData
4c0315d0 1dnl ----------------------------------------------------------------------
2dnl This whole bit snagged from libgfortran.
3
4dnl Check whether the target supports __sync_*_compare_and_swap.
5AC_DEFUN([LIBITM_CHECK_SYNC_BUILTINS], [
6 AC_CACHE_CHECK([whether the target supports __sync_*_compare_and_swap],
7 libitm_cv_have_sync_builtins, [
8 AC_TRY_LINK([], [int foo, bar; bar = __sync_val_compare_and_swap(&foo, 0, 1);],
9 libitm_cv_have_sync_builtins=yes, libitm_cv_have_sync_builtins=no)])
10 if test $libitm_cv_have_sync_builtins = yes; then
11 AC_DEFINE(HAVE_SYNC_BUILTINS, 1,
12 [Define to 1 if the target supports __sync_*_compare_and_swap])
13 fi])
14
15dnl Check whether the target supports 64-bit __sync_*_compare_and_swap.
16AC_DEFUN([LIBITM_CHECK_64BIT_SYNC_BUILTINS], [
17 AC_CACHE_CHECK([whether the target supports 64-bit __sync_*_compare_and_swap],
18 libitm_cv_have_64bit_sync_builtins, [
19 AC_TRY_LINK([#include <stdint.h>],
20 [uint64_t foo, bar;
21 bar = __sync_val_compare_and_swap(&foo, 0, 1);],
22 libitm_cv_have_64bit_sync_builtins=yes,
23 libitm_cv_have_64bit_sync_builtins=no)])
24 if test $libitm_cv_have_64bit_sync_builtins = yes; then
25 AC_DEFINE(HAVE_64BIT_SYNC_BUILTINS, 1,
26 [Define to 1 if the target supports 64-bit __sync_*_compare_and_swap])
27 fi])
28
29dnl Check whether the target supports hidden visibility.
30AC_DEFUN([LIBITM_CHECK_ATTRIBUTE_VISIBILITY], [
31 AC_CACHE_CHECK([whether the target supports hidden visibility],
32 libitm_cv_have_attribute_visibility, [
33 save_CFLAGS="$CFLAGS"
34 CFLAGS="$CFLAGS -Werror"
35 AC_TRY_COMPILE([void __attribute__((visibility("hidden"))) foo(void) { }],
36 [], libitm_cv_have_attribute_visibility=yes,
37 libitm_cv_have_attribute_visibility=no)
38 CFLAGS="$save_CFLAGS"])
39 if test $libitm_cv_have_attribute_visibility = yes; then
40 AC_DEFINE(HAVE_ATTRIBUTE_VISIBILITY, 1,
41 [Define to 1 if the target supports __attribute__((visibility(...))).])
42 fi])
43
44dnl Check whether the target supports dllexport
45AC_DEFUN([LIBITM_CHECK_ATTRIBUTE_DLLEXPORT], [
46 AC_CACHE_CHECK([whether the target supports dllexport],
47 libitm_cv_have_attribute_dllexport, [
48 save_CFLAGS="$CFLAGS"
49 CFLAGS="$CFLAGS -Werror"
50 AC_TRY_COMPILE([void __attribute__((dllexport)) foo(void) { }],
51 [], libitm_cv_have_attribute_dllexport=yes,
52 libitm_cv_have_attribute_dllexport=no)
53 CFLAGS="$save_CFLAGS"])
54 if test $libitm_cv_have_attribute_dllexport = yes; then
55 AC_DEFINE(HAVE_ATTRIBUTE_DLLEXPORT, 1,
56 [Define to 1 if the target supports __attribute__((dllexport)).])
57 fi])
58
59dnl Check whether the target supports symbol aliases.
60AC_DEFUN([LIBITM_CHECK_ATTRIBUTE_ALIAS], [
61 AC_CACHE_CHECK([whether the target supports symbol aliases],
62 libitm_cv_have_attribute_alias, [
63 AC_TRY_LINK([
64void foo(void) { }
65extern void bar(void) __attribute__((alias("foo")));],
66 [bar();], libitm_cv_have_attribute_alias=yes, libitm_cv_have_attribute_alias=no)])
67 if test $libitm_cv_have_attribute_alias = yes; then
68 AC_DEFINE(HAVE_ATTRIBUTE_ALIAS, 1,
69 [Define to 1 if the target supports __attribute__((alias(...))).])
70 fi])
71
72dnl Check how size_t is mangled.
73AC_DEFUN([LIBITM_CHECK_SIZE_T_MANGLING], [
74 AC_CACHE_CHECK([how size_t is mangled],
75 libitm_cv_size_t_mangling, [
76 AC_TRY_COMPILE([], [extern __SIZE_TYPE__ x; extern unsigned long x;],
77 [libitm_cv_size_t_mangling=m], [
78 AC_TRY_COMPILE([], [extern __SIZE_TYPE__ x; extern unsigned int x;],
79 [libitm_cv_size_t_mangling=j], [
80 AC_TRY_COMPILE([],
81 [extern __SIZE_TYPE__ x; extern unsigned long long x;],
82 [libitm_cv_size_t_mangling=y], [
83 AC_TRY_COMPILE([],
84 [extern __SIZE_TYPE__ x; extern unsigned short x;],
85 [libitm_cv_size_t_mangling=t],
86 [libitm_cv_size_t_mangling=x])
87 ])
88 ])
89 ])
90 ])
91 if test $libitm_cv_size_t_mangling = x; then
92 AC_MSG_ERROR([Unknown underlying type for size_t])
93 fi
94 AC_DEFINE_UNQUOTED(MANGLE_SIZE_T, [$libitm_cv_size_t_mangling],
95 [Define to the letter to which size_t is mangled.])
96])
97
36a0e17a 98dnl Check if as supports AVX instructions.
99AC_DEFUN([LIBITM_CHECK_AS_AVX], [
100case "${target_cpu}" in
785d9613 101i[[34567]]86 | x86_64)
36a0e17a 102 AC_CACHE_CHECK([if the assembler supports AVX], libitm_cv_as_avx, [
103 AC_TRY_COMPILE([], [asm("vzeroupper");],
104 [libitm_cv_as_avx=yes], [libitm_cv_as_avx=no])
105 ])
106 if test x$libitm_cv_as_avx = xyes; then
107 AC_DEFINE(HAVE_AS_AVX, 1, [Define to 1 if the assembler supports AVX.])
108 fi
109 ;;
110esac])
111
ca09a9c4 112dnl Check if as supports RTM instructions.
113AC_DEFUN([LIBITM_CHECK_AS_RTM], [
114case "${target_cpu}" in
115i[[34567]]86 | x86_64)
116 AC_CACHE_CHECK([if the assembler supports RTM], libitm_cv_as_rtm, [
117 AC_TRY_COMPILE([], [asm("1: xbegin 1b; xend");],
118 [libitm_cv_as_rtm=yes], [libitm_cv_as_rtm=no])
119 ])
120 if test x$libitm_cv_as_rtm = xyes; then
121 AC_DEFINE(HAVE_AS_RTM, 1, [Define to 1 if the assembler supports RTM.])
122 fi
123 ;;
124esac])
125
5088e479 126dnl Check if as supports HTM instructions.
127AC_DEFUN([LIBITM_CHECK_AS_HTM], [
128case "${target_cpu}" in
129powerpc*)
130 AC_CACHE_CHECK([if the assembler supports HTM], libitm_cv_as_htm, [
131 AC_TRY_COMPILE([], [asm("tbegin. 0; tend. 0");],
132 [libitm_cv_as_htm=yes], [libitm_cv_as_htm=no])
133 ])
134 if test x$libitm_cv_as_htm = xyes; then
135 AC_DEFINE(HAVE_AS_HTM, 1, [Define to 1 if the assembler supports HTM.])
136 fi
137 ;;
ee2dbc39 138s390*)
139 AC_CACHE_CHECK([if the assembler supports HTM], libitm_cv_as_htm, [
140 save_CFLAGS="$CFLAGS"
141 CFLAGS="$CFLAGS -march=zEC12"
142 AC_TRY_COMPILE([], [asm("tbegin 0,0; tend");],
143 [libitm_cv_as_htm=yes], [libitm_cv_as_htm=no])
144 CFLAGS="$save_CFLAGS"])
145 if test x$libitm_cv_as_htm = xyes; then
146 AC_DEFINE(HAVE_AS_HTM, 1, [Define to 1 if the assembler supports HTM.])
147 fi
148 ;;
5088e479 149esac])
150
4c0315d0 151sinclude(../libtool.m4)
152dnl The lines below arrange for aclocal not to bring an installed
153dnl libtool.m4 into aclocal.m4, while still arranging for automake to
154dnl add a definition of LIBTOOL to Makefile.in.
155ifelse(,,,[AC_SUBST(LIBTOOL)
156AC_DEFUN([AM_PROG_LIBTOOL])
157AC_DEFUN([AC_LIBTOOL_DLOPEN])
158AC_DEFUN([AC_PROG_LD])
159])
160
161dnl ----------------------------------------------------------------------
162dnl This whole bit snagged from libstdc++-v3.
163
164dnl
165dnl LIBITM_ENABLE
166dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING)
167dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, permit a|b|c)
168dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, SHELL-CODE-HANDLER)
169dnl
170dnl See docs/html/17_intro/configury.html#enable for documentation.
171dnl
172m4_define([LIBITM_ENABLE],[dnl
173m4_define([_g_switch],[--enable-$1])dnl
174m4_define([_g_help],[AC_HELP_STRING(_g_switch$3,[$4 @<:@default=$2@:>@])])dnl
175 AC_ARG_ENABLE($1,_g_help,
176 m4_bmatch([$5],
177 [^permit ],
178 [[
179 case "$enableval" in
180 m4_bpatsubst([$5],[permit ])) ;;
181 *) AC_MSG_ERROR(Unknown argument to enable/disable $1) ;;
182 dnl Idea for future: generate a URL pointing to
183 dnl "onlinedocs/configopts.html#whatever"
184 esac
185 ]],
186 [^$],
187 [[
188 case "$enableval" in
189 yes|no) ;;
190 *) AC_MSG_ERROR(Argument to enable/disable $1 must be yes or no) ;;
191 esac
192 ]],
193 [[$5]]),
194 [enable_]m4_bpatsubst([$1],-,_)[=][$2])
195m4_undefine([_g_switch])dnl
196m4_undefine([_g_help])dnl
197])
198
199
200dnl
201dnl If GNU ld is in use, check to see if tricky linker opts can be used. If
202dnl the native linker is in use, all variables will be defined to something
203dnl safe (like an empty string).
204dnl
205dnl Defines:
206dnl SECTION_LDFLAGS='-Wl,--gc-sections' if possible
207dnl OPT_LDFLAGS='-Wl,-O1' if possible
208dnl LD (as a side effect of testing)
209dnl Sets:
210dnl with_gnu_ld
2e44db0a 211dnl libitm_ld_is_gold (possibly)
4c0315d0 212dnl libitm_gnu_ld_version (possibly)
213dnl
214dnl The last will be a single integer, e.g., version 1.23.45.0.67.89 will
215dnl set libitm_gnu_ld_version to 12345. Zeros cause problems.
216dnl
217AC_DEFUN([LIBITM_CHECK_LINKER_FEATURES], [
218 # If we're not using GNU ld, then there's no point in even trying these
219 # tests. Check for that first. We should have already tested for gld
220 # by now (in libtool), but require it now just to be safe...
221 test -z "$SECTION_LDFLAGS" && SECTION_LDFLAGS=''
222 test -z "$OPT_LDFLAGS" && OPT_LDFLAGS=''
223 AC_REQUIRE([AC_PROG_LD])
224 AC_REQUIRE([AC_PROG_AWK])
225
226 # The name set by libtool depends on the version of libtool. Shame on us
227 # for depending on an impl detail, but c'est la vie. Older versions used
228 # ac_cv_prog_gnu_ld, but now it's lt_cv_prog_gnu_ld, and is copied back on
229 # top of with_gnu_ld (which is also set by --with-gnu-ld, so that actually
230 # makes sense). We'll test with_gnu_ld everywhere else, so if that isn't
231 # set (hence we're using an older libtool), then set it.
232 if test x${with_gnu_ld+set} != xset; then
233 if test x${ac_cv_prog_gnu_ld+set} != xset; then
234 # We got through "ac_require(ac_prog_ld)" and still not set? Huh?
235 with_gnu_ld=no
236 else
237 with_gnu_ld=$ac_cv_prog_gnu_ld
238 fi
239 fi
240
241 # Start by getting the version number. I think the libtool test already
242 # does some of this, but throws away the result.
2e44db0a 243 libitm_ld_is_gold=no
244 if $LD --version 2>/dev/null | grep 'GNU gold'> /dev/null 2>&1; then
245 libitm_ld_is_gold=yes
246 fi
4c0315d0 247 changequote(,)
2e44db0a 248 ldver=`$LD --version 2>/dev/null |
249 sed -e 's/GNU gold /GNU ld /;s/GNU ld version /GNU ld /;s/GNU ld ([^)]*) /GNU ld /;s/GNU ld \([0-9.][0-9.]*\).*/\1/; q'`
4c0315d0 250 changequote([,])
251 libitm_gnu_ld_version=`echo $ldver | \
252 $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
253
254 # Set --gc-sections.
255 if test "$with_gnu_ld" = "notbroken"; then
256 # GNU ld it is! Joy and bunny rabbits!
257
258 # All these tests are for C++; save the language and the compiler flags.
259 # Need to do this so that g++ won't try to link in libstdc++
260 ac_test_CFLAGS="${CFLAGS+set}"
261 ac_save_CFLAGS="$CFLAGS"
262 CFLAGS='-x c++ -Wl,--gc-sections'
263
264 # Check for -Wl,--gc-sections
265 # XXX This test is broken at the moment, as symbols required for linking
266 # are now in libsupc++ (not built yet). In addition, this test has
267 # cored on solaris in the past. In addition, --gc-sections doesn't
268 # really work at the moment (keeps on discarding used sections, first
269 # .eh_frame and now some of the glibc sections for iconv).
270 # Bzzzzt. Thanks for playing, maybe next time.
271 AC_MSG_CHECKING([for ld that supports -Wl,--gc-sections])
272 AC_TRY_RUN([
273 int main(void)
274 {
275 try { throw 1; }
276 catch (...) { };
277 return 0;
278 }
279 ], [ac_sectionLDflags=yes],[ac_sectionLDflags=no], [ac_sectionLDflags=yes])
280 if test "$ac_test_CFLAGS" = set; then
281 CFLAGS="$ac_save_CFLAGS"
282 else
283 # this is the suspicious part
284 CFLAGS=''
285 fi
286 if test "$ac_sectionLDflags" = "yes"; then
287 SECTION_LDFLAGS="-Wl,--gc-sections $SECTION_LDFLAGS"
288 fi
289 AC_MSG_RESULT($ac_sectionLDflags)
290 fi
291
292 # Set linker optimization flags.
293 if test x"$with_gnu_ld" = x"yes"; then
294 OPT_LDFLAGS="-Wl,-O1 $OPT_LDFLAGS"
295 fi
296
297 AC_SUBST(SECTION_LDFLAGS)
298 AC_SUBST(OPT_LDFLAGS)
299])
300
301
dffe2d19 302dnl
303dnl Check if the linker used supports linker maps to clear hardware
304dnl capabilities. This is only supported by Sun ld at the moment.
305dnl
306dnl Defines:
307dnl HWCAP_LDFLAGS='-Wl,-M,clearcap.map' if possible
308dnl LD (as a side effect of testing)
309dnl
310AC_DEFUN([LIBITM_CHECK_LINKER_HWCAP], [
311 test -z "$HWCAP_LDFLAGS" && HWCAP_LDFLAGS=''
312 AC_REQUIRE([AC_PROG_LD])
313
314 ac_save_LDFLAGS="$LDFLAGS"
315 LDFLAGS="$LFLAGS -Wl,-M,$srcdir/clearcap.map"
316
317 AC_MSG_CHECKING([for ld that supports -Wl,-M,mapfile])
318 AC_TRY_LINK([], [return 0;], [ac_hwcap_ldflags=yes],[ac_hwcap_ldflags=no])
319 if test "$ac_hwcap_ldflags" = "yes"; then
320 HWCAP_LDFLAGS="-Wl,-M,$srcdir/clearcap.map $HWCAP_LDFLAGS"
321 fi
322 AC_MSG_RESULT($ac_hwcap_ldflags)
323
324 LDFLAGS="$ac_save_LDFLAGS"
325
326 AC_SUBST(HWCAP_LDFLAGS)
327
328 AM_CONDITIONAL(HAVE_HWCAP, test $ac_hwcap_ldflags != no)
329])
330
331
4c0315d0 332dnl
333dnl Add version tags to symbols in shared library (or not), additionally
334dnl marking other symbols as private/local (or not).
335dnl
336dnl --enable-symvers=style adds a version script to the linker call when
337dnl creating the shared library. The choice of version script is
338dnl controlled by 'style'.
339dnl --disable-symvers does not.
340dnl + Usage: LIBITM_ENABLE_SYMVERS[(DEFAULT)]
341dnl Where DEFAULT is either 'yes' or 'no'. Passing `yes' tries to
342dnl choose a default style based on linker characteristics. Passing
343dnl 'no' disables versioning.
344dnl
345AC_DEFUN([LIBITM_ENABLE_SYMVERS], [
346
347LIBITM_ENABLE(symvers,yes,[=STYLE],
348 [enables symbol versioning of the shared library],
2e44db0a 349 [permit yes|no|gnu*|sun])
4c0315d0 350
351# If we never went through the LIBITM_CHECK_LINKER_FEATURES macro, then we
352# don't know enough about $LD to do tricks...
353AC_REQUIRE([LIBITM_CHECK_LINKER_FEATURES])
2e44db0a 354
355# Turn a 'yes' into a suitable default.
356if test x$enable_symvers = xyes ; then
357 # FIXME The following test is too strict, in theory.
358 if test $enable_shared = no || test "x$LD" = x; then
359 enable_symvers=no
360 else
361 if test $with_gnu_ld = yes ; then
362 enable_symvers=gnu
363 else
364 case ${target_os} in
365 # Sun symbol versioning exists since Solaris 2.5.
366 solaris2.[[5-9]]* | solaris2.1[[0-9]]*)
367 enable_symvers=sun ;;
368 *)
369 enable_symvers=no ;;
370 esac
371 fi
372 fi
373fi
374
375# Check if 'sun' was requested on non-Solaris 2 platforms.
376if test x$enable_symvers = xsun ; then
377 case ${target_os} in
378 solaris2*)
379 # All fine.
380 ;;
381 *)
382 # Unlikely to work.
383 AC_MSG_WARN([=== You have requested Sun symbol versioning, but])
384 AC_MSG_WARN([=== you are not targetting Solaris 2.])
385 AC_MSG_WARN([=== Symbol versioning will be disabled.])
386 enable_symvers=no
387 ;;
388 esac
4c0315d0 389fi
390
391# Check to see if libgcc_s exists, indicating that shared libgcc is possible.
392if test $enable_symvers != no; then
393 AC_MSG_CHECKING([for shared libgcc])
394 ac_save_CFLAGS="$CFLAGS"
395 CFLAGS=' -lgcc_s'
396 AC_TRY_LINK(, [return 0;], libitm_shared_libgcc=yes, libitm_shared_libgcc=no)
397 CFLAGS="$ac_save_CFLAGS"
398 if test $libitm_shared_libgcc = no; then
399 cat > conftest.c <<EOF
400int main (void) { return 0; }
401EOF
402changequote(,)dnl
403 libitm_libgcc_s_suffix=`${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
404 -shared -shared-libgcc -o conftest.so \
405 conftest.c -v 2>&1 >/dev/null \
406 | sed -n 's/^.* -lgcc_s\([^ ]*\) .*$/\1/p'`
407changequote([,])dnl
408 rm -f conftest.c conftest.so
409 if test x${libitm_libgcc_s_suffix+set} = xset; then
410 CFLAGS=" -lgcc_s$libitm_libgcc_s_suffix"
411 AC_TRY_LINK(, [return 0;], libitm_shared_libgcc=yes)
412 CFLAGS="$ac_save_CFLAGS"
413 fi
414 fi
415 AC_MSG_RESULT($libitm_shared_libgcc)
416fi
417
418# For GNU ld, we need at least this version. The format is described in
419# LIBITM_CHECK_LINKER_FEATURES above.
420libitm_min_gnu_ld_version=21400
421# XXXXXXXXXXX libitm_gnu_ld_version=21390
422
423# Check to see if unspecified "yes" value can win, given results above.
424# Change "yes" into either "no" or a style name.
2e44db0a 425if test $enable_symvers != no && test $libitm_shared_libgcc = yes; then
426 if test $with_gnu_ld = yes; then
4c0315d0 427 if test $libitm_gnu_ld_version -ge $libitm_min_gnu_ld_version ; then
428 enable_symvers=gnu
2e44db0a 429 elif test $libitm_ld_is_gold = yes ; then
430 enable_symvers=gnu
4c0315d0 431 else
432 # The right tools, the right setup, but too old. Fallbacks?
433 AC_MSG_WARN(=== Linker version $libitm_gnu_ld_version is too old for)
434 AC_MSG_WARN(=== full symbol versioning support in this release of GCC.)
435 AC_MSG_WARN(=== You would need to upgrade your binutils to version)
436 AC_MSG_WARN(=== $libitm_min_gnu_ld_version or later and rebuild GCC.)
437 if test $libitm_gnu_ld_version -ge 21200 ; then
438 # Globbing fix is present, proper block support is not.
439 dnl AC_MSG_WARN([=== Dude, you are soooo close. Maybe we can fake it.])
440 dnl enable_symvers=???
441 AC_MSG_WARN([=== Symbol versioning will be disabled.])
442 enable_symvers=no
443 else
444 # 2.11 or older.
445 AC_MSG_WARN([=== Symbol versioning will be disabled.])
446 enable_symvers=no
447 fi
448 fi
2e44db0a 449 elif test $enable_symvers = sun; then
450 : All interesting versions of Sun ld support sun style symbol versioning.
4c0315d0 451 else
452 # just fail for now
453 AC_MSG_WARN([=== You have requested some kind of symbol versioning, but])
454 AC_MSG_WARN([=== either you are not using a supported linker, or you are])
455 AC_MSG_WARN([=== not building a shared libgcc_s (which is required).])
456 AC_MSG_WARN([=== Symbol versioning will be disabled.])
457 enable_symvers=no
458 fi
459fi
460
461AM_CONDITIONAL(LIBITM_BUILD_VERSIONED_SHLIB, test $enable_symvers != no)
2e44db0a 462AM_CONDITIONAL(LIBITM_BUILD_VERSIONED_SHLIB_GNU, test $enable_symvers = gnu)
463AM_CONDITIONAL(LIBITM_BUILD_VERSIONED_SHLIB_SUN, test $enable_symvers = sun)
4c0315d0 464AC_MSG_NOTICE(versioning on shared library symbols is $enable_symvers)
465])