Hi.

I noticed we have duplicate .m4 code that detects information about linker
in lib* folders:

libffi/acinclude.m4 - this one is merge from the upstream project

libatomic/acinclude.m4
libgomp/acinclude.m4
libitm/acinclude.m4
libstdc++-v3/acinclude.m4

I prepared a proof-of-concept patch that factors out the code for libgomp and 
libatomic.
Is it something we want to? If so, I can try finished that for next stage1.

Cheers,
Martin

---
 config/ld.m4               | 233 +++++++++++++++++++++++++++
 libatomic/Makefile.in      |   1 +
 libatomic/acinclude.m4     | 317 +------------------------------------
 libatomic/aclocal.m4       |   1 +
 libatomic/auto-config.h.in |  10 +-
 libatomic/configure        | 149 +++++++++--------
 libgomp/Makefile.in        |   1 +
 libgomp/acinclude.m4       | 225 +-------------------------
 libgomp/aclocal.m4         |   1 +
 libgomp/config.h.in        |   3 +
 libgomp/configure          | 162 ++++++++++---------
 11 files changed, 417 insertions(+), 686 deletions(-)
 create mode 100644 config/ld.m4

diff --git a/config/ld.m4 b/config/ld.m4
new file mode 100644
index 00000000000..1f069d463d7
--- /dev/null
+++ b/config/ld.m4
@@ -0,0 +1,233 @@
+dnl Copyright (C) 2022 Free Software Foundation, Inc.
+dnl This file is free software, distributed under the terms of the GNU
+dnl General Public License.  As a special exception to the GNU General
+dnl Public License, this file may be distributed as part of a program
+dnl that contains a configuration script generated by Autoconf, under
+dnl the same distribution terms as the rest of that program.
+
+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  GNU_SYMBOL_VERSIONING
+dnl Sets:
+dnl  with_gnu_ld
+dnl  ld_is_gold (possibly)
+dnl  gnu_ld_version (possibly)
+dnl  enable_symvers
+dnl
+dnl The last will be a single integer, e.g., version 1.23.45.0.67.89 will
+dnl set gnu_ld_version to 12345.  Zeros cause problems.
+dnl
+AC_DEFUN([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.
+  ld_is_gold=no
+  if $LD --version 2>/dev/null | grep 'GNU gold'> /dev/null 2>&1; then
+    ld_is_gold=yes
+  fi
+  changequote(,)
+  ldver=`$LD --version 2>/dev/null |
+         sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
+  changequote([,])
+  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
+
+  # Turn a 'yes' into a suitable default.
+  if test x$enable_symvers = xyes ; then
+    # 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
+  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 x$enable_symvers != xno; then
+  AC_MSG_CHECKING([for shared libgcc])
+  ac_save_CFLAGS="$CFLAGS"
+  CFLAGS=' -lgcc_s'
+  AC_TRY_LINK(, [return 0;], shared_libgcc=yes, shared_libgcc=no)
+  CFLAGS="$ac_save_CFLAGS"
+  if test $shared_libgcc = no; then
+    cat > conftest.c <<EOF
+int main (void) { return 0; }
+EOF
+changequote(,)dnl
+    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${libgcc_s_suffix+set} = xset; then
+      CFLAGS=" -lgcc_s$libgcc_s_suffix"
+      AC_TRY_LINK(, [return 0;], shared_libgcc=yes)
+      CFLAGS="$ac_save_CFLAGS"
+    fi
+  fi
+  AC_MSG_RESULT($shared_libgcc)
+fi
+
+# For GNU ld, we need at least this version.  The format is described in
+# CHECK_LINKER_FEATURES above.
+min_gnu_ld_version=21400
+# XXXXXXXXXXX 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 x$enable_symvers != xno && test $shared_libgcc = yes; then
+  if test $with_gnu_ld = yes; then
+    if test $gnu_ld_version -ge $min_gnu_ld_version ; then
+      enable_symvers=gnu
+    elif test $ld_is_gold = yes ; then
+      enable_symvers=gnu
+    else
+      # The right tools, the right setup, but too old.  Fallbacks?
+      AC_MSG_WARN(=== Linker version $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(=== $min_gnu_ld_version or later and rebuild GCC.)
+      if test $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
+if test $enable_symvers = gnu; then
+  AC_DEFINE(GNU_SYMBOL_VERSIONING, 1,
+           [Define to 1 if GNU symbol versioning is used for libatomic.])
+fi
+
+if test x$enable_symvers != xno ; 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*)
+       ;;
+     # 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.])
+       ;;
+    esac
+fi
+
+  AC_SUBST(SECTION_LDFLAGS)
+  AC_SUBST(OPT_LDFLAGS)
+])
diff --git a/libatomic/Makefile.in b/libatomic/Makefile.in
index 0a51bd55f01..4ae0760db07 100644
--- a/libatomic/Makefile.in
+++ b/libatomic/Makefile.in
@@ -108,6 +108,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
        $(top_srcdir)/../config/stdint.m4 \
        $(top_srcdir)/../config/toolexeclibdir.m4 \
        $(top_srcdir)/../config/warnings.m4 \
+       $(top_srcdir)/../config/ld.m4 \
        $(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \
        $(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \
        $(top_srcdir)/acinclude.m4 $(top_srcdir)/../libtool.m4 \
diff --git a/libatomic/acinclude.m4 b/libatomic/acinclude.m4
index 20814bf6cdc..647fcaf0872 100644
--- a/libatomic/acinclude.m4
+++ b/libatomic/acinclude.m4
@@ -287,209 +287,6 @@ 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  libat_ld_is_gold (possibly)
-dnl  libat_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 libat_gnu_ld_version to 12345.  Zeros cause problems.
-dnl
-AC_DEFUN([LIBAT_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.
-  libat_ld_is_gold=no
-  if $LD --version 2>/dev/null | grep 'GNU gold'> /dev/null 2>&1; then
-    libat_ld_is_gold=yes
-  fi
-  changequote(,)
-  ldver=`$LD --version 2>/dev/null |
-         sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
-  changequote([,])
-  libat_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 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  libat_ld_is_gold (possibly)
-dnl  libat_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 libat_gnu_ld_version to 12345.  Zeros cause problems.
-dnl
-AC_DEFUN([LIBAT_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.
-  libat_ld_is_gold=no
-  if $LD --version 2>/dev/null | grep 'GNU gold'> /dev/null 2>&1; then
-    libat_ld_is_gold=yes
-  fi
-  changequote(,)
-  ldver=`$LD --version 2>/dev/null |
-         sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
-  changequote([,])
-  libat_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
@@ -510,119 +307,9 @@ LIBAT_ENABLE(symvers,yes,[=STYLE],
   [enables symbol versioning of the shared library],
   [permit yes|no|gnu*|sun])
-# If we never went through the LIBAT_CHECK_LINKER_FEATURES macro, then we
+# If we never went through the CHECK_LINKER_FEATURES macro, then we
 # don't know enough about $LD to do tricks...
-AC_REQUIRE([LIBAT_CHECK_LINKER_FEATURES])
-
-# Turn a 'yes' into a suitable default.
-if test x$enable_symvers = xyes ; then
-  # 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
-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;], libat_shared_libgcc=yes, libat_shared_libgcc=no)
-  CFLAGS="$ac_save_CFLAGS"
-  if test $libat_shared_libgcc = no; then
-    cat > conftest.c <<EOF
-int main (void) { return 0; }
-EOF
-changequote(,)dnl
-    libat_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${libat_libgcc_s_suffix+set} = xset; then
-      CFLAGS=" -lgcc_s$libat_libgcc_s_suffix"
-      AC_TRY_LINK(, [return 0;], libat_shared_libgcc=yes)
-      CFLAGS="$ac_save_CFLAGS"
-    fi
-  fi
-  AC_MSG_RESULT($libat_shared_libgcc)
-fi
-
-# For GNU ld, we need at least this version.  The format is described in
-# LIBAT_CHECK_LINKER_FEATURES above.
-libat_min_gnu_ld_version=21400
-# XXXXXXXXXXX libat_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 $libat_shared_libgcc = yes; then
-  if test $with_gnu_ld = yes; then
-    if test $libat_gnu_ld_version -ge $libat_min_gnu_ld_version ; then
-      enable_symvers=gnu
-    elif test $libat_ld_is_gold = yes ; then
-      enable_symvers=gnu
-    else
-      # The right tools, the right setup, but too old.  Fallbacks?
-      AC_MSG_WARN(=== Linker version $libat_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(=== $libat_min_gnu_ld_version or later and rebuild GCC.)
-      if test $libat_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
-if test $enable_symvers = gnu; then
-  AC_DEFINE(LIBAT_GNU_SYMBOL_VERSIONING, 1,
-           [Define to 1 if GNU symbol versioning is used for libatomic.])
-fi
+AC_REQUIRE([CHECK_LINKER_FEATURES])
AM_CONDITIONAL(LIBAT_BUILD_VERSIONED_SHLIB, test $enable_symvers != no)
 AM_CONDITIONAL(LIBAT_BUILD_VERSIONED_SHLIB_GNU, test $enable_symvers = gnu)
diff --git a/libatomic/aclocal.m4 b/libatomic/aclocal.m4
index 80e24219d7d..ab5a0cc006f 100644
--- a/libatomic/aclocal.m4
+++ b/libatomic/aclocal.m4
@@ -1189,6 +1189,7 @@ AC_SUBST([am__untar])
m4_include([../config/acx.m4])
 m4_include([../config/depstand.m4])
+m4_include([../config/ld.m4])
 m4_include([../config/lead-dot.m4])
 m4_include([../config/lthostflags.m4])
 m4_include([../config/multi.m4])
diff --git a/libatomic/auto-config.h.in b/libatomic/auto-config.h.in
index ab3424a759e..038490a1ce8 100644
--- a/libatomic/auto-config.h.in
+++ b/libatomic/auto-config.h.in
@@ -3,6 +3,9 @@
 /* Define if building universal (internal helper macro) */
 #undef AC_APPLE_UNIVERSAL_BUILD
+/* Define to 1 if GNU symbol versioning is used for libatomic. */
+#undef GNU_SYMBOL_VERSIONING
+
 /* Have __atomic_compare_exchange for 1 byte integers. */
 #undef HAVE_ATOMIC_CAS_1
@@ -144,6 +147,10 @@
 /* Define to 1 if you have the <string.h> header file. */
 #undef HAVE_STRING_H
+/* Define to 1 if the target runtime linker supports binding the same symbol
+   to different versions. */
+#undef HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT
+
 /* Define to 1 if you have the <sys/stat.h> header file. */
 #undef HAVE_SYS_STAT_H
@@ -156,9 +163,6 @@
 /* Define ifunc resolver function argument. */
 #undef IFUNC_RESOLVER_ARGS
-/* Define to 1 if GNU symbol versioning is used for libatomic. */
-#undef LIBAT_GNU_SYMBOL_VERSIONING
-
 /* Define to the sub-directory in which libtool stores uninstalled libraries.
    */
 #undef LT_OBJDIR
diff --git a/libatomic/configure b/libatomic/configure
index 5867e69ac14..8057bdabd6b 100755
--- a/libatomic/configure
+++ b/libatomic/configure
@@ -11380,7 +11380,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11393 "configure"
+#line 11383 "configure"
 #include "confdefs.h"
#if HAVE_DLFCN_H
@@ -11486,7 +11486,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11499 "configure"
+#line 11489 "configure"
 #include "confdefs.h"
#if HAVE_DLFCN_H
@@ -15196,15 +15196,15 @@ with_gnu_ld=$lt_cv_prog_gnu_ld
# Start by getting the version number. I think the libtool test already
   # does some of this, but throws away the result.
-  libat_ld_is_gold=no
+  ld_is_gold=no
   if $LD --version 2>/dev/null | grep 'GNU gold'> /dev/null 2>&1; then
-    libat_ld_is_gold=yes
+    ld_is_gold=yes
   fi
ldver=`$LD --version 2>/dev/null |
          sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
- libat_gnu_ld_version=`echo $ldver | \
+  gnu_ld_version=`echo $ldver | \
          $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
# Set --gc-sections.
@@ -15267,48 +15267,25 @@ $as_echo "$ac_sectionLDflags" >&6; }
     OPT_LDFLAGS="-Wl,-O1 $OPT_LDFLAGS"
   fi
-
-
-
-
-
- # Check whether --enable-symvers was given.
-if test "${enable_symvers+set}" = set; then :
-  enableval=$enable_symvers;
-      case "$enableval" in
-       yes|no|gnu*|sun) ;;
-       *) as_fn_error $? "Unknown argument to enable/disable symvers" 
"$LINENO" 5 ;;
-                          esac
-
-else
-  enable_symvers=yes
-fi
-
-
-
-# If we never went through the LIBAT_CHECK_LINKER_FEATURES macro, then we
-# don't know enough about $LD to do tricks...
-
-
-# Turn a 'yes' into a suitable default.
-if test x$enable_symvers = xyes ; then
-  # 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
+  # Turn a 'yes' into a suitable default.
+  if test x$enable_symvers = xyes ; then
+    # FIXME  The following test is too strict, in theory.
+    if test $enable_shared = no || test "x$LD" = x; then
+      enable_symvers=no
     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
+      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
   fi
-fi
# Check if 'sun' was requested on non-Solaris 2 platforms.
 if test x$enable_symvers = xsun ; then
@@ -15330,7 +15307,7 @@ $as_echo "$as_me: WARNING: === Symbol versioning will be 
disabled." >&2;}
 fi
# Check to see if libgcc_s exists, indicating that shared libgcc is possible.
-if test $enable_symvers != no; then
+if test x$enable_symvers != xno; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared libgcc" >&5
 $as_echo_n "checking for shared libgcc... " >&6; }
   ac_save_CFLAGS="$CFLAGS"
@@ -15347,24 +15324,24 @@ return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  libat_shared_libgcc=yes
+  shared_libgcc=yes
 else
-  libat_shared_libgcc=no
+  shared_libgcc=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
   CFLAGS="$ac_save_CFLAGS"
-  if test $libat_shared_libgcc = no; then
+  if test $shared_libgcc = no; then
     cat > conftest.c <<EOF
 int main (void) { return 0; }
 EOF
-    libat_libgcc_s_suffix=`${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
+    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'`
     rm -f conftest.c conftest.so
-    if test x${libat_libgcc_s_suffix+set} = xset; then
-      CFLAGS=" -lgcc_s$libat_libgcc_s_suffix"
+    if test x${libgcc_s_suffix+set} = xset; then
+      CFLAGS=" -lgcc_s$libgcc_s_suffix"
       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
@@ -15377,41 +15354,41 @@ return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  libat_shared_libgcc=yes
+  shared_libgcc=yes
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
       CFLAGS="$ac_save_CFLAGS"
     fi
   fi
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libat_shared_libgcc" >&5
-$as_echo "$libat_shared_libgcc" >&6; }
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $shared_libgcc" >&5
+$as_echo "$shared_libgcc" >&6; }
 fi
# For GNU ld, we need at least this version. The format is described in
-# LIBAT_CHECK_LINKER_FEATURES above.
-libat_min_gnu_ld_version=21400
-# XXXXXXXXXXX libat_gnu_ld_version=21390
+# CHECK_LINKER_FEATURES above.
+min_gnu_ld_version=21400
+# XXXXXXXXXXX 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 $libat_shared_libgcc = yes; then
+if test x$enable_symvers != xno && test $shared_libgcc = yes; then
   if test $with_gnu_ld = yes; then
-    if test $libat_gnu_ld_version -ge $libat_min_gnu_ld_version ; then
+    if test $gnu_ld_version -ge $min_gnu_ld_version ; then
       enable_symvers=gnu
-    elif test $libat_ld_is_gold = yes ; then
+    elif test $ld_is_gold = yes ; then
       enable_symvers=gnu
     else
       # The right tools, the right setup, but too old.  Fallbacks?
-      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: === Linker version 
$libat_gnu_ld_version is too old for" >&5
-$as_echo "$as_me: WARNING: === Linker version $libat_gnu_ld_version is too old for" 
>&2;}
+      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: === Linker version $gnu_ld_version 
is too old for" >&5
+$as_echo "$as_me: WARNING: === Linker version $gnu_ld_version is too old for" 
>&2;}
       { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: === full symbol versioning support 
in this release of GCC." >&5
 $as_echo "$as_me: WARNING: === full symbol versioning support in this release of 
GCC." >&2;}
       { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: === You would need to upgrade your 
binutils to version" >&5
 $as_echo "$as_me: WARNING: === You would need to upgrade your binutils to version" 
>&2;}
-      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: === $libat_min_gnu_ld_version or 
later and rebuild GCC." >&5
-$as_echo "$as_me: WARNING: === $libat_min_gnu_ld_version or later and rebuild GCC." 
>&2;}
-      if test $libat_gnu_ld_version -ge 21200 ; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: === $min_gnu_ld_version or later 
and rebuild GCC." >&5
+$as_echo "$as_me: WARNING: === $min_gnu_ld_version or later and rebuild GCC." 
>&2;}
+      if test $gnu_ld_version -ge 21200 ; then
         # Globbing fix is present, proper block support is not.
                         { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: === Symbol 
versioning will be disabled." >&5
 $as_echo "$as_me: WARNING: === Symbol versioning will be disabled." >&2;}
@@ -15440,10 +15417,48 @@ $as_echo "$as_me: WARNING: === Symbol versioning will be 
disabled." >&2;}
 fi
 if test $enable_symvers = gnu; then
-$as_echo "#define LIBAT_GNU_SYMBOL_VERSIONING 1" >>confdefs.h
+$as_echo "#define GNU_SYMBOL_VERSIONING 1" >>confdefs.h
+
+fi
+
+if test x$enable_symvers != xno ; 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*)
+       ;;
+     # Other platforms with GNU symbol versioning (GNU/Linux, more?) do.
+     *)
+
+$as_echo "#define HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT 1" >>confdefs.h
+
+       ;;
+    esac
+fi
+
+
+
+
+
+ # Check whether --enable-symvers was given.
+if test "${enable_symvers+set}" = set; then :
+  enableval=$enable_symvers;
+      case "$enableval" in
+       yes|no|gnu*|sun) ;;
+       *) as_fn_error $? "Unknown argument to enable/disable symvers" 
"$LINENO" 5 ;;
+                          esac
+
+else
+  enable_symvers=yes
 fi
+
+
+# If we never went through the CHECK_LINKER_FEATURES macro, then we
+# don't know enough about $LD to do tricks...
+
+
  if test $enable_symvers != no; then
   LIBAT_BUILD_VERSIONED_SHLIB_TRUE=
   LIBAT_BUILD_VERSIONED_SHLIB_FALSE='#'
@@ -15588,7 +15603,7 @@ case "$host" in
     case "$enable_cet" in
       auto)
        # Check if target supports multi-byte NOPs
-       # and if assembler supports CET insn.
+       # and if compiler and assembler support CET insn.
        cet_save_CFLAGS="$CFLAGS"
        CFLAGS="$CFLAGS -fcf-protection"
        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
diff --git a/libgomp/Makefile.in b/libgomp/Makefile.in
index 22cb2136a08..ce62bc816fa 100644
--- a/libgomp/Makefile.in
+++ b/libgomp/Makefile.in
@@ -134,6 +134,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
        $(top_srcdir)/../config/override.m4 \
        $(top_srcdir)/../config/tls.m4 \
        $(top_srcdir)/../config/toolexeclibdir.m4 \
+       $(top_srcdir)/../config/ld.m4 \
        $(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \
        $(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \
        $(top_srcdir)/acinclude.m4 $(top_srcdir)/../libtool.m4 \
diff --git a/libgomp/acinclude.m4 b/libgomp/acinclude.m4
index dbf54d06db9..3cceb439bc5 100644
--- a/libgomp/acinclude.m4
+++ b/libgomp/acinclude.m4
@@ -105,108 +105,6 @@ 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  libgomp_ld_is_gold (possibly)
-dnl  libgomp_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 libgomp_gnu_ld_version to 12345.  Zeros cause problems.
-dnl
-AC_DEFUN([LIBGOMP_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.
-  libgomp_ld_is_gold=no
-  if $LD --version 2>/dev/null | grep 'GNU gold'> /dev/null 2>&1; then
-    libgomp_ld_is_gold=yes
-  fi
-  changequote(,)
-  ldver=`$LD --version 2>/dev/null |
-         sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
-  changequote([,])
-  libgomp_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).
@@ -226,115 +124,9 @@ LIBGOMP_ENABLE(symvers,yes,[=STYLE],
   [enables symbol versioning of the shared library],
   [permit yes|no|gnu*|sun])
-# If we never went through the LIBGOMP_CHECK_LINKER_FEATURES macro, then we
+# If we never went through the CHECK_LINKER_FEATURES macro, then we
 # don't know enough about $LD to do tricks...
-AC_REQUIRE([LIBGOMP_CHECK_LINKER_FEATURES])
-
-# Turn a 'yes' into a suitable default.
-if test x$enable_symvers = xyes ; then
-  # 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
-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;], libgomp_shared_libgcc=yes, 
libgomp_shared_libgcc=no)
-  CFLAGS="$ac_save_CFLAGS"
-  if test $libgomp_shared_libgcc = no; then
-    cat > conftest.c <<EOF
-int main (void) { return 0; }
-EOF
-changequote(,)dnl
-    libgomp_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${libgomp_libgcc_s_suffix+set} = xset; then
-      CFLAGS=" -lgcc_s$libgomp_libgcc_s_suffix"
-      AC_TRY_LINK(, [return 0;], libgomp_shared_libgcc=yes)
-      CFLAGS="$ac_save_CFLAGS"
-    fi
-  fi
-  AC_MSG_RESULT($libgomp_shared_libgcc)
-fi
-
-# For GNU ld, we need at least this version.  The format is described in
-# LIBGOMP_CHECK_LINKER_FEATURES above.
-libgomp_min_gnu_ld_version=21400
-# XXXXXXXXXXX libgomp_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 $libgomp_shared_libgcc = yes; then
-  if test $with_gnu_ld = yes; then
-    if test $libgomp_gnu_ld_version -ge $libgomp_min_gnu_ld_version ; then
-      enable_symvers=gnu
-    elif test $libgomp_ld_is_gold = yes ; then
-      enable_symvers=gnu
-    else
-      # The right tools, the right setup, but too old.  Fallbacks?
-      AC_MSG_WARN(=== Linker version $libgomp_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(=== $libgomp_min_gnu_ld_version or later and rebuild GCC.)
-      if test $libgomp_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_REQUIRE([CHECK_LINKER_FEATURES])
AC_CACHE_CHECK([whether the target supports .symver directive],
               libgomp_cv_have_as_symver_directive, [
@@ -351,17 +143,4 @@ AM_CONDITIONAL(LIBGOMP_BUILD_VERSIONED_SHLIB_GNU, test 
$enable_symvers = gnu)
 AM_CONDITIONAL(LIBGOMP_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*)
-       ;;
-     # 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.])
-       ;;
-    esac
-fi
 ])
diff --git a/libgomp/aclocal.m4 b/libgomp/aclocal.m4
index 55d9d71895a..412f2eb381f 100644
--- a/libgomp/aclocal.m4
+++ b/libgomp/aclocal.m4
@@ -1172,6 +1172,7 @@ m4_include([../config/ax_count_cpus.m4])
 m4_include([../config/depstand.m4])
 m4_include([../config/enable.m4])
 m4_include([../config/futex.m4])
+m4_include([../config/ld.m4])
 m4_include([../config/lead-dot.m4])
 m4_include([../config/lthostflags.m4])
 m4_include([../config/multi.m4])
diff --git a/libgomp/config.h.in b/libgomp/config.h.in
index e702625ab6e..78930fa7417 100644
--- a/libgomp/config.h.in
+++ b/libgomp/config.h.in
@@ -1,5 +1,8 @@
 /* config.h.in.  Generated from configure.ac by autoheader.  */
+/* Define to 1 if GNU symbol versioning is used for libatomic. */
+#undef GNU_SYMBOL_VERSIONING
+
 /* Define to 1 if you have the `aligned_alloc' function. */
 #undef HAVE_ALIGNED_ALLOC
diff --git a/libgomp/configure b/libgomp/configure
index 4bc9b381c5c..c697f9fe292 100755
--- a/libgomp/configure
+++ b/libgomp/configure
@@ -15037,7 +15037,7 @@ _ACEOF
# Plugins for offload execution, configure.ac fragment. -*- mode: autoconf -*-
 #
-# Copyright (C) 2014-2021 Free Software Foundation, Inc.
+# Copyright (C) 2014-2022 Free Software Foundation, Inc.
 #
 # Contributed by Mentor Embedded.
 #
@@ -16230,15 +16230,15 @@ with_gnu_ld=$lt_cv_prog_gnu_ld
# Start by getting the version number. I think the libtool test already
   # does some of this, but throws away the result.
-  libgomp_ld_is_gold=no
+  ld_is_gold=no
   if $LD --version 2>/dev/null | grep 'GNU gold'> /dev/null 2>&1; then
-    libgomp_ld_is_gold=yes
+    ld_is_gold=yes
   fi
ldver=`$LD --version 2>/dev/null |
          sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
- libgomp_gnu_ld_version=`echo $ldver | \
+  gnu_ld_version=`echo $ldver | \
          $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
# Set --gc-sections.
@@ -16301,48 +16301,25 @@ $as_echo "$ac_sectionLDflags" >&6; }
     OPT_LDFLAGS="-Wl,-O1 $OPT_LDFLAGS"
   fi
-
-
-
-
-
- # Check whether --enable-symvers was given.
-if test "${enable_symvers+set}" = set; then :
-  enableval=$enable_symvers;
-      case "$enableval" in
-       yes|no|gnu*|sun) ;;
-       *) as_fn_error $? "Unknown argument to enable/disable symvers" 
"$LINENO" 5 ;;
-                          esac
-
-else
-  enable_symvers=yes
-fi
-
-
-
-# If we never went through the LIBGOMP_CHECK_LINKER_FEATURES macro, then we
-# don't know enough about $LD to do tricks...
-
-
-# Turn a 'yes' into a suitable default.
-if test x$enable_symvers = xyes ; then
-  # 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
+  # Turn a 'yes' into a suitable default.
+  if test x$enable_symvers = xyes ; then
+    # FIXME  The following test is too strict, in theory.
+    if test $enable_shared = no || test "x$LD" = x; then
+      enable_symvers=no
     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
+      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
   fi
-fi
# Check if 'sun' was requested on non-Solaris 2 platforms.
 if test x$enable_symvers = xsun ; then
@@ -16364,7 +16341,7 @@ $as_echo "$as_me: WARNING: === Symbol versioning will be 
disabled." >&2;}
 fi
# Check to see if libgcc_s exists, indicating that shared libgcc is possible.
-if test $enable_symvers != no; then
+if test x$enable_symvers != xno; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared libgcc" >&5
 $as_echo_n "checking for shared libgcc... " >&6; }
   ac_save_CFLAGS="$CFLAGS"
@@ -16381,24 +16358,24 @@ return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  libgomp_shared_libgcc=yes
+  shared_libgcc=yes
 else
-  libgomp_shared_libgcc=no
+  shared_libgcc=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
   CFLAGS="$ac_save_CFLAGS"
-  if test $libgomp_shared_libgcc = no; then
+  if test $shared_libgcc = no; then
     cat > conftest.c <<EOF
 int main (void) { return 0; }
 EOF
-    libgomp_libgcc_s_suffix=`${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
+    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'`
     rm -f conftest.c conftest.so
-    if test x${libgomp_libgcc_s_suffix+set} = xset; then
-      CFLAGS=" -lgcc_s$libgomp_libgcc_s_suffix"
+    if test x${libgcc_s_suffix+set} = xset; then
+      CFLAGS=" -lgcc_s$libgcc_s_suffix"
       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
@@ -16411,41 +16388,41 @@ return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  libgomp_shared_libgcc=yes
+  shared_libgcc=yes
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
       CFLAGS="$ac_save_CFLAGS"
     fi
   fi
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libgomp_shared_libgcc" >&5
-$as_echo "$libgomp_shared_libgcc" >&6; }
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $shared_libgcc" >&5
+$as_echo "$shared_libgcc" >&6; }
 fi
# For GNU ld, we need at least this version. The format is described in
-# LIBGOMP_CHECK_LINKER_FEATURES above.
-libgomp_min_gnu_ld_version=21400
-# XXXXXXXXXXX libgomp_gnu_ld_version=21390
+# CHECK_LINKER_FEATURES above.
+min_gnu_ld_version=21400
+# XXXXXXXXXXX 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 $libgomp_shared_libgcc = yes; then
+if test x$enable_symvers != xno && test $shared_libgcc = yes; then
   if test $with_gnu_ld = yes; then
-    if test $libgomp_gnu_ld_version -ge $libgomp_min_gnu_ld_version ; then
+    if test $gnu_ld_version -ge $min_gnu_ld_version ; then
       enable_symvers=gnu
-    elif test $libgomp_ld_is_gold = yes ; then
+    elif test $ld_is_gold = yes ; then
       enable_symvers=gnu
     else
       # The right tools, the right setup, but too old.  Fallbacks?
-      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: === Linker version 
$libgomp_gnu_ld_version is too old for" >&5
-$as_echo "$as_me: WARNING: === Linker version $libgomp_gnu_ld_version is too old for" 
>&2;}
+      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: === Linker version $gnu_ld_version 
is too old for" >&5
+$as_echo "$as_me: WARNING: === Linker version $gnu_ld_version is too old for" 
>&2;}
       { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: === full symbol versioning support 
in this release of GCC." >&5
 $as_echo "$as_me: WARNING: === full symbol versioning support in this release of 
GCC." >&2;}
       { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: === You would need to upgrade your 
binutils to version" >&5
 $as_echo "$as_me: WARNING: === You would need to upgrade your binutils to version" 
>&2;}
-      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: === $libgomp_min_gnu_ld_version or 
later and rebuild GCC." >&5
-$as_echo "$as_me: WARNING: === $libgomp_min_gnu_ld_version or later and rebuild GCC." 
>&2;}
-      if test $libgomp_gnu_ld_version -ge 21200 ; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: === $min_gnu_ld_version or later 
and rebuild GCC." >&5
+$as_echo "$as_me: WARNING: === $min_gnu_ld_version or later and rebuild GCC." 
>&2;}
+      if test $gnu_ld_version -ge 21200 ; then
         # Globbing fix is present, proper block support is not.
                         { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: === Symbol 
versioning will be disabled." >&5
 $as_echo "$as_me: WARNING: === Symbol versioning will be disabled." >&2;}
@@ -16472,6 +16449,49 @@ $as_echo "$as_me: WARNING: === Symbol versioning will be 
disabled." >&2;}
     enable_symvers=no
   fi
 fi
+if test $enable_symvers = gnu; then
+
+$as_echo "#define GNU_SYMBOL_VERSIONING 1" >>confdefs.h
+
+fi
+
+if test x$enable_symvers != xno ; 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*)
+       ;;
+     # Other platforms with GNU symbol versioning (GNU/Linux, more?) do.
+     *)
+
+$as_echo "#define HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT 1" >>confdefs.h
+
+       ;;
+    esac
+fi
+
+
+
+
+
+
+ # Check whether --enable-symvers was given.
+if test "${enable_symvers+set}" = set; then :
+  enableval=$enable_symvers;
+      case "$enableval" in
+       yes|no|gnu*|sun) ;;
+       *) as_fn_error $? "Unknown argument to enable/disable symvers" 
"$LINENO" 5 ;;
+                          esac
+
+else
+  enable_symvers=yes
+fi
+
+
+
+# If we never went through the CHECK_LINKER_FEATURES macro, then we
+# don't know enough about $LD to do tricks...
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the target supports .symver directive" >&5
 $as_echo_n "checking whether the target supports .symver directive... " >&6; }
@@ -16532,20 +16552,6 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: versioning on shared library symbols is 
$enable_symvers" >&5
 $as_echo "$as_me: versioning on shared library symbols is $enable_symvers" 
>&6;}
-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*)
-       ;;
-     # Other platforms with GNU symbol versioning (GNU/Linux, more?) do.
-     *)
-
-$as_echo "#define HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT 1" >>confdefs.h
-
-       ;;
-    esac
-fi
if test $enable_symvers = gnu; then
--
2.34.1

Reply via email to