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