diff mbox series

[PR,other/79543] Fix GNU ld --version scanning to conform to the GNU Coding Standards

Message ID 87po9jhz9e.fsf@euler.schwinge.homeip.net
State New
Headers show
Series [PR,other/79543] Fix GNU ld --version scanning to conform to the GNU Coding Standards | expand

Commit Message

Thomas Schwinge Oct. 19, 2017, 4:35 p.m. UTC
Hi!

As discussed in <https://gcc.gnu.org/PR79543>:

| [...] target
| libraries [...] conditionally use certain linker features, depending on linker
| version numbers.  For example, linker version scripts in libgomp; see
| LIBGOMP_BUILD_VERSIONED_SHLIB, LIBGOMP_BUILD_VERSIONED_SHLIB_GNU usage in
| libgomp/Makefile.am, which are defined in libgomp/acinclude.m4 based on the
| enable_symvers value, which is set by some logic depending on "ld --version"
| output.  Looking at one specific build's libgomp/config.log, I see:
| 
|     [...]
|     configure:16132: checking if the linker ([...]/gcc/collect-ld) is GNU ld
|     configure:16147: result: yes
|     [...]
|     configure:16389: WARNING: === Linker version 1125 is too old for
|     configure:16391: WARNING: === full symbol versioning support in this release of GCC.
|     configure:16393: WARNING: === You would need to upgrade your binutils to version
|     configure:16395: WARNING: === 21400 or later and rebuild GCC.
|     configure:16404: WARNING: === Symbol versioning will be disabled.
|     [...]
| 
| Now, what is this "1125" linker version?
| 
|     $ [...]/gcc/collect-ld --version
|     GNU ld (Sourcery CodeBench ([...]) Lite 2015.11-[...]) 2.25.51
| 
| ..., and then apply the "magic" used in libgomp/acinclude.m4 to compute
| libgomp_gnu_ld_version:
| 
|     $ [...]/gcc/collect-ld --version | 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' | awk -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'
|     1125
| 
| "1125" instead of the expected "22551".  That's pretty weird, and I suppose it
| may be causing all kinds of "interesting" issues, when using a linker that has
| been configured to override/augment its version string?

Specifically, it's the additional set of nested parens that is confusing
the sed command.

| Joseph told me that "the correct logic for finding the version number is to
| take everything after the last space on the first line of the output, as per
| the GNU Coding Standards.

See here:
<https://www.gnu.org/prep/standards/html_node/_002d_002dversion.html>:
"[...] the version number proper starts after the last space.  [...]"

| (It's possible some very old binutils versions may
| not have properly formatted output; my view is that each GCC version should
| have a minimum corresponding binutils version, no more than say five years old,
| for targets using GNU binutils.)"

(Agreed.  That's for another day.)

| Yet better, obviously, would be to not rely on such version-based decisions at
| all.

(That, too.)

| (Hopefully, similar parsing is not also being done for "as --version", or other
| tools

(That, too; not verified now.)

| and this was just a one-off problem, possibly originally introduced in
| libstdc++-v3/acinclude.m4, 15 years ago, and the copied from there to other
| target libraries?  I haven't looked in detail.)

(Also, I don't know what the GNU Conding Standards described, 15 years
ago.)


| (For reference, this is the root cause for the issue reported in
| <http://mid.mail-archive.com/6351bfaf-d64e-5f73-9749-78b469dba5fa@mentor.com>.)

In addition to that libgomp example, the problem can be observed for
libstdc++ in the following existing test cases
libgomp.oacc-c++/../libgomp.oacc-c-c++-common/context-1.c,
libgomp.oacc-c++/../libgomp.oacc-c-c++-common/context-2.c,
libgomp.oacc-c++/../libgomp.oacc-c-c++-common/context-3.c,
libgomp.oacc-c++/../libgomp.oacc-c-c++-common/context-4.c, and
libgomp.oacc-c++/../libgomp.oacc-c-c++-common/host_data-1.c.  Trying to
link in cuBLAS (these require a nvptx offloading configuration), these
FAIL to compile:

    /usr/lib/x86_64-linux-gnu/libcublas.so: undefined reference to `operator delete[](void*)@GLIBCXX_3.4'
    /usr/lib/x86_64-linux-gnu/libcublas.so: undefined reference to `operator new[](unsigned long)@GLIBCXX_3.4'


Applying the following patch (that is, simplying the sed command), makes
the problem go away:

    -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'`
    +sed -e 's/GNU gold /GNU ld /;s/GNU ld .* \(.*\)/\1/; q'`

In one specific build, this causes the following changes:

    x86_64-none-linux-gnu/libatomic/config.log:
    
    [...]
    -configure:15071: WARNING: === Linker version 1125 is too old for
    -configure:15073: WARNING: === full symbol versioning support in this release of GCC.
    -configure:15075: WARNING: === You would need to upgrade your binutils to version
    -configure:15077: WARNING: === 21400 or later and rebuild GCC.
    -configure:15086: WARNING: === Symbol versioning will be disabled.
    -configure:15136: versioning on shared library symbols is no
    +configure:15136: versioning on shared library symbols is gnu
    [...]

x86_64-none-linux-gnu/libgomp/config.log:

    [...]
    -configure:16458: WARNING: === Linker version 1125 is too old for
    -configure:16460: WARNING: === full symbol versioning support in this release of GCC.
    -configure:16462: WARNING: === You would need to upgrade your binutils to version
    -configure:16464: WARNING: === 21400 or later and rebuild GCC.
    -configure:16473: WARNING: === Symbol versioning will be disabled.
    [...]
    -configure:16550: versioning on shared library symbols is no
    +configure:16550: versioning on shared library symbols is gnu
    [...]

x86_64-none-linux-gnu/libstdc++-v3/config.log:

    [...]
     configure:53843: checking for ld version
    -configure:53854: result: 1125
    +configure:53854: result: 22551
    +configure:53881: checking for ld that supports -Wl,--gc-sections
    +configure:53899: [...]
    +configure:53899: $? = 0
    +configure:53920: result: yes
    [...]
    -configure:79256: WARNING: === Linker version 1125 is too old for
    -configure:79258: WARNING: === full symbol versioning support in this release of GCC.
    -configure:79260: WARNING: === You would need to upgrade your binutils to version
    -configure:79262: WARNING: === 21400 or later and rebuild GCC.
    -configure:79264: WARNING: === Symbol versioning will be disabled.
    [...]
    -configure:79350: versioning on shared library symbols is no
    +configure:79350: versioning on shared library symbols is gnu
    [...]
    +configure:80758: checking for first version to support std::exception_ptr
    +configure:80795: result: 4.6.0
    [...]

x86_64-none-linux-gnu/libstdc++-v3/Makefile:

     SECTION_FLAGS = -ffunction-sections -fdata-sections
    -SECTION_LDFLAGS = 
    +SECTION_LDFLAGS = -Wl,--gc-sections 

    -SYMVER_FILE = config/abi/pre/none.ver
    +SYMVER_FILE = config/abi/pre/gnu.ver

x86_64-none-linux-gnu/libstdc++-v3/config.h:

     /* Define to 1 if GCC 4.6 supported std::exception_ptr for the target */
    -/* #undef HAVE_EXCEPTION_PTR_SINCE_GCC46 */
    +#define HAVE_EXCEPTION_PTR_SINCE_GCC46 1
     
     /* Define to 1 if you have the <execinfo.h> header file. */
     #define HAVE_EXECINFO_H 1
    @@ -405,7 +405,7 @@
     
     /* Define to 1 if the target runtime linker supports binding the same symbol
        to different versions. */
    -/* #undef HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT */
    +#define HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT 1
     
     /* Define to 1 if you have the <sys/filio.h> header file. */
     /* #undef HAVE_SYS_FILIO_H */
    @@ -842,13 +842,13 @@
     #define _GLIBCXX_STDIO_SEEK_END 2
     
     /* Define to use symbol versioning in the shared library. */
    -/* #undef _GLIBCXX_SYMVER */
    +#define _GLIBCXX_SYMVER 1
     
     /* Define to use darwin versioning in the shared library. */
     /* #undef _GLIBCXX_SYMVER_DARWIN */
     
     /* Define to use GNU versioning in the shared library. */
    -/* #undef _GLIBCXX_SYMVER_GNU */
    +#define _GLIBCXX_SYMVER_GNU 1
     
     /* Define to use GNU namespace versioning in the shared library. */
     /* #undef _GLIBCXX_SYMVER_GNU_NAMESPACE */

Pending testing, I propose to commit the following patch to trunk, and
similar for gcc-7-branch, and gcc-6-branch.  If approving this, please
respond with "Reviewed-by: NAME <EMAIL>" so that your effort will be
recorded.  See <https://gcc.gnu.org/wiki/Reviewed-by>.

commit 9f6652fe67efbde9da3ac74e81acc7776fc6a8e6
Author: Thomas Schwinge <thomas@codesourcery.com>
Date:   Wed Oct 18 15:24:46 2017 +0200

    [PR other/79543] Fix GNU ld --version scanning to conform to the GNU Coding Standards
    
            libatomic/
            PR other/79543
            * acinclude.m4 (LIBAT_CHECK_LINKER_FEATURES): Fix GNU ld --version
            scanning to conform to the GNU Coding Standards.
            * configure: Regenerate.
            libffi/
            PR other/79543
            * acinclude.m4 (LIBAT_CHECK_LINKER_FEATURES): Fix GNU ld --version
            scanning to conform to the GNU Coding Standards.
            * configure: Regenerate.
            libgomp/
            PR other/79543
            * acinclude.m4 (LIBGOMP_CHECK_LINKER_FEATURES): Fix GNU ld
            --version scanning to conform to the GNU Coding Standards.
            * configure: Regenerate.
            libitm/
            PR other/79543
            * acinclude.m4 (LIBITM_CHECK_LINKER_FEATURES): Fix GNU ld
            --version scanning to conform to the GNU Coding Standards.
            * configure: Regenerate.
            libstdc++-v3/
            PR other/79543
            * acinclude.m4 (GLIBCXX_CHECK_LINKER_FEATURES): Fix GNU ld
            --version scanning to conform to the GNU Coding Standards.
            * configure: Regenerate.
---
 libatomic/acinclude.m4    |  4 ++--
 libatomic/configure       |  2 +-
 libffi/acinclude.m4       |  4 ++--
 libffi/configure          |  2 +-
 libgomp/acinclude.m4      |  2 +-
 libgomp/configure         |  2 +-
 libitm/acinclude.m4       |  2 +-
 libitm/configure          |  2 +-
 libstdc++-v3/acinclude.m4 |  2 +-
 libstdc++-v3/configure    | 22 +++++++++++-----------
 10 files changed, 22 insertions(+), 22 deletions(-)



Grüße
 Thomas

Comments

Joseph Myers Oct. 31, 2017, 12:17 a.m. UTC | #1
On Thu, 19 Oct 2017, Thomas Schwinge wrote:

> | (It's possible some very old binutils versions may
> | not have properly formatted output; my view is that each GCC version should
> | have a minimum corresponding binutils version, no more than say five years old,
> | for targets using GNU binutils.)"
> 
> (Agreed.  That's for another day.)

Specifically, *non-release* versions of binutils predating my patch

commit 066c2a57f5858310c9f12518317aecd4b54e753d
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Thu Mar 1 15:48:36 2007 +0000

would have had a space between the binutils version number and the BFD 
datestamp and the end of the first line of --version output.  That would 
not have been an issue for release versions, and the stray word "version" 
before the version number before that patch would not cause problems for 
the simplified sed expressions.

> Applying the following patch (that is, simplying the sed command), makes
> the problem go away:
> 
>     -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'`
>     +sed -e 's/GNU gold /GNU ld /;s/GNU ld .* \(.*\)/\1/; q'`

While I think working properly for binutils versions in the past ten years 
matters more than any issues with old non-release versions that probably 
wouldn't work with current GCC anyway, it seems to me that this patch 
would require *something* surrounded by spaces between "GNU ld" and the 
version number.  If you configure with --without-pkgversion, you get e.g.

GNU ld 2.28

as the complete first line of the output, and that doesn't look like it 
would match the above pattern, as there's only one space not two between 
"GNU ld" and the version number.  So I think you need a pattern that does 
allow the --without-pkgversion form of output.
Chung-Lin Tang July 4, 2019, 8:28 a.m. UTC | #2
On 2017/10/31 8:17 AM, Joseph Myers wrote:
> Specifically,*non-release*  versions of binutils predating my patch
> 
> commit 066c2a57f5858310c9f12518317aecd4b54e753d
> Author: Joseph Myers<joseph@codesourcery.com>
> Date:   Thu Mar 1 15:48:36 2007 +0000
> 
> would have had a space between the binutils version number and the BFD
> datestamp and the end of the first line of --version output.  That would
> not have been an issue for release versions, and the stray word "version"
> before the version number before that patch would not cause problems for
> the simplified sed expressions.
> 
>> Applying the following patch (that is, simplying the sed command), makes
>> the problem go away:
>>
>>      -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'`
>>      +sed -e 's/GNU gold /GNU ld /;s/GNU ld .* \(.*\)/\1/; q'`
> While I think working properly for binutils versions in the past ten years
> matters more than any issues with old non-release versions that probably
> wouldn't work with current GCC anyway, it seems to me that this patch
> would require*something*  surrounded by spaces between "GNU ld" and the
> version number.  If you configure with --without-pkgversion, you get e.g.
> 
> GNU ld 2.28
> 
> as the complete first line of the output, and that doesn't look like it
> would match the above pattern, as there's only one space not two between
> "GNU ld" and the version number.  So I think you need a pattern that does
> allow the --without-pkgversion form of output.

Bringing back this issue, as this is still bothering our OpenACC toolchains.

If the main variance in format was the 2007 ' ' to '.' change for non-release
binutils builds, then is the attached patch okay?

What the patch does is to first look for an 8-digit part at the end
(preceded by either a space or '.'), chop it off if it exists, and then take the last
space-preceded string.

This matching logic does appear to be more reliant on the aforementioned
GNU standard of 'everything after the last space on the first line of the output'.
OTOH, not sure if all the testing for GNU gold, GNU ld, etc. in the current
sed pattern means much since this is already under $with_gnu_ld=yes.

(seeking approval for trunk and all active release branches)

Thanks,
Chung-Lin

2019-07-04  Chung-Lin Tang <cltang@codesourcery.com>

         libatomic/
         PR other/79543
         * acinclude.m4 (LIBAT_CHECK_LINKER_FEATURES): Fix GNU ld --version
         scanning to conform to the GNU Coding Standards.
         * configure: Regenerate.

         libffi/
         PR other/79543
         * acinclude.m4 (LIBAT_CHECK_LINKER_FEATURES): Fix GNU ld --version
         scanning to conform to the GNU Coding Standards.
         * configure: Regenerate.

         libgomp/
         PR other/79543
         * acinclude.m4 (LIBGOMP_CHECK_LINKER_FEATURES): Fix GNU ld --version
         scanning to conform to the GNU Coding Standards.
         * configure: Regenerate.

         libitm/
         PR other/79543
         * acinclude.m4 (LIBITM_CHECK_LINKER_FEATURES): Fix GNU ld --version
         scanning to conform to the GNU Coding Standards.
         * configure: Regenerate.

         libstdc++-v3/
         PR other/79543
         * acinclude.m4 (GLIBCXX_CHECK_LINKER_FEATURES): Fix GNU ld --version
         scanning to conform to the GNU Coding Standards.
         * configure: Regenerate.
Index: libatomic/acinclude.m4
===================================================================
--- libatomic/acinclude.m4	(revision 273041)
+++ libatomic/acinclude.m4	(working copy)
@@ -336,7 +336,7 @@ AC_DEFUN([LIBAT_CHECK_LINKER_FEATURES], [
   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'`
+         sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\+\)$/\1/; q'`
   changequote([,])
   libat_gnu_ld_version=`echo $ldver | \
          $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
@@ -438,7 +438,7 @@ AC_DEFUN([LIBAT_CHECK_LINKER_FEATURES], [
   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'`
+         sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\+\)$/\1/; q'`
   changequote([,])
   libat_gnu_ld_version=`echo $ldver | \
          $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
Index: libatomic/configure
===================================================================
--- libatomic/configure	(revision 273041)
+++ libatomic/configure	(working copy)
@@ -15177,7 +15177,7 @@ with_gnu_ld=$lt_cv_prog_gnu_ld
   fi
 
   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'`
+         sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\+\)$/\1/; q'`
 
   libat_gnu_ld_version=`echo $ldver | \
          $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
Index: libffi/acinclude.m4
===================================================================
--- libffi/acinclude.m4	(revision 273041)
+++ libffi/acinclude.m4	(working copy)
@@ -178,7 +178,7 @@ AC_DEFUN([LIBAT_CHECK_LINKER_FEATURES], [
   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'`
+         sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\+\)$/\1/; q'`
   changequote([,])
   libat_gnu_ld_version=`echo $ldver | \
          $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
@@ -280,7 +280,7 @@ AC_DEFUN([LIBAT_CHECK_LINKER_FEATURES], [
   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'`
+         sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\+\)$/\1/; q'`
   changequote([,])
   libat_gnu_ld_version=`echo $ldver | \
          $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
Index: libffi/configure
===================================================================
--- libffi/configure	(revision 273041)
+++ libffi/configure	(working copy)
@@ -16332,7 +16332,7 @@ with_gnu_ld=$lt_cv_prog_gnu_ld
   fi
 
   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'`
+         sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\+\)$/\1/; q'`
 
   libat_gnu_ld_version=`echo $ldver | \
          $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
Index: libgomp/acinclude.m4
===================================================================
--- libgomp/acinclude.m4	(revision 273041)
+++ libgomp/acinclude.m4	(working copy)
@@ -154,7 +154,7 @@ AC_DEFUN([LIBGOMP_CHECK_LINKER_FEATURES], [
   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'`
+         sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\+\)$/\1/; q'`
   changequote([,])
   libgomp_gnu_ld_version=`echo $ldver | \
          $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
Index: libgomp/configure
===================================================================
--- libgomp/configure	(revision 273041)
+++ libgomp/configure	(working copy)
@@ -16587,7 +16587,7 @@ with_gnu_ld=$lt_cv_prog_gnu_ld
   fi
 
   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'`
+         sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\+\)$/\1/; q'`
 
   libgomp_gnu_ld_version=`echo $ldver | \
          $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
Index: libitm/acinclude.m4
===================================================================
--- libitm/acinclude.m4	(revision 273041)
+++ libitm/acinclude.m4	(working copy)
@@ -247,7 +247,7 @@ AC_DEFUN([LIBITM_CHECK_LINKER_FEATURES], [
   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'`
+         sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\+\)$/\1/; q'`
   changequote([,])
   libitm_gnu_ld_version=`echo $ldver | \
          $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
Index: libitm/configure
===================================================================
--- libitm/configure	(revision 273041)
+++ libitm/configure	(working copy)
@@ -17059,7 +17059,7 @@ fi
   fi
 
   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'`
+         sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\+\)$/\1/; q'`
 
   libitm_gnu_ld_version=`echo $ldver | \
          $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
Index: libstdc++-v3/acinclude.m4
===================================================================
--- libstdc++-v3/acinclude.m4	(revision 273041)
+++ libstdc++-v3/acinclude.m4	(working copy)
@@ -211,7 +211,7 @@ AC_DEFUN([GLIBCXX_CHECK_LINKER_FEATURES], [
       glibcxx_ld_is_gold=yes
     fi
     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'`
+	   sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\+\)$/\1/; q'`
     changequote([,])
     glibcxx_gnu_ld_version=`echo $ldver | \
 	   $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
Index: libstdc++-v3/configure
===================================================================
--- libstdc++-v3/configure	(revision 273041)
+++ libstdc++-v3/configure	(working copy)
@@ -22294,7 +22294,7 @@ $as_echo_n "checking for ld version... " >&6; }
       glibcxx_ld_is_gold=yes
     fi
     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'`
+	   sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\+\)$/\1/; q'`
 
     glibcxx_gnu_ld_version=`echo $ldver | \
 	   $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
@@ -29461,7 +29461,7 @@ $as_echo_n "checking for ld version... " >&6; }
       glibcxx_ld_is_gold=yes
     fi
     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'`
+	   sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\+\)$/\1/; q'`
 
     glibcxx_gnu_ld_version=`echo $ldver | \
 	   $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
@@ -35439,7 +35439,7 @@ $as_echo_n "checking for ld version... " >&6; }
       glibcxx_ld_is_gold=yes
     fi
     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'`
+	   sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\+\)$/\1/; q'`
 
     glibcxx_gnu_ld_version=`echo $ldver | \
 	   $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
@@ -41551,7 +41551,7 @@ $as_echo_n "checking for ld version... " >&6; }
       glibcxx_ld_is_gold=yes
     fi
     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'`
+	   sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\+\)$/\1/; q'`
 
     glibcxx_gnu_ld_version=`echo $ldver | \
 	   $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
@@ -53458,7 +53458,7 @@ $as_echo_n "checking for ld version... " >&6; }
       glibcxx_ld_is_gold=yes
     fi
     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'`
+	   sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\+\)$/\1/; q'`
 
     glibcxx_gnu_ld_version=`echo $ldver | \
 	   $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
@@ -53723,7 +53723,7 @@ $as_echo_n "checking for ld version... " >&6; }
       glibcxx_ld_is_gold=yes
     fi
     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'`
+	   sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\+\)$/\1/; q'`
 
     glibcxx_gnu_ld_version=`echo $ldver | \
 	   $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
@@ -54190,7 +54190,7 @@ $as_echo_n "checking for ld version... " >&6; }
       glibcxx_ld_is_gold=yes
     fi
     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'`
+	   sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\+\)$/\1/; q'`
 
     glibcxx_gnu_ld_version=`echo $ldver | \
 	   $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
@@ -60558,7 +60558,7 @@ $as_echo_n "checking for ld version... " >&6; }
       glibcxx_ld_is_gold=yes
     fi
     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'`
+	   sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\+\)$/\1/; q'`
 
     glibcxx_gnu_ld_version=`echo $ldver | \
 	   $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
@@ -66489,7 +66489,7 @@ $as_echo_n "checking for ld version... " >&6; }
       glibcxx_ld_is_gold=yes
     fi
     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'`
+	   sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\+\)$/\1/; q'`
 
     glibcxx_gnu_ld_version=`echo $ldver | \
 	   $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
@@ -66690,7 +66690,7 @@ $as_echo_n "checking for ld version... " >&6; }
       glibcxx_ld_is_gold=yes
     fi
     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'`
+	   sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\+\)$/\1/; q'`
 
     glibcxx_gnu_ld_version=`echo $ldver | \
 	   $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
@@ -66910,7 +66910,7 @@ $as_echo_n "checking for ld version... " >&6; }
       glibcxx_ld_is_gold=yes
     fi
     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'`
+	   sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\+\)$/\1/; q'`
 
     glibcxx_gnu_ld_version=`echo $ldver | \
 	   $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
Chung-Lin Tang July 16, 2019, 2:27 p.m. UTC | #3
Ping.
(I think Joseph happens to be out, was wondering if any build maintainer or global reviewer can take a look?)

Thanks,
Chung-Lin

On 2019/7/4 4:28 PM, Chung-Lin Tang wrote:
> On 2017/10/31 8:17 AM, Joseph Myers wrote:
>> Specifically,*non-release*  versions of binutils predating my patch
>>
>> commit 066c2a57f5858310c9f12518317aecd4b54e753d
>> Author: Joseph Myers<joseph@codesourcery.com>
>> Date:   Thu Mar 1 15:48:36 2007 +0000
>>
>> would have had a space between the binutils version number and the BFD
>> datestamp and the end of the first line of --version output.  That would
>> not have been an issue for release versions, and the stray word "version"
>> before the version number before that patch would not cause problems for
>> the simplified sed expressions.
>>
>>> Applying the following patch (that is, simplying the sed command), makes
>>> the problem go away:
>>>
>>>      -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'`
>>>      +sed -e 's/GNU gold /GNU ld /;s/GNU ld .* \(.*\)/\1/; q'`
>> While I think working properly for binutils versions in the past ten years
>> matters more than any issues with old non-release versions that probably
>> wouldn't work with current GCC anyway, it seems to me that this patch
>> would require*something*  surrounded by spaces between "GNU ld" and the
>> version number.  If you configure with --without-pkgversion, you get e.g.
>>
>> GNU ld 2.28
>>
>> as the complete first line of the output, and that doesn't look like it
>> would match the above pattern, as there's only one space not two between
>> "GNU ld" and the version number.  So I think you need a pattern that does
>> allow the --without-pkgversion form of output.
> 
> Bringing back this issue, as this is still bothering our OpenACC toolchains.
> 
> If the main variance in format was the 2007 ' ' to '.' change for non-release
> binutils builds, then is the attached patch okay?
> 
> What the patch does is to first look for an 8-digit part at the end
> (preceded by either a space or '.'), chop it off if it exists, and then take the last
> space-preceded string.
> 
> This matching logic does appear to be more reliant on the aforementioned
> GNU standard of 'everything after the last space on the first line of the output'.
> OTOH, not sure if all the testing for GNU gold, GNU ld, etc. in the current
> sed pattern means much since this is already under $with_gnu_ld=yes.
> 
> (seeking approval for trunk and all active release branches)
> 
> Thanks,
> Chung-Lin
> 
> 2019-07-04  Chung-Lin Tang <cltang@codesourcery.com>
> 
>          libatomic/
>          PR other/79543
>          * acinclude.m4 (LIBAT_CHECK_LINKER_FEATURES): Fix GNU ld --version
>          scanning to conform to the GNU Coding Standards.
>          * configure: Regenerate.
> 
>          libffi/
>          PR other/79543
>          * acinclude.m4 (LIBAT_CHECK_LINKER_FEATURES): Fix GNU ld --version
>          scanning to conform to the GNU Coding Standards.
>          * configure: Regenerate.
> 
>          libgomp/
>          PR other/79543
>          * acinclude.m4 (LIBGOMP_CHECK_LINKER_FEATURES): Fix GNU ld --version
>          scanning to conform to the GNU Coding Standards.
>          * configure: Regenerate.
> 
>          libitm/
>          PR other/79543
>          * acinclude.m4 (LIBITM_CHECK_LINKER_FEATURES): Fix GNU ld --version
>          scanning to conform to the GNU Coding Standards.
>          * configure: Regenerate.
> 
>          libstdc++-v3/
>          PR other/79543
>          * acinclude.m4 (GLIBCXX_CHECK_LINKER_FEATURES): Fix GNU ld --version
>          scanning to conform to the GNU Coding Standards.
>          * configure: Regenerate.
Chung-Lin Tang July 16, 2019, 3:01 p.m. UTC | #4
This patch has been committed ahead to openacc-gcc-9-branch [OG9],
we will revert and adjust in case the patch is not approved for trunk later.

Chung-Lin

On 2019/7/16 10:27 PM, Chung-Lin Tang wrote:
> 2019-07-04  Chung-Lin Tang <cltang@codesourcery.com>
> 
>           libatomic/
>           PR other/79543
>           * acinclude.m4 (LIBAT_CHECK_LINKER_FEATURES): Fix GNU ld --version
>           scanning to conform to the GNU Coding Standards.
>           * configure: Regenerate.
> 
>           libffi/
>           PR other/79543
>           * acinclude.m4 (LIBAT_CHECK_LINKER_FEATURES): Fix GNU ld --version
>           scanning to conform to the GNU Coding Standards.
>           * configure: Regenerate.
> 
>           libgomp/
>           PR other/79543
>           * acinclude.m4 (LIBGOMP_CHECK_LINKER_FEATURES): Fix GNU ld --version
>           scanning to conform to the GNU Coding Standards.
>           * configure: Regenerate.
> 
>           libitm/
>           PR other/79543
>           * acinclude.m4 (LIBITM_CHECK_LINKER_FEATURES): Fix GNU ld --version
>           scanning to conform to the GNU Coding Standards.
>           * configure: Regenerate.
> 
>           libstdc++-v3/
>           PR other/79543
>           * acinclude.m4 (GLIBCXX_CHECK_LINKER_FEATURES): Fix GNU ld --version
>           scanning to conform to the GNU Coding Standards.
>           * configure: Regenerate.
Joseph Myers Aug. 13, 2019, 5:16 p.m. UTC | #5
On Thu, 4 Jul 2019, Chung-Lin Tang wrote:

> Bringing back this issue, as this is still bothering our OpenACC toolchains.
> 
> If the main variance in format was the 2007 ' ' to '.' change for non-release
> binutils builds, then is the attached patch okay?
> 
> What the patch does is to first look for an 8-digit part at the end
> (preceded by either a space or '.'), chop it off if it exists, and then take
> the last
> space-preceded string.

This patch is using \+ with sed, which is a GNU extension rather than part 
of POSIX sed.  I don't think we require GNU sed to build GCC.

The patch is OK for trunk with \+ changed to \{1,\} throughout (presuming 
that does indeed work).

However, I strongly encourage a followup to refactor this code 
(*_CHECK_LINKER_FEATURES and *_ENABLE_SYMVERS that use it, not just the 
fragment that determines the linker version number), which is evidently 
duplicated far too much in different target library directories, into 
common macros in a .m4 file in the top-level config/ directory, so it's 
more maintainable in future.  (Note 1: I don't know what differences there 
might be between the versions in different directories; that would need 
investigating as part of such a refactoring; differences need not be 
deliberate, they could easily have arisen by accident.  Note 2: although 
libffi is maintained outside of GCC, I think such a refactoring should 
still be applied to the libffi directory along with the others; standalone 
libffi would simply need its own copy of the relevant .m4 file.  Note 3: 
it should be possible to do such a refactoring bit by bit if that's more 
approachable, rather than necessarily doing a complete refactoring of all 
the definitions of all these macros at once.)

> (seeking approval for trunk and all active release branches)

For release branches you should at least wait a few weeks to see if any 
issues show up on trunk.
Rainer Orth Aug. 13, 2019, 5:33 p.m. UTC | #6
Hi Joseph,

> However, I strongly encourage a followup to refactor this code 
> (*_CHECK_LINKER_FEATURES and *_ENABLE_SYMVERS that use it, not just the 
> fragment that determines the linker version number), which is evidently 
> duplicated far too much in different target library directories, into 
> common macros in a .m4 file in the top-level config/ directory, so it's 
> more maintainable in future.  (Note 1: I don't know what differences there 
> might be between the versions in different directories; that would need 
> investigating as part of such a refactoring; differences need not be 
> deliberate, they could easily have arisen by accident.  Note 2: although 
> libffi is maintained outside of GCC, I think such a refactoring should 
> still be applied to the libffi directory along with the others; standalone 
> libffi would simply need its own copy of the relevant .m4 file.  Note 3: 
> it should be possible to do such a refactoring bit by bit if that's more 
> approachable, rather than necessarily doing a complete refactoring of all 
> the definitions of all these macros at once.)

as it happens, I've been working on exactly this.  I'd noticed that
*_CHECK_LINKER_FEATURES enabled --gc-sections only with gld although
recent Solaris ld supports it as well.  What's worse, even with gld the
option is detected and used only for some of the libraries due to
inconsistencies between the different versions of the macro.

I'd meant to unify *_ENABLE_SYMVERS for a long time and this seemed the
perfect opportunity to do so, among others because several libs require
it from *_CHECK_LINKER_FEATURES to get the linker version info ;-(

On top of that, there are many different copies of the code that handles
--enable-version-specific-runtime-libs, sets toolexeclibdir and
--enable-generated-files-in-srcdir, as well as several instances of
*_CHECK_ATTRIBUTE_ALIAS, *_CHECK_ATTRIBUTE_DLLEXPORT, and
*_CHECK_ATTRIBUTE_VISIBILITY, and probably more that I've missed so
far.  Overall, we've created an incredible mess here, and I'm probably
partially responsible at least for the *_ENABLE_SYMVERS part.

	Rainer
Chung-Lin Tang Sept. 3, 2019, 2:10 p.m. UTC | #7
On 2019/8/14 1:16 AM, Joseph Myers wrote:
> On Thu, 4 Jul 2019, Chung-Lin Tang wrote:
> 
>> Bringing back this issue, as this is still bothering our OpenACC toolchains.
>>
>> If the main variance in format was the 2007 ' ' to '.' change for non-release
>> binutils builds, then is the attached patch okay?
>>
>> What the patch does is to first look for an 8-digit part at the end
>> (preceded by either a space or '.'), chop it off if it exists, and then take
>> the last
>> space-preceded string.
> 
> This patch is using \+ with sed, which is a GNU extension rather than part
> of POSIX sed.  I don't think we require GNU sed to build GCC.
> 
> The patch is OK for trunk with \+ changed to \{1,\} throughout (presuming
> that does indeed work).

I have tested and indeed \{1,\} works the same. I have committed the attached
updated patch to trunk.

> However, I strongly encourage a followup to refactor this code
> (*_CHECK_LINKER_FEATURES and *_ENABLE_SYMVERS that use it, not just the
> fragment that determines the linker version number), which is evidently
> duplicated far too much in different target library directories, into
> common macros in a .m4 file in the top-level config/ directory, so it's
> more maintainable in future.  (Note 1: I don't know what differences there
> might be between the versions in different directories; that would need
> investigating as part of such a refactoring; differences need not be
> deliberate, they could easily have arisen by accident.  Note 2: although
> libffi is maintained outside of GCC, I think such a refactoring should
> still be applied to the libffi directory along with the others; standalone
> libffi would simply need its own copy of the relevant .m4 file.  Note 3:
> it should be possible to do such a refactoring bit by bit if that's more
> approachable, rather than necessarily doing a complete refactoring of all
> the definitions of all these macros at once.)

This is much larger scale follow up work, for another day...

>> (seeking approval for trunk and all active release branches)
> 
> For release branches you should at least wait a few weeks to see if any
> issues show up on trunk.

Sure, will wait for a while before applying to release branches.

Thanks,
Chung-Lin
Index: libatomic/acinclude.m4
===================================================================
--- libatomic/acinclude.m4	(revision 275340)
+++ libatomic/acinclude.m4	(working copy)
@@ -336,7 +336,7 @@ AC_DEFUN([LIBAT_CHECK_LINKER_FEATURES], [
   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'`
+         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 }'`
@@ -438,7 +438,7 @@ AC_DEFUN([LIBAT_CHECK_LINKER_FEATURES], [
   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'`
+         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 }'`
Index: libatomic/configure
===================================================================
--- libatomic/configure	(revision 275340)
+++ libatomic/configure	(working copy)
@@ -15177,7 +15177,7 @@ with_gnu_ld=$lt_cv_prog_gnu_ld
   fi
 
   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'`
+         sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
 
   libat_gnu_ld_version=`echo $ldver | \
          $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
Index: libffi/acinclude.m4
===================================================================
--- libffi/acinclude.m4	(revision 275340)
+++ libffi/acinclude.m4	(working copy)
@@ -178,7 +178,7 @@ AC_DEFUN([LIBAT_CHECK_LINKER_FEATURES], [
   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'`
+         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 }'`
@@ -280,7 +280,7 @@ AC_DEFUN([LIBAT_CHECK_LINKER_FEATURES], [
   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'`
+         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 }'`
Index: libffi/configure
===================================================================
--- libffi/configure	(revision 275340)
+++ libffi/configure	(working copy)
@@ -16332,7 +16332,7 @@ with_gnu_ld=$lt_cv_prog_gnu_ld
   fi
 
   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'`
+         sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
 
   libat_gnu_ld_version=`echo $ldver | \
          $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
Index: libgomp/acinclude.m4
===================================================================
--- libgomp/acinclude.m4	(revision 275340)
+++ libgomp/acinclude.m4	(working copy)
@@ -154,7 +154,7 @@ AC_DEFUN([LIBGOMP_CHECK_LINKER_FEATURES], [
   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'`
+         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 }'`
Index: libgomp/configure
===================================================================
--- libgomp/configure	(revision 275340)
+++ libgomp/configure	(working copy)
@@ -16587,7 +16587,7 @@ with_gnu_ld=$lt_cv_prog_gnu_ld
   fi
 
   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'`
+         sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
 
   libgomp_gnu_ld_version=`echo $ldver | \
          $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
Index: libitm/acinclude.m4
===================================================================
--- libitm/acinclude.m4	(revision 275340)
+++ libitm/acinclude.m4	(working copy)
@@ -247,7 +247,7 @@ AC_DEFUN([LIBITM_CHECK_LINKER_FEATURES], [
   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'`
+         sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
   changequote([,])
   libitm_gnu_ld_version=`echo $ldver | \
          $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
Index: libitm/configure
===================================================================
--- libitm/configure	(revision 275340)
+++ libitm/configure	(working copy)
@@ -17059,7 +17059,7 @@ fi
   fi
 
   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'`
+         sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
 
   libitm_gnu_ld_version=`echo $ldver | \
          $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
Index: libstdc++-v3/acinclude.m4
===================================================================
--- libstdc++-v3/acinclude.m4	(revision 275340)
+++ libstdc++-v3/acinclude.m4	(working copy)
@@ -211,7 +211,7 @@ AC_DEFUN([GLIBCXX_CHECK_LINKER_FEATURES], [
       glibcxx_ld_is_gold=yes
     fi
     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'`
+	   sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
     changequote([,])
     glibcxx_gnu_ld_version=`echo $ldver | \
 	   $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
Index: libstdc++-v3/configure
===================================================================
--- libstdc++-v3/configure	(revision 275340)
+++ libstdc++-v3/configure	(working copy)
@@ -22294,7 +22294,7 @@ $as_echo_n "checking for ld version... " >&6; }
       glibcxx_ld_is_gold=yes
     fi
     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'`
+	   sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
 
     glibcxx_gnu_ld_version=`echo $ldver | \
 	   $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
@@ -29461,7 +29461,7 @@ $as_echo_n "checking for ld version... " >&6; }
       glibcxx_ld_is_gold=yes
     fi
     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'`
+	   sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
 
     glibcxx_gnu_ld_version=`echo $ldver | \
 	   $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
@@ -35439,7 +35439,7 @@ $as_echo_n "checking for ld version... " >&6; }
       glibcxx_ld_is_gold=yes
     fi
     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'`
+	   sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
 
     glibcxx_gnu_ld_version=`echo $ldver | \
 	   $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
@@ -41551,7 +41551,7 @@ $as_echo_n "checking for ld version... " >&6; }
       glibcxx_ld_is_gold=yes
     fi
     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'`
+	   sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
 
     glibcxx_gnu_ld_version=`echo $ldver | \
 	   $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
@@ -53458,7 +53458,7 @@ $as_echo_n "checking for ld version... " >&6; }
       glibcxx_ld_is_gold=yes
     fi
     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'`
+	   sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
 
     glibcxx_gnu_ld_version=`echo $ldver | \
 	   $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
@@ -53723,7 +53723,7 @@ $as_echo_n "checking for ld version... " >&6; }
       glibcxx_ld_is_gold=yes
     fi
     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'`
+	   sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
 
     glibcxx_gnu_ld_version=`echo $ldver | \
 	   $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
@@ -54190,7 +54190,7 @@ $as_echo_n "checking for ld version... " >&6; }
       glibcxx_ld_is_gold=yes
     fi
     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'`
+	   sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
 
     glibcxx_gnu_ld_version=`echo $ldver | \
 	   $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
@@ -60558,7 +60558,7 @@ $as_echo_n "checking for ld version... " >&6; }
       glibcxx_ld_is_gold=yes
     fi
     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'`
+	   sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
 
     glibcxx_gnu_ld_version=`echo $ldver | \
 	   $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
@@ -66489,7 +66489,7 @@ $as_echo_n "checking for ld version... " >&6; }
       glibcxx_ld_is_gold=yes
     fi
     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'`
+	   sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
 
     glibcxx_gnu_ld_version=`echo $ldver | \
 	   $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
@@ -66690,7 +66690,7 @@ $as_echo_n "checking for ld version... " >&6; }
       glibcxx_ld_is_gold=yes
     fi
     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'`
+	   sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
 
     glibcxx_gnu_ld_version=`echo $ldver | \
 	   $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
@@ -66910,7 +66910,7 @@ $as_echo_n "checking for ld version... " >&6; }
       glibcxx_ld_is_gold=yes
     fi
     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'`
+	   sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
 
     glibcxx_gnu_ld_version=`echo $ldver | \
 	   $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
diff mbox series

Patch

diff --git libatomic/acinclude.m4 libatomic/acinclude.m4
index 383218f..6a3c5c5 100644
--- libatomic/acinclude.m4
+++ libatomic/acinclude.m4
@@ -336,7 +336,7 @@  AC_DEFUN([LIBAT_CHECK_LINKER_FEATURES], [
   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'`
+         sed -e 's/GNU gold /GNU ld /;s/GNU ld .* \(.*\)/\1/; q'`
   changequote([,])
   libat_gnu_ld_version=`echo $ldver | \
          $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
@@ -438,7 +438,7 @@  AC_DEFUN([LIBAT_CHECK_LINKER_FEATURES], [
   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'`
+         sed -e 's/GNU gold /GNU ld /;s/GNU ld .* \(.*\)/\1/; q'`
   changequote([,])
   libat_gnu_ld_version=`echo $ldver | \
          $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
diff --git libatomic/configure libatomic/configure
index e88a7b8..7d47525 100755
--- libatomic/configure
+++ libatomic/configure
@@ -14873,7 +14873,7 @@  with_gnu_ld=$lt_cv_prog_gnu_ld
   fi
 
   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'`
+         sed -e 's/GNU gold /GNU ld /;s/GNU ld .* \(.*\)/\1/; q'`
 
   libat_gnu_ld_version=`echo $ldver | \
          $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
diff --git libffi/acinclude.m4 libffi/acinclude.m4
index 270dadf..0f2c1ea 100644
--- libffi/acinclude.m4
+++ libffi/acinclude.m4
@@ -178,7 +178,7 @@  AC_DEFUN([LIBAT_CHECK_LINKER_FEATURES], [
   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'`
+         sed -e 's/GNU gold /GNU ld /;s/GNU ld .* \(.*\)/\1/; q'`
   changequote([,])
   libat_gnu_ld_version=`echo $ldver | \
          $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
@@ -280,7 +280,7 @@  AC_DEFUN([LIBAT_CHECK_LINKER_FEATURES], [
   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'`
+         sed -e 's/GNU gold /GNU ld /;s/GNU ld .* \(.*\)/\1/; q'`
   changequote([,])
   libat_gnu_ld_version=`echo $ldver | \
          $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
diff --git libffi/configure libffi/configure
index 74b747b..f82fe11 100755
--- libffi/configure
+++ libffi/configure
@@ -16167,7 +16167,7 @@  with_gnu_ld=$lt_cv_prog_gnu_ld
   fi
 
   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'`
+         sed -e 's/GNU gold /GNU ld /;s/GNU ld .* \(.*\)/\1/; q'`
 
   libat_gnu_ld_version=`echo $ldver | \
          $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
diff --git libgomp/acinclude.m4 libgomp/acinclude.m4
index d43aa88..d9d9da8 100644
--- libgomp/acinclude.m4
+++ libgomp/acinclude.m4
@@ -153,7 +153,7 @@  AC_DEFUN([LIBGOMP_CHECK_LINKER_FEATURES], [
   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'`
+         sed -e 's/GNU gold /GNU ld /;s/GNU ld .* \(.*\)/\1/; q'`
   changequote([,])
   libgomp_gnu_ld_version=`echo $ldver | \
          $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
diff --git libgomp/configure libgomp/configure
index b7e9f40..efcf3f5 100755
--- libgomp/configure
+++ libgomp/configure
@@ -16256,7 +16256,7 @@  with_gnu_ld=$lt_cv_prog_gnu_ld
   fi
 
   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'`
+         sed -e 's/GNU gold /GNU ld /;s/GNU ld .* \(.*\)/\1/; q'`
 
   libgomp_gnu_ld_version=`echo $ldver | \
          $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
diff --git libitm/acinclude.m4 libitm/acinclude.m4
index c81b3e9..7c26756 100644
--- libitm/acinclude.m4
+++ libitm/acinclude.m4
@@ -246,7 +246,7 @@  AC_DEFUN([LIBITM_CHECK_LINKER_FEATURES], [
   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'`
+         sed -e 's/GNU gold /GNU ld /;s/GNU ld .* \(.*\)/\1/; q'`
   changequote([,])
   libitm_gnu_ld_version=`echo $ldver | \
          $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
diff --git libitm/configure libitm/configure
index 775f370..1ce18fd 100644
--- libitm/configure
+++ libitm/configure
@@ -16828,7 +16828,7 @@  fi
   fi
 
   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'`
+         sed -e 's/GNU gold /GNU ld /;s/GNU ld .* \(.*\)/\1/; q'`
 
   libitm_gnu_ld_version=`echo $ldver | \
          $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
diff --git libstdc++-v3/acinclude.m4 libstdc++-v3/acinclude.m4
index 599308f..e4a64ce 100644
--- libstdc++-v3/acinclude.m4
+++ libstdc++-v3/acinclude.m4
@@ -219,7 +219,7 @@  AC_DEFUN([GLIBCXX_CHECK_LINKER_FEATURES], [
       glibcxx_ld_is_gold=yes
     fi
     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'`
+	   sed -e 's/GNU gold /GNU ld /;s/GNU ld .* \(.*\)/\1/; q'`
     changequote([,])
     glibcxx_gnu_ld_version=`echo $ldver | \
 	   $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
diff --git libstdc++-v3/configure libstdc++-v3/configure
index 836a6d5..ece031d 100755
--- libstdc++-v3/configure
+++ libstdc++-v3/configure
@@ -21961,7 +21961,7 @@  $as_echo_n "checking for ld version... " >&6; }
       glibcxx_ld_is_gold=yes
     fi
     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'`
+	   sed -e 's/GNU gold /GNU ld /;s/GNU ld .* \(.*\)/\1/; q'`
 
     glibcxx_gnu_ld_version=`echo $ldver | \
 	   $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
@@ -29106,7 +29106,7 @@  $as_echo_n "checking for ld version... " >&6; }
       glibcxx_ld_is_gold=yes
     fi
     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'`
+	   sed -e 's/GNU gold /GNU ld /;s/GNU ld .* \(.*\)/\1/; q'`
 
     glibcxx_gnu_ld_version=`echo $ldver | \
 	   $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
@@ -35100,7 +35100,7 @@  $as_echo_n "checking for ld version... " >&6; }
       glibcxx_ld_is_gold=yes
     fi
     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'`
+	   sed -e 's/GNU gold /GNU ld /;s/GNU ld .* \(.*\)/\1/; q'`
 
     glibcxx_gnu_ld_version=`echo $ldver | \
 	   $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
@@ -41220,7 +41220,7 @@  $as_echo_n "checking for ld version... " >&6; }
       glibcxx_ld_is_gold=yes
     fi
     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'`
+	   sed -e 's/GNU gold /GNU ld /;s/GNU ld .* \(.*\)/\1/; q'`
 
     glibcxx_gnu_ld_version=`echo $ldver | \
 	   $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
@@ -53141,7 +53141,7 @@  $as_echo_n "checking for ld version... " >&6; }
       glibcxx_ld_is_gold=yes
     fi
     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'`
+	   sed -e 's/GNU gold /GNU ld /;s/GNU ld .* \(.*\)/\1/; q'`
 
     glibcxx_gnu_ld_version=`echo $ldver | \
 	   $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
@@ -53372,7 +53372,7 @@  $as_echo_n "checking for ld version... " >&6; }
       glibcxx_ld_is_gold=yes
     fi
     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'`
+	   sed -e 's/GNU gold /GNU ld /;s/GNU ld .* \(.*\)/\1/; q'`
 
     glibcxx_gnu_ld_version=`echo $ldver | \
 	   $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
@@ -53847,7 +53847,7 @@  $as_echo_n "checking for ld version... " >&6; }
       glibcxx_ld_is_gold=yes
     fi
     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'`
+	   sed -e 's/GNU gold /GNU ld /;s/GNU ld .* \(.*\)/\1/; q'`
 
     glibcxx_gnu_ld_version=`echo $ldver | \
 	   $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
@@ -60200,7 +60200,7 @@  $as_echo_n "checking for ld version... " >&6; }
       glibcxx_ld_is_gold=yes
     fi
     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'`
+	   sed -e 's/GNU gold /GNU ld /;s/GNU ld .* \(.*\)/\1/; q'`
 
     glibcxx_gnu_ld_version=`echo $ldver | \
 	   $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
@@ -66116,7 +66116,7 @@  $as_echo_n "checking for ld version... " >&6; }
       glibcxx_ld_is_gold=yes
     fi
     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'`
+	   sed -e 's/GNU gold /GNU ld /;s/GNU ld .* \(.*\)/\1/; q'`
 
     glibcxx_gnu_ld_version=`echo $ldver | \
 	   $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
@@ -66283,7 +66283,7 @@  $as_echo_n "checking for ld version... " >&6; }
       glibcxx_ld_is_gold=yes
     fi
     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'`
+	   sed -e 's/GNU gold /GNU ld /;s/GNU ld .* \(.*\)/\1/; q'`
 
     glibcxx_gnu_ld_version=`echo $ldver | \
 	   $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
@@ -66511,7 +66511,7 @@  $as_echo_n "checking for ld version... " >&6; }
       glibcxx_ld_is_gold=yes
     fi
     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'`
+	   sed -e 's/GNU gold /GNU ld /;s/GNU ld .* \(.*\)/\1/; q'`
 
     glibcxx_gnu_ld_version=`echo $ldver | \
 	   $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`