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 }'`

Reply via email to