Patchwork [Build,Quad,Fortran] PR 46520: Build only with languages=fortran; fix build with cross compiler

login
register
mail settings
Submitter Tobias Burnus
Date Nov. 17, 2010, 9:42 p.m.
Message ID <4CE44C58.9070608@net-b.de>
Download mbox | patch
Permalink /patch/71622/
State New
Headers show

Comments

Tobias Burnus - Nov. 17, 2010, 9:42 p.m.
Dear all,

this patch fixes two issues:

a) libquadmath was supposed to be only build when --enable-languages= 
encompassed "fortran". The chunk in gcc/fortran/ does this.

b) I failed to write - or rather copy-and-paste together - configure.ac 
such that it will work with a cross compiler.

For the symbol versioning I switched over from the libgfortran macros to 
the ones of libgomp (which seem to be copied from libstdc++). Those look 
as if they also work with a cross compiler; I also removes some not 
needed macros from acinclude.m4.

For the __float128 check, I now use _cv_ and GCC_TRY_COMPILE_OR_LINK. If 
I understood the macro correctly, it only does a compile check if one 
does cross compiling. The result is approximately correct: If there is 
no __float128 the result is "no". However, there can be false positives 
if __float128 is supported but libgcc does not provide the needed 
functionality. Even after looking at gcc/config.build and 
libgcc/config.host, I have no idea how many targets are affected by 
having __float128 but no libgcc for it.

The patch has been bootstrapped once with --enable-languages=c only (in 
which case libquadmath is not build) and once with 
--enable-languages=c,c++,fortran.

OK for the trunk?

Tobias

PS: The patch contain's Rainer's -lm change.
Jakub Jelinek - Nov. 17, 2010, 9:45 p.m.
On Wed, Nov 17, 2010 at 10:42:48PM +0100, Tobias Burnus wrote:
> Dear all,
> 
> this patch fixes two issues:
> 
> a) libquadmath was supposed to be only build when
> --enable-languages= encompassed "fortran". The chunk in gcc/fortran/
> does this.

Why?  libquadmath ought to be usable not just from Fortran, so it should be
built always when the target supports __float128.

	Jakub
Tobias Burnus - Nov. 17, 2010, 9:59 p.m.
Jakub Jelinek wrote:
> Why?  libquadmath ought to be usable not just from Fortran, so it should be
> built always when the target supports __float128.

I think that's at least the opinion of Joseph; I am not 100% sure about 
Ian, though. If there is consensus, one can also drop the change to 
gcc/fortran/* and keep building it on all _float128-supporting systems.

 From #gcc:

<jsm28> libquadmath should build only for Fortran and only for the 
relevant architectures.
[16 hours earlier, recorded for me by "gccbot %seen"]

[Ian mentioned a failure with non-native builds; discussion moved to why 
(technical reason) it is always build:]
16:39 < iant> the question is when you put target-libquadmath in 
target_libraries in configure.ac
16:41 < iant> or maybe it is target_libs in gcc/fortran/config-lang.in
16:41 < xchat> shouldn't quad precision mathematics (binary128) be 
supported in C/C++ as well (as a GCC extension)?
16:42 < jsm28> Supporting for any other target would require a properly 
defined ABI for it first.
16:43 < jsm28> Supporting the "_Complex __float128" syntax is bug 32187, 
best fixed by making __float128 a keyword much like __int128.

Tobias

Patch

gcc/fortran/
2010-11-17  Tobias Burnus  <burnus@net-b.de>

	PR fortran/46520
	* config-lang.in (target_libs): Add target-libquadmath.

libquad/
2010-11-17  Tobias Burnus  <burnus@net-b.de>
	    Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	PR fortran/46520
	* acinclude.m4 (LIBGOMP_CHECK_SYNC_BUILTINS,
	LIBGOMP_CHECK_ATTRIBUTE_VISIBILITY,
	LIBGOMP_CHECK_ATTRIBUTE_DLLEXPORT): Remove.
	(LIBQUAD_ENABLE, LIBQUAD_CHECK_LINKER_FEATURES,
	LIBQUAD_ENABLE_SYMVERS): Add.
	* configure.ac: Use GCC_NO_EXECUTABLES, change
	symver handling.
	* Makefile.am: Change symver handling.
	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* config.h.in: Regenerate.
	* configure: Regenerate.

Index: gcc/fortran/config-lang.in
===================================================================
--- gcc/fortran/config-lang.in	(Revision 166875)
+++ gcc/fortran/config-lang.in	(Arbeitskopie)
@@ -27,7 +27,7 @@  language="fortran"
 
 compilers="f951\$(exeext)"
 
-target_libs=target-libgfortran
+target_libs="target-libquadmath target-libgfortran"
 
 gtfiles="\$(srcdir)/fortran/f95-lang.c \$(srcdir)/fortran/trans-decl.c \$(srcdir)/fortran/trans-intrinsic.c \$(srcdir)/fortran/trans-io.c \$(srcdir)/fortran/trans-stmt.c \$(srcdir)/fortran/trans-types.c \$(srcdir)/fortran/trans-types.h \$(srcdir)/fortran/trans.h \$(srcdir)/fortran/trans-const.h"
 
Index: libquadmath/Makefile.am
===================================================================
--- libquadmath/Makefile.am	(Revision 166875)
+++ libquadmath/Makefile.am	(Arbeitskopie)
@@ -10,39 +10,45 @@  ACLOCAL_AMFLAGS = -I .. -I ../config
 ## May be used by toolexeclibdir.
 gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
 
-## Symbol versioning (copied from libssp).
-if LIBQUAD_USE_SYMVER
-if LIBQUAD_USE_SYMVER_GNU
-version_arg = -Wl,--version-script=$(srcdir)/quadmath.map
-version_dep = $(srcdir)/quadmath.map
+## Symbol versioning (copied from libgomp).
+if LIBQUAD_BUILD_VERSIONED_SHLIB
+if LIBQUAD_BUILD_VERSIONED_SHLIB_GNU
+if LIBQUAD_BUILD_VERSIONED_SHLIB_SOL2
+libquadmath_version_script = -Wl,--version-script,quadmath.map-sol2
+libquadmath_version_dep = quadmath.map-sol2
+quadmath.map-sol2 : $(top_srcdir)/quadmath.map
+	sed -e '/^#ifdef HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT/,/^#endif/d' $< \
+	  > $@ || (rm -f $@ ; exit 1)
+else
+libquadmath_version_script = -Wl,--version-script,$(top_srcdir)/quadmath.map
+libquadmath_version_dep = $(top_srcdir)/quadmath.map
+endif
 endif
-if LIBQUAD_USE_SYMVER_SUN
-version_arg = -Wl,-M,quadmath.map-sun
-version_dep = quadmath.map-sun
-quadmath.map-sun : $(srcdir)/quadmath.map \
-                $(top_srcdir)/../contrib/make_sunver.pl \
-                $(libquadmath_la_OBJECTS) $(libquadmath_la_LIBADD)
-        perl $(top_srcdir)/../contrib/make_sunver.pl \
-          $(srcdir)/quadmath.map \
-          $(libquadmath_la_OBJECTS:%.lo=.libs/%.o) \
-         `echo $(libquadmath_la_LIBADD) | \
-            sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
-         > $@ || (rm -f $@ ; exit 1)
+if LIBQUAD_BUILD_VERSIONED_SHLIB_SUN
+libquadmath_version_script = -Wl,-M,quadmath.map-sun
+libquadmath_version_dep = quadmath.map-sun
+quadmath.map-sun : $(top_srcdir)/quadmath.map \
+		$(top_srcdir)/../contrib/make_sunver.pl \
+		$(libquadmath_la_OBJECTS) $(libquadmath_la_LIBADD)
+	perl $(top_srcdir)/../contrib/make_sunver.pl \
+	  $(top_srcdir)/quadmath.map \
+	  $(libquadmath_la_OBJECTS:%.lo=.libs/%.o) \
+	 `echo $(libquadmath_la_LIBADD) | \
+	   sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
+	   > $@ || (rm -f $@ ; exit 1)
 endif
 else
-version_arg =
-version_dep =
+libquadmath_version_script =
+libquadmath_version_dep =
 endif
 
-LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS)) \
-            -no-undefined
-
-
 toolexeclib_LTLIBRARIES = libquadmath.la
-libquadmath_la_LIBADD = -lm
-libquadmath_la_LDFLAGS = $(LTLDFLAGS) -version-info `grep -v '^\#' $(srcdir)/libtool-version` $(version_arg)
-libquadmath_la_LINK = $(LINK) $(libgfortran_la_LDFLAGS)
-libquadmath_la_DEPENDENCIES = $(version_dep)
+
+libquadmath_version_info = -version-info `grep -v '^\#' $(srcdir)/libtool-version`
+libquadmath_la_LDFLAGS = $(libquadmath_version_info) $(libquadmath_version_script) \
+	-no-undefined -bindir "$(bindir)" -lm
+libquadmath_la_LINK = $(LINK) $(libquadmath_la_LDFLAGS)
+libquadmath_la_DEPENDENCIES = $(libquadmath_version_dep)
 
 include_HEADERS = quadmath.h quadmath_weak.h
 
Index: libquadmath/acinclude.m4
===================================================================
--- libquadmath/acinclude.m4	(Revision 166875)
+++ libquadmath/acinclude.m4	(Arbeitskopie)
@@ -1,46 +1,302 @@ 
-dnl ----------------------------------------------------------------------
-dnl This whole bit snagged from libgfortran.
+dnl The following has been taken from gomp, which has
+dnl the whole bit snagged from libstdc++-v3.
 
-dnl Check whether the target supports __sync_*_compare_and_swap.
-AC_DEFUN([LIBGOMP_CHECK_SYNC_BUILTINS], [
-  AC_CACHE_CHECK([whether the target supports __sync_*_compare_and_swap],
-                 libgomp_cv_have_sync_builtins, [
-  AC_TRY_LINK([], [int foo; __sync_val_compare_and_swap(&foo, 0, 1);],
-              libgomp_cv_have_sync_builtins=yes, libgomp_cv_have_sync_builtins=no)])
-  if test $libgomp_cv_have_sync_builtins = yes; then
-    AC_DEFINE(HAVE_SYNC_BUILTINS, 1,
-              [Define to 1 if the target supports __sync_*_compare_and_swap])
-  fi])
-
-dnl Check whether the target supports hidden visibility.
-AC_DEFUN([LIBGOMP_CHECK_ATTRIBUTE_VISIBILITY], [
-  AC_CACHE_CHECK([whether the target supports hidden visibility],
-                 libgomp_cv_have_attribute_visibility, [
-  save_CFLAGS="$CFLAGS"
-  CFLAGS="$CFLAGS -Werror"
-  AC_TRY_COMPILE([void __attribute__((visibility("hidden"))) foo(void) { }],
-                 [], libgomp_cv_have_attribute_visibility=yes,
-                 libgomp_cv_have_attribute_visibility=no)
-  CFLAGS="$save_CFLAGS"])
-  if test $libgomp_cv_have_attribute_visibility = yes; then
-    AC_DEFINE(HAVE_ATTRIBUTE_VISIBILITY, 1,
-      [Define to 1 if the target supports __attribute__((visibility(...))).])
-  fi])
-
-dnl Check whether the target supports dllexport
-AC_DEFUN([LIBGOMP_CHECK_ATTRIBUTE_DLLEXPORT], [
-  AC_CACHE_CHECK([whether the target supports dllexport],
-                 libgomp_cv_have_attribute_dllexport, [
-  save_CFLAGS="$CFLAGS"
-  CFLAGS="$CFLAGS -Werror"
-  AC_TRY_COMPILE([void __attribute__((dllexport)) foo(void) { }],
-                 [], libgomp_cv_have_attribute_dllexport=yes,
-                 libgomp_cv_have_attribute_dllexport=no)
-  CFLAGS="$save_CFLAGS"])
-  if test $libgomp_cv_have_attribute_dllexport = yes; then
-    AC_DEFINE(HAVE_ATTRIBUTE_DLLEXPORT, 1,
-      [Define to 1 if the target supports __attribute__((dllexport)).])
-  fi])
+dnl
+dnl LIBQUAD_ENABLE
+dnl    (FEATURE, DEFAULT, HELP-ARG, HELP-STRING)
+dnl    (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, permit a|b|c)
+dnl    (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, SHELL-CODE-HANDLER)
+dnl
+dnl See docs/html/17_intro/configury.html#enable for documentation.
+dnl
+m4_define([LIBQUAD_ENABLE],[dnl
+m4_define([_g_switch],[--enable-$1])dnl
+m4_define([_g_help],[AC_HELP_STRING(_g_switch$3,[$4 @<:@default=$2@:>@])])dnl
+ AC_ARG_ENABLE($1,_g_help,
+  m4_bmatch([$5],
+   [^permit ],
+     [[
+      case "$enableval" in
+       m4_bpatsubst([$5],[permit ])) ;;
+       *) AC_MSG_ERROR(Unknown argument to enable/disable $1) ;;
+          dnl Idea for future:  generate a URL pointing to
+          dnl "onlinedocs/configopts.html#whatever"
+      esac
+     ]],
+   [^$],
+     [[
+      case "$enableval" in
+       yes|no) ;;
+       *) AC_MSG_ERROR(Argument to enable/disable $1 must be yes or no) ;;
+      esac
+     ]],
+   [[$5]]),
+  [enable_]m4_bpatsubst([$1],-,_)[=][$2])
+m4_undefine([_g_switch])dnl
+m4_undefine([_g_help])dnl
+])
+
+
+dnl
+dnl If GNU ld is in use, check to see if tricky linker opts can be used.  If
+dnl the native linker is in use, all variables will be defined to something
+dnl safe (like an empty string).
+dnl
+dnl Defines:
+dnl  SECTION_LDFLAGS='-Wl,--gc-sections' if possible
+dnl  OPT_LDFLAGS='-Wl,-O1' if possible
+dnl  LD (as a side effect of testing)
+dnl Sets:
+dnl  with_gnu_ld
+dnl  libquad_ld_is_gold (possibly)
+dnl  libquad_gnu_ld_version (possibly)
+dnl
+dnl The last will be a single integer, e.g., version 1.23.45.0.67.89 will
+dnl set libquad_gnu_ld_version to 12345.  Zeros cause problems.
+dnl
+AC_DEFUN([LIBQUAD_CHECK_LINKER_FEATURES], [
+  # If we're not using GNU ld, then there's no point in even trying these
+  # tests.  Check for that first.  We should have already tested for gld
+  # by now (in libtool), but require it now just to be safe...
+  test -z "$SECTION_LDFLAGS" && SECTION_LDFLAGS=''
+  test -z "$OPT_LDFLAGS" && OPT_LDFLAGS=''
+  AC_REQUIRE([AC_PROG_LD])
+  AC_REQUIRE([AC_PROG_AWK])
+
+  # The name set by libtool depends on the version of libtool.  Shame on us
+  # for depending on an impl detail, but c'est la vie.  Older versions used
+  # ac_cv_prog_gnu_ld, but now it's lt_cv_prog_gnu_ld, and is copied back on
+  # top of with_gnu_ld (which is also set by --with-gnu-ld, so that actually
+  # makes sense).  We'll test with_gnu_ld everywhere else, so if that isn't
+  # set (hence we're using an older libtool), then set it.
+  if test x${with_gnu_ld+set} != xset; then
+    if test x${ac_cv_prog_gnu_ld+set} != xset; then
+      # We got through "ac_require(ac_prog_ld)" and still not set?  Huh?
+      with_gnu_ld=no
+    else
+      with_gnu_ld=$ac_cv_prog_gnu_ld
+    fi
+  fi
+
+  # Start by getting the version number.  I think the libtool test already
+  # does some of this, but throws away the result.
+  libquad_ld_is_gold=no
+  if $LD --version 2>/dev/null | grep 'GNU gold'> /dev/null 2>&1; then
+    libquad_ld_is_gold=yes
+  fi
+  changequote(,)
+  ldver=`$LD --version 2>/dev/null |
+         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'`
+  changequote([,])
+  libquad_gnu_ld_version=`echo $ldver | \
+         $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
+
+  # Set --gc-sections.
+  if test "$with_gnu_ld" = "notbroken"; then
+    # GNU ld it is!  Joy and bunny rabbits!
+
+    # All these tests are for C++; save the language and the compiler flags.
+    # Need to do this so that g++ won't try to link in libstdc++
+    ac_test_CFLAGS="${CFLAGS+set}"
+    ac_save_CFLAGS="$CFLAGS"
+    CFLAGS='-x c++  -Wl,--gc-sections'
+
+    # Check for -Wl,--gc-sections
+    # XXX This test is broken at the moment, as symbols required for linking
+    # are now in libsupc++ (not built yet).  In addition, this test has
+    # cored on solaris in the past.  In addition, --gc-sections doesn't
+    # really work at the moment (keeps on discarding used sections, first
+    # .eh_frame and now some of the glibc sections for iconv).
+    # Bzzzzt.  Thanks for playing, maybe next time.
+    AC_MSG_CHECKING([for ld that supports -Wl,--gc-sections])
+    AC_TRY_RUN([
+     int main(void)
+     {
+       try { throw 1; }
+       catch (...) { };
+       return 0;
+     }
+    ], [ac_sectionLDflags=yes],[ac_sectionLDflags=no], [ac_sectionLDflags=yes])
+    if test "$ac_test_CFLAGS" = set; then
+      CFLAGS="$ac_save_CFLAGS"
+    else
+      # this is the suspicious part
+      CFLAGS=''
+    fi
+    if test "$ac_sectionLDflags" = "yes"; then
+      SECTION_LDFLAGS="-Wl,--gc-sections $SECTION_LDFLAGS"
+    fi
+    AC_MSG_RESULT($ac_sectionLDflags)
+  fi
+
+  # Set linker optimization flags.
+  if test x"$with_gnu_ld" = x"yes"; then
+    OPT_LDFLAGS="-Wl,-O1 $OPT_LDFLAGS"
+  fi
+
+  AC_SUBST(SECTION_LDFLAGS)
+  AC_SUBST(OPT_LDFLAGS)
+])
+
+
+dnl
+dnl Add version tags to symbols in shared library (or not), additionally
+dnl marking other symbols as private/local (or not).
+dnl
+dnl --enable-symvers=style adds a version script to the linker call when
+dnl       creating the shared library.  The choice of version script is
+dnl       controlled by 'style'.
+dnl --disable-symvers does not.
+dnl  +  Usage:  LIBQUAD_ENABLE_SYMVERS[(DEFAULT)]
+dnl       Where DEFAULT is either 'yes' or 'no'.  Passing `yes' tries to
+dnl       choose a default style based on linker characteristics.  Passing
+dnl       'no' disables versioning.
+dnl
+AC_DEFUN([LIBQUAD_ENABLE_SYMVERS], [
+
+LIBQUAD_ENABLE(symvers,yes,[=STYLE],
+  [enables symbol versioning of the shared library],
+  [permit yes|no|gnu|sun])
+
+# If we never went through the LIBQUAD_CHECK_LINKER_FEATURES macro, then we
+# don't know enough about $LD to do tricks...
+AC_REQUIRE([LIBQUAD_CHECK_LINKER_FEATURES])
+# FIXME  The following test is too strict, in theory.
+if test $enable_shared = no || test "x$LD" = x; then
+  enable_symvers=no
+else
+  if test $with_gnu_ld = yes ; then
+    enable_symvers=gnu
+  else
+    case ${target_os} in
+      # Sun symbol versioning exists since Solaris 2.5.
+      solaris2.[[5-9]]* | solaris2.1[[0-9]]*)
+        enable_symvers=sun ;;
+      *)
+        enable_symvers=no ;;
+    esac
+  fi
+fi
+
+# Check if 'sun' was requested on non-Solaris 2 platforms.
+if test x$enable_symvers = xsun ; then
+  case ${target_os} in
+    solaris2*)
+      # All fine.
+      ;;
+    *)
+      # Unlikely to work.
+      AC_MSG_WARN([=== You have requested Sun symbol versioning, but])
+      AC_MSG_WARN([=== you are not targetting Solaris 2.])
+      AC_MSG_WARN([=== Symbol versioning will be disabled.])
+      enable_symvers=no
+      ;;
+  esac
+fi
+
+# Check to see if libgcc_s exists, indicating that shared libgcc is possible.
+if test $enable_symvers != no; then
+  AC_MSG_CHECKING([for shared libgcc])
+  ac_save_CFLAGS="$CFLAGS"
+  CFLAGS=' -lgcc_s'
+  AC_TRY_LINK(, [return 0;], libquad_shared_libgcc=yes, libquad_shared_libgcc=no)
+  CFLAGS="$ac_save_CFLAGS"
+  if test $libquad_shared_libgcc = no; then
+    cat > conftest.c <<EOF
+int main (void) { return 0; }
+EOF
+changequote(,)dnl
+    libquad_libgcc_s_suffix=`${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
+			     -shared -shared-libgcc -o conftest.so \
+			     conftest.c -v 2>&1 >/dev/null \
+			     | sed -n 's/^.* -lgcc_s\([^ ]*\) .*$/\1/p'`
+changequote([,])dnl
+    rm -f conftest.c conftest.so
+    if test x${libquad_libgcc_s_suffix+set} = xset; then
+      CFLAGS=" -lgcc_s$libquad_libgcc_s_suffix"
+      AC_TRY_LINK(, [return 0;], libquad_shared_libgcc=yes)
+      CFLAGS="$ac_save_CFLAGS"
+    fi
+  fi
+  AC_MSG_RESULT($libquad_shared_libgcc)
+fi
+
+# For GNU ld, we need at least this version.  The format is described in
+# LIBQUAD_CHECK_LINKER_FEATURES above.
+libquad_min_gnu_ld_version=21400
+# XXXXXXXXXXX libquad_gnu_ld_version=21390
+
+# Check to see if unspecified "yes" value can win, given results above.
+# Change "yes" into either "no" or a style name.
+if test $enable_symvers != no && test $libquad_shared_libgcc = yes; then
+  if test $with_gnu_ld = yes; then
+    if test $libquad_gnu_ld_version -ge $libquad_min_gnu_ld_version ; then
+      enable_symvers=gnu
+    elif test $libquad_ld_is_gold = yes ; then
+      enable_symvers=gnu
+    else
+      # The right tools, the right setup, but too old.  Fallbacks?
+      AC_MSG_WARN(=== Linker version $libquad_gnu_ld_version is too old for)
+      AC_MSG_WARN(=== full symbol versioning support in this release of GCC.)
+      AC_MSG_WARN(=== You would need to upgrade your binutils to version)
+      AC_MSG_WARN(=== $libquad_min_gnu_ld_version or later and rebuild GCC.)
+      if test $libquad_gnu_ld_version -ge 21200 ; then
+        # Globbing fix is present, proper block support is not.
+        dnl AC_MSG_WARN([=== Dude, you are soooo close.  Maybe we can fake it.])
+        dnl enable_symvers=???
+        AC_MSG_WARN([=== Symbol versioning will be disabled.])
+        enable_symvers=no
+      else
+        # 2.11 or older.
+        AC_MSG_WARN([=== Symbol versioning will be disabled.])
+        enable_symvers=no
+      fi
+    fi
+  elif test $enable_symvers = sun; then
+    : All interesting versions of Sun ld support sun style symbol versioning.
+  else
+    # just fail for now
+    AC_MSG_WARN([=== You have requested some kind of symbol versioning, but])
+    AC_MSG_WARN([=== either you are not using a supported linker, or you are])
+    AC_MSG_WARN([=== not building a shared libgcc_s (which is required).])
+    AC_MSG_WARN([=== Symbol versioning will be disabled.])
+    enable_symvers=no
+  fi
+fi
+
+AC_CACHE_CHECK([whether the target supports .symver directive],
+	       libquad_cv_have_as_symver_directive, [
+  AC_TRY_COMPILE([void foo (void); __asm (".symver foo, bar@SYMVER");],
+		 [], libquad_cv_have_as_symver_directive=yes,
+		 libquad_cv_have_as_symver_directive=no)])
+if test $libquad_cv_have_as_symver_directive = yes; then
+  AC_DEFINE(HAVE_AS_SYMVER_DIRECTIVE, 1,
+    [Define to 1 if the target assembler supports .symver directive.])
+fi
+
+AM_CONDITIONAL(LIBQUAD_BUILD_VERSIONED_SHLIB, test $enable_symvers != no)
+AM_CONDITIONAL(LIBQUAD_BUILD_VERSIONED_SHLIB_GNU, test $enable_symvers = gnu)
+AM_CONDITIONAL(LIBQUAD_BUILD_VERSIONED_SHLIB_SUN, test $enable_symvers = sun)
+AC_MSG_NOTICE(versioning on shared library symbols is $enable_symvers)
+
+if test $enable_symvers != no ; then
+   case ${target_os} in
+     # The Solaris 2 runtime linker doesn't support the GNU extension of
+     # binding the same symbol to different versions
+     solaris2*)
+       symvers_renaming=no ;;
+     # Other platforms with GNU symbol versioning (GNU/Linux, more?) do.
+     *)
+       AC_DEFINE(HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT, 1,
+         [Define to 1 if the target runtime linker supports binding the same symbol to different versions.])
+       symvers_renaming=yes ;;
+    esac
+fi
+AM_CONDITIONAL(LIBQUAD_BUILD_VERSIONED_SHLIB_SOL2, test $symvers_renaming = no)
+])
+
+
+dnl The following comes from libgomp, which has it from libgfortran 
 
 sinclude(../libtool.m4)
 dnl The lines below arrange for aclocal not to bring an installed
Index: libquadmath/configure.ac
===================================================================
--- libquadmath/configure.ac	(Revision 166875)
+++ libquadmath/configure.ac	(Arbeitskopie)
@@ -25,8 +25,13 @@  target_alias=${target_alias-$host_alias}
 
 AM_INIT_AUTOMAKE([1.9.0 foreign subdir-objects no-dist -Wall -Werror])
 
-AC_PROG_CC
-AM_PROG_CC_C_O
+# Are we being configured with some form of cross compiler?
+if test "$build" != "$host"; then
+  LIBQUAD_IS_NATIVE=false
+  GCC_NO_EXECUTABLES
+else
+  LIBQUAD_IS_NATIVE=true
+fi
 
 AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
 AC_ARG_ENABLE(version-specific-runtime-libs,
@@ -39,7 +44,6 @@  AC_ARG_ENABLE(version-specific-runtime-l
 [version_specific_libs=no])
 AC_MSG_RESULT($version_specific_libs)
 
-
 # Configure libtool
 AM_PROG_LIBTOOL
 AC_SUBST(enable_shared)
@@ -78,42 +82,22 @@  esac
 AC_SUBST(toolexecdir)
 AC_SUBST(toolexeclibdir)
 
+AC_PROG_CC
+AM_PROG_CC_C_O
+
 AC_CHECK_LIB([m],[sqrtl],[AC_DEFINE([HAVE_SQRTL],[1],[libm includes sqrtl])])
 AC_CHECK_LIB([m],[cbrtl],[AC_DEFINE([HAVE_CBRTL],[1],[libm includes cbrtl])])
 
-# Check for symbol versioning (copied from libssp).
-AC_MSG_CHECKING([whether symbol versioning is supported])
-save_LDFLAGS="$LDFLAGS"
-LDFLAGS="$LDFLAGS -fPIC -shared -Wl,--version-script,./conftest.map"
-cat > conftest.map <<EOF
-FOO_1.0 {
-  global: *foo*; bar; local: *;
-};
-EOF
-AC_TRY_LINK([int foo;],[],[quadmath_use_symver=gnu],[quadmath_use_symver=no])
-if test x$quadmath_use_symver = xno; then
-  case "$target_os" in
-    solaris2*)
-      LDFLAGS="$save_LDFLAGS"
-      LDFLAGS="$LDFLAGS -fPIC -shared -Wl,-M,./conftest.map"
-      # Sun ld cannot handle wildcards and treats all entries as undefined.
-      cat > conftest.map <<EOF
-FOO_1.0 {
-  global: foo; local: *;
-};
-EOF
-      AC_TRY_LINK([int foo;],[],[quadmath_use_symver=sun],[quadmath_use_symver=no])
-      ;;
-  esac
+LIBQUAD_ENABLE_SYMVERS
+
+if test $enable_symvers = gnu; then
+  AC_DEFINE(LIBQUAD_GNU_SYMBOL_VERSIONING, 1,
+            [Define to 1 if GNU symbol versioning is used for libgomp.])
 fi
-LDFLAGS="$save_LDFLAGS"
-AC_MSG_RESULT($quadmath_use_symver)
-AM_CONDITIONAL(LIBQUAD_USE_SYMVER, [test "x$quadmath_use_symver" != xno])
-AM_CONDITIONAL(LIBQUAD_USE_SYMVER_GNU, [test "x$quadmath_use_symver" = xgnu])
-AM_CONDITIONAL(LIBQUAD_USE_SYMVER_SUN, [test "x$quadmath_use_symver" = xsun])
+
 
 AC_MSG_CHECKING([whether __float128 is supported])
-  AC_TRY_LINK([
+  GCC_TRY_COMPILE_OR_LINK([
     typedef _Complex float __attribute__((mode(TC))) __complex128;
 
     __float128 foo (__float128 x)
@@ -136,12 +120,13 @@  AC_MSG_CHECKING([whether __float128 is s
     foo (1.2Q);
     bar (1.2Q);
   ],[
-    libquad_have_float128=yes
+    libquad_cv_have_float128=yes
   ],[
-    libquad_have_float128=no
+    libquad_cv_have_float128=no
 ])
 AC_MSG_RESULT([$libquad_have_float128])
 
+
 dnl
 dnl Enable the following for a stand-alone library:
 dnl
@@ -149,7 +134,7 @@  dnl if test $libquad_have_float128 = no;
 dnl   AC_MSG_ERROR([__float128 support is required to build this library.])
 dnl fi
 
-AM_CONDITIONAL(BUILD_LIBQUADMATH, [test "x$libquad_have_float128" = xyes])
+AM_CONDITIONAL(BUILD_LIBQUADMATH, [test "x$libquad_cv_have_float128" = xyes])
 
 AC_CACHE_SAVE