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

Chung-Lin Tang chunglin_tang@mentor.com
Thu Jul 4 08:29:00 GMT 2019


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.
-------------- next part --------------
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 }'`


More information about the Gcc-patches mailing list