PATCH: [4.1/4.2/4.3]: Gcc failed to detect Linux linker version

Richard Guenther richard.guenther@gmail.com
Sun Sep 23 17:10:00 GMT 2007


On 9/23/07, Richard Guenther <richard.guenther@gmail.com> wrote:
> On 9/23/07, H.J. Lu <hjl@lucon.org> wrote:
> > On Fri, Sep 21, 2007 at 05:48:32PM +0200, Richard Guenther wrote:
> > > On 9/13/07, H.J. Lu <hjl@lucon.org> wrote:
> > > > On Thu, Sep 13, 2007 at 12:09:44PM -0700, H.J. Lu wrote:
> > > > > On Thu, Sep 13, 2007 at 11:45:11AM -0700, Mark Mitchell wrote:
> > > > > > Paolo Bonzini wrote:
> > > > > > > H.J. Lu wrote:
> > > > > > >> Linux linker version is reported as 2.18.50.0.2.20070912. configure
> > > > > > >> failed to parse it. This patch fixes. Tested on Linux/x86-64. OK
> > > > > > >> to install to 4.1/4.2/4.3?
> > > > > > >
> > > > > > > Ok for 4.1 and 4.3.  For 4.2, ask Mark.
> > > > > >
> > > > > > OK.
> > > > > >
> > > > > > (But, can we please stop making the GNU/Linux linker version numbers
> > > > > > ever weirder?  We seem to have a patch like this rather often...)
> > > > > >
> > > > >
> > > > > I will see if I can come up with a better approach to parse linker
> > > > > version.
> > > > >
> > > > >
> > > >
> > > > I have seen
> > > >
> > > > GNU ld version 2.17.50.0.6-5.fc6 20061020
> > > > GNU ld version 2.17.50.0.12-4 20070128
> > > > GNU ld version 2.15.92.0.2 20040927
> > > > GNU ld (GNU Binutils) 2.18.50.20070913
> > > > GNU ld (Linux/GNU Binutils) 2.18.50.0.1.20070906
> > > >
> > > > This patch can handle any GNU linker version starting with xx.xx.*
> > >
> > > It doesn't handle
> > >
> > > > ld --version
> > > GNU ld (GNU Binutils) 2.17.50.20070726-12 (SUSE Linux)
> > >
> >
> > Have you tried my patch? I got
> >
> > # ./check "GNU ld (GNU Binutils) 2.17.50.20070726-12 (SUSE Linux)"
> > ld_ver: GNU ld (GNU Binutils) 2.17.50.20070726-12 (SUSE Linux)
> > ld_vers: 2.17.50.20070726-12 (SUSE Linux)
> > ld_date: 20070726
> > ld_vers_major: 2
> > ld_vers_minor: 17
> > ld_vers_patch: 50
>
> Yes, I tried your patch, but somehow it didn't work.  Maybe an error
> on my side though - I'll retry.

While the version in the script from you below matches the version,
the patched 4.2 branch version does not.  It reads:

echo $ld_ver | sed -n \
        -e 's,^.*[       ]\([0-9][0-9]*\.[0-9][0-9]*\)$,\1,p' \
        -e 's,^.*[       ]\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)$,\1,p' \
        -e 's,^.*[
]\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)$,\1,p' \
        -e 's,^.*[
]\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)$,\1,p'
\
        -e 's,^.*[       ]\([0-9][0-9]*\.[0-9][0-9]*\)[  ].*$,\1,p' \
        -e 's,^.*[       ]\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)[
  ].*$,\1,p' \
        -e 's,^.*[
]\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)[
].*$,\1,p' \
        -e 's,^.*[
]\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)[
 -].*$,\1,p'`

and produces an empty ld_vers string.

It is actually

  -e 's,^.*[       ]\([0-9][0-9]*\.[0-9][0-9]*.*\)$,\1,p'

that matches in your script.  We could, as a fallback, add the libstdc++v4
variant.

Richard.

> Thx,
> Richard.
>
> >
> > H.J.
> > ---
> > -----
> > #! /bin/sh
> >
> > ld_ver="$1"
> >     ld_vers=`echo $ld_ver | sed -n \
> >         -e 's,^.*[       ]\([0-9][0-9]*\.[0-9][0-9]*.*\)$,\1,p' \
> >         -e 's,^.*[       ]\([0-9][0-9]*\.[0-9][0-9]*\)[  ].*$,\1,p' \
> >         -e 's,^.*[       ]\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)[     ].*$,\1,p' \
> >         -e 's,^.*[       ]\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)[       ].*$,\1,p' \
> >         -e 's,^.*[       ]\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)[   -].*$,\1,p'`
> >     ld_date=`echo $ld_ver | sed -n 's,^.*\([2-9][0-9][0-9][0-9]\)[-]*\([01][0-9]\)[-]*\([0-3][0-9]\).*$,\1\2\3,p'`
> >     ld_vers_major=`expr "$ld_vers" : '\([0-9]*\)'`
> >     ld_vers_minor=`expr "$ld_vers" : '[0-9]*\.\([0-9]*\)'`
> >     ld_vers_patch=`expr "$ld_vers" : '[0-9]*\.[0-9]*\.\([0-9]*\)'`
> > echo ld_ver: $ld_ver
> > echo ld_vers: $ld_vers
> > echo ld_date: $ld_date
> > echo ld_vers_major: $ld_vers_major
> > echo ld_vers_minor: $ld_vers_minor
> > echo ld_vers_patch: $ld_vers_patch
> >
>



More information about the Gcc-patches mailing list