1169695Skandnl ---------------------------------------------------------------------- 2169695Skandnl This whole bit snagged from libgfortran. 3169695Skan 4169695Skandnl Check whether the target supports __sync_*_compare_and_swap. 5169695SkanAC_DEFUN([LIBGOMP_CHECK_SYNC_BUILTINS], [ 6169695Skan AC_CACHE_CHECK([whether the target supports __sync_*_compare_and_swap], 7169695Skan have_sync_builtins, [ 8169695Skan AC_TRY_LINK([], [int foo, bar; bar = __sync_val_compare_and_swap(&foo, 0, 1);], 9169695Skan have_sync_builtins=yes, have_sync_builtins=no)]) 10169695Skan if test $have_sync_builtins = yes; then 11169695Skan AC_DEFINE(HAVE_SYNC_BUILTINS, 1, 12169695Skan [Define to 1 if the target supports __sync_*_compare_and_swap]) 13169695Skan fi]) 14169695Skan 15169695Skandnl Check whether the target supports hidden visibility. 16169695SkanAC_DEFUN([LIBGOMP_CHECK_ATTRIBUTE_VISIBILITY], [ 17169695Skan AC_CACHE_CHECK([whether the target supports hidden visibility], 18169695Skan have_attribute_visibility, [ 19169695Skan save_CFLAGS="$CFLAGS" 20169695Skan CFLAGS="$CFLAGS -Werror" 21169695Skan AC_TRY_COMPILE([void __attribute__((visibility("hidden"))) foo(void) { }], 22169695Skan [], have_attribute_visibility=yes, 23169695Skan have_attribute_visibility=no) 24169695Skan CFLAGS="$save_CFLAGS"]) 25169695Skan if test $have_attribute_visibility = yes; then 26169695Skan AC_DEFINE(HAVE_ATTRIBUTE_VISIBILITY, 1, 27169695Skan [Define to 1 if the target supports __attribute__((visibility(...))).]) 28169695Skan fi]) 29169695Skan 30169695Skandnl Check whether the target supports dllexport 31169695SkanAC_DEFUN([LIBGOMP_CHECK_ATTRIBUTE_DLLEXPORT], [ 32169695Skan AC_CACHE_CHECK([whether the target supports dllexport], 33169695Skan have_attribute_dllexport, [ 34169695Skan save_CFLAGS="$CFLAGS" 35169695Skan CFLAGS="$CFLAGS -Werror" 36169695Skan AC_TRY_COMPILE([void __attribute__((dllexport)) foo(void) { }], 37169695Skan [], have_attribute_dllexport=yes, 38169695Skan have_attribute_dllexport=no) 39169695Skan CFLAGS="$save_CFLAGS"]) 40169695Skan if test $have_attribute_dllexport = yes; then 41169695Skan AC_DEFINE(HAVE_ATTRIBUTE_DLLEXPORT, 1, 42169695Skan [Define to 1 if the target supports __attribute__((dllexport)).]) 43169695Skan fi]) 44169695Skan 45169695Skandnl Check whether the target supports symbol aliases. 46169695SkanAC_DEFUN([LIBGOMP_CHECK_ATTRIBUTE_ALIAS], [ 47169695Skan AC_CACHE_CHECK([whether the target supports symbol aliases], 48169695Skan have_attribute_alias, [ 49169695Skan AC_TRY_LINK([ 50169695Skanvoid foo(void) { } 51169695Skanextern void bar(void) __attribute__((alias("foo")));], 52169695Skan [bar();], have_attribute_alias=yes, have_attribute_alias=no)]) 53169695Skan if test $have_attribute_alias = yes; then 54169695Skan AC_DEFINE(HAVE_ATTRIBUTE_ALIAS, 1, 55169695Skan [Define to 1 if the target supports __attribute__((alias(...))).]) 56169695Skan fi]) 57169695Skan 58169695Skansinclude(../libtool.m4) 59169695Skandnl The lines below arrange for aclocal not to bring an installed 60169695Skandnl libtool.m4 into aclocal.m4, while still arranging for automake to 61169695Skandnl add a definition of LIBTOOL to Makefile.in. 62169695Skanifelse(,,,[AC_SUBST(LIBTOOL) 63169695SkanAC_DEFUN([AM_PROG_LIBTOOL]) 64169695SkanAC_DEFUN([AC_LIBTOOL_DLOPEN]) 65169695SkanAC_DEFUN([AC_PROG_LD]) 66169695Skan]) 67169695Skan 68169695Skandnl ---------------------------------------------------------------------- 69169695Skandnl This whole bit snagged from libstdc++-v3. 70169695Skan 71169695Skandnl 72169695Skandnl LIBGOMP_ENABLE 73169695Skandnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING) 74169695Skandnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, permit a|b|c) 75169695Skandnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, SHELL-CODE-HANDLER) 76169695Skandnl 77169695Skandnl See docs/html/17_intro/configury.html#enable for documentation. 78169695Skandnl 79169695Skanm4_define([LIBGOMP_ENABLE],[dnl 80169695Skanm4_define([_g_switch],[--enable-$1])dnl 81169695Skanm4_define([_g_help],[AC_HELP_STRING(_g_switch$3,[$4 @<:@default=$2@:>@])])dnl 82169695Skan AC_ARG_ENABLE($1,_g_help, 83169695Skan m4_bmatch([$5], 84169695Skan [^permit ], 85169695Skan [[ 86169695Skan case "$enableval" in 87169695Skan m4_bpatsubst([$5],[permit ])) ;; 88169695Skan *) AC_MSG_ERROR(Unknown argument to enable/disable $1) ;; 89169695Skan dnl Idea for future: generate a URL pointing to 90169695Skan dnl "onlinedocs/configopts.html#whatever" 91169695Skan esac 92169695Skan ]], 93169695Skan [^$], 94169695Skan [[ 95169695Skan case "$enableval" in 96169695Skan yes|no) ;; 97169695Skan *) AC_MSG_ERROR(Argument to enable/disable $1 must be yes or no) ;; 98169695Skan esac 99169695Skan ]], 100169695Skan [[$5]]), 101169695Skan [enable_]m4_bpatsubst([$1],-,_)[=][$2]) 102169695Skanm4_undefine([_g_switch])dnl 103169695Skanm4_undefine([_g_help])dnl 104169695Skan]) 105169695Skan 106169695Skan 107169695Skandnl 108169695Skandnl If GNU ld is in use, check to see if tricky linker opts can be used. If 109169695Skandnl the native linker is in use, all variables will be defined to something 110169695Skandnl safe (like an empty string). 111169695Skandnl 112169695Skandnl Defines: 113169695Skandnl SECTION_LDFLAGS='-Wl,--gc-sections' if possible 114169695Skandnl OPT_LDFLAGS='-Wl,-O1' if possible 115169695Skandnl LD (as a side effect of testing) 116169695Skandnl Sets: 117169695Skandnl with_gnu_ld 118169695Skandnl libgomp_gnu_ld_version (possibly) 119169695Skandnl 120169695Skandnl The last will be a single integer, e.g., version 1.23.45.0.67.89 will 121169695Skandnl set libgomp_gnu_ld_version to 12345. Zeros cause problems. 122169695Skandnl 123169695SkanAC_DEFUN([LIBGOMP_CHECK_LINKER_FEATURES], [ 124169695Skan # If we're not using GNU ld, then there's no point in even trying these 125169695Skan # tests. Check for that first. We should have already tested for gld 126169695Skan # by now (in libtool), but require it now just to be safe... 127169695Skan test -z "$SECTION_LDFLAGS" && SECTION_LDFLAGS='' 128169695Skan test -z "$OPT_LDFLAGS" && OPT_LDFLAGS='' 129169695Skan AC_REQUIRE([AC_PROG_LD]) 130169695Skan AC_REQUIRE([AC_PROG_AWK]) 131169695Skan 132169695Skan # The name set by libtool depends on the version of libtool. Shame on us 133169695Skan # for depending on an impl detail, but c'est la vie. Older versions used 134169695Skan # ac_cv_prog_gnu_ld, but now it's lt_cv_prog_gnu_ld, and is copied back on 135169695Skan # top of with_gnu_ld (which is also set by --with-gnu-ld, so that actually 136169695Skan # makes sense). We'll test with_gnu_ld everywhere else, so if that isn't 137169695Skan # set (hence we're using an older libtool), then set it. 138169695Skan if test x${with_gnu_ld+set} != xset; then 139169695Skan if test x${ac_cv_prog_gnu_ld+set} != xset; then 140169695Skan # We got through "ac_require(ac_prog_ld)" and still not set? Huh? 141169695Skan with_gnu_ld=no 142169695Skan else 143169695Skan with_gnu_ld=$ac_cv_prog_gnu_ld 144169695Skan fi 145169695Skan fi 146169695Skan 147169695Skan # Start by getting the version number. I think the libtool test already 148169695Skan # does some of this, but throws away the result. 149169695Skan changequote(,) 150169695Skan ldver=`$LD --version 2>/dev/null | head -1 | \ 151169695Skan sed -e 's/GNU ld \(version \)\{0,1\}\(([^)]*) \)\{0,1\}\([0-9.][0-9.]*\).*/\3/'` 152169695Skan changequote([,]) 153169695Skan libgomp_gnu_ld_version=`echo $ldver | \ 154169695Skan $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'` 155169695Skan 156169695Skan # Set --gc-sections. 157169695Skan if test "$with_gnu_ld" = "notbroken"; then 158169695Skan # GNU ld it is! Joy and bunny rabbits! 159169695Skan 160169695Skan # All these tests are for C++; save the language and the compiler flags. 161169695Skan # Need to do this so that g++ won't try to link in libstdc++ 162169695Skan ac_test_CFLAGS="${CFLAGS+set}" 163169695Skan ac_save_CFLAGS="$CFLAGS" 164169695Skan CFLAGS='-x c++ -Wl,--gc-sections' 165169695Skan 166169695Skan # Check for -Wl,--gc-sections 167169695Skan # XXX This test is broken at the moment, as symbols required for linking 168169695Skan # are now in libsupc++ (not built yet). In addition, this test has 169169695Skan # cored on solaris in the past. In addition, --gc-sections doesn't 170169695Skan # really work at the moment (keeps on discarding used sections, first 171169695Skan # .eh_frame and now some of the glibc sections for iconv). 172169695Skan # Bzzzzt. Thanks for playing, maybe next time. 173169695Skan AC_MSG_CHECKING([for ld that supports -Wl,--gc-sections]) 174169695Skan AC_TRY_RUN([ 175169695Skan int main(void) 176169695Skan { 177169695Skan try { throw 1; } 178169695Skan catch (...) { }; 179169695Skan return 0; 180169695Skan } 181169695Skan ], [ac_sectionLDflags=yes],[ac_sectionLDflags=no], [ac_sectionLDflags=yes]) 182169695Skan if test "$ac_test_CFLAGS" = set; then 183169695Skan CFLAGS="$ac_save_CFLAGS" 184169695Skan else 185169695Skan # this is the suspicious part 186169695Skan CFLAGS='' 187169695Skan fi 188169695Skan if test "$ac_sectionLDflags" = "yes"; then 189169695Skan SECTION_LDFLAGS="-Wl,--gc-sections $SECTION_LDFLAGS" 190169695Skan fi 191169695Skan AC_MSG_RESULT($ac_sectionLDflags) 192169695Skan fi 193169695Skan 194169695Skan # Set linker optimization flags. 195169695Skan if test x"$with_gnu_ld" = x"yes"; then 196169695Skan OPT_LDFLAGS="-Wl,-O1 $OPT_LDFLAGS" 197169695Skan fi 198169695Skan 199169695Skan AC_SUBST(SECTION_LDFLAGS) 200169695Skan AC_SUBST(OPT_LDFLAGS) 201169695Skan]) 202169695Skan 203169695Skan 204169695Skandnl 205169695Skandnl Add version tags to symbols in shared library (or not), additionally 206169695Skandnl marking other symbols as private/local (or not). 207169695Skandnl 208169695Skandnl --enable-symvers=style adds a version script to the linker call when 209169695Skandnl creating the shared library. The choice of version script is 210169695Skandnl controlled by 'style'. 211169695Skandnl --disable-symvers does not. 212169695Skandnl + Usage: LIBGOMP_ENABLE_SYMVERS[(DEFAULT)] 213169695Skandnl Where DEFAULT is either 'yes' or 'no'. Passing `yes' tries to 214169695Skandnl choose a default style based on linker characteristics. Passing 215169695Skandnl 'no' disables versioning. 216169695Skandnl 217169695SkanAC_DEFUN([LIBGOMP_ENABLE_SYMVERS], [ 218169695Skan 219169695SkanLIBGOMP_ENABLE(symvers,yes,[=STYLE], 220169695Skan [enables symbol versioning of the shared library], 221169695Skan [permit yes|no|gnu]) 222169695Skan 223169695Skan# If we never went through the LIBGOMP_CHECK_LINKER_FEATURES macro, then we 224169695Skan# don't know enough about $LD to do tricks... 225169695SkanAC_REQUIRE([LIBGOMP_CHECK_LINKER_FEATURES]) 226169695Skan# FIXME The following test is too strict, in theory. 227169695Skanif test $enable_shared = no || 228169695Skan test "x$LD" = x || 229169695Skan test x$libgomp_gnu_ld_version = x; then 230169695Skan enable_symvers=no 231169695Skanfi 232169695Skan 233169695Skan# Check to see if libgcc_s exists, indicating that shared libgcc is possible. 234169695Skanif test $enable_symvers != no; then 235169695Skan AC_MSG_CHECKING([for shared libgcc]) 236169695Skan ac_save_CFLAGS="$CFLAGS" 237169695Skan CFLAGS=' -lgcc_s' 238169695Skan AC_TRY_LINK(, [return 0;], libgomp_shared_libgcc=yes, libgomp_shared_libgcc=no) 239169695Skan CFLAGS="$ac_save_CFLAGS" 240169695Skan if test $libgomp_shared_libgcc = no; then 241169695Skan cat > conftest.c <<EOF 242169695Skanint main (void) { return 0; } 243169695SkanEOF 244169695Skanchangequote(,)dnl 245169695Skan libgomp_libgcc_s_suffix=`${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \ 246169695Skan -shared -shared-libgcc -o conftest.so \ 247169695Skan conftest.c -v 2>&1 >/dev/null \ 248169695Skan | sed -n 's/^.* -lgcc_s\([^ ]*\) .*$/\1/p'` 249169695Skanchangequote([,])dnl 250169695Skan rm -f conftest.c conftest.so 251169695Skan if test x${libgomp_libgcc_s_suffix+set} = xset; then 252169695Skan CFLAGS=" -lgcc_s$libgomp_libgcc_s_suffix" 253169695Skan AC_TRY_LINK(, [return 0;], libgomp_shared_libgcc=yes) 254169695Skan CFLAGS="$ac_save_CFLAGS" 255169695Skan fi 256169695Skan fi 257169695Skan AC_MSG_RESULT($libgomp_shared_libgcc) 258169695Skanfi 259169695Skan 260169695Skan# For GNU ld, we need at least this version. The format is described in 261169695Skan# LIBGOMP_CHECK_LINKER_FEATURES above. 262169695Skanlibgomp_min_gnu_ld_version=21400 263169695Skan# XXXXXXXXXXX libgomp_gnu_ld_version=21390 264169695Skan 265169695Skan# Check to see if unspecified "yes" value can win, given results above. 266169695Skan# Change "yes" into either "no" or a style name. 267169695Skanif test $enable_symvers = yes; then 268169695Skan if test $with_gnu_ld = yes && 269169695Skan test $libgomp_shared_libgcc = yes; 270169695Skan then 271169695Skan if test $libgomp_gnu_ld_version -ge $libgomp_min_gnu_ld_version ; then 272169695Skan enable_symvers=gnu 273169695Skan else 274169695Skan # The right tools, the right setup, but too old. Fallbacks? 275169695Skan AC_MSG_WARN(=== Linker version $libgomp_gnu_ld_version is too old for) 276169695Skan AC_MSG_WARN(=== full symbol versioning support in this release of GCC.) 277169695Skan AC_MSG_WARN(=== You would need to upgrade your binutils to version) 278169695Skan AC_MSG_WARN(=== $libgomp_min_gnu_ld_version or later and rebuild GCC.) 279169695Skan if test $libgomp_gnu_ld_version -ge 21200 ; then 280169695Skan # Globbing fix is present, proper block support is not. 281169695Skan dnl AC_MSG_WARN([=== Dude, you are soooo close. Maybe we can fake it.]) 282169695Skan dnl enable_symvers=??? 283169695Skan AC_MSG_WARN([=== Symbol versioning will be disabled.]) 284169695Skan enable_symvers=no 285169695Skan else 286169695Skan # 2.11 or older. 287169695Skan AC_MSG_WARN([=== Symbol versioning will be disabled.]) 288169695Skan enable_symvers=no 289169695Skan fi 290169695Skan fi 291169695Skan else 292169695Skan # just fail for now 293169695Skan AC_MSG_WARN([=== You have requested some kind of symbol versioning, but]) 294169695Skan AC_MSG_WARN([=== either you are not using a supported linker, or you are]) 295169695Skan AC_MSG_WARN([=== not building a shared libgcc_s (which is required).]) 296169695Skan AC_MSG_WARN([=== Symbol versioning will be disabled.]) 297169695Skan enable_symvers=no 298169695Skan fi 299169695Skanfi 300169695Skan 301169695SkanAM_CONDITIONAL(LIBGOMP_BUILD_VERSIONED_SHLIB, test $enable_symvers != no) 302169695SkanAC_MSG_NOTICE(versioning on shared library symbols is $enable_symvers) 303169695Skan]) 304