[PATCH] LD/testsuite: Fix GCC version check

Andrew Pinski pinskia@gmail.com
Fri Aug 3 01:02:00 GMT 2012


On Thu, Aug 2, 2012 at 2:34 PM, Maciej W. Rozycki
<macro@codesourcery.com> wrote:
> Hi,
>
>  No developer seems to be using released GCC anymore. ;)  I've got this in
> testing:

I have tested this with "gcc version 4.7.0 (true) ".

Thanks,
Andrew Pinski

>
> [...]
> Running .../src/ld/testsuite/ld-elfvers/vers.exp ...
> ERROR: tcl error sourcing .../src/ld/testsuite/ld-elfvers/vers.exp.
> ERROR: can't read "maj": no such variable
>     while executing
> "verbose "major gcc version is $maj, want at least $major""
>     (procedure "at_least_gcc_version" line 14)
>     invoked from within
> "at_least_gcc_version 4 3"
>     invoked from within
> "if { [istarget mips*-*-*] && ! [at_least_gcc_version 4 3] } then {
>     set picflag ""
> } else {
>     # Unfortunately, the gcc argument is -fpic and the ..."
>     (file ".../src/ld/testsuite/ld-elfvers/vers.exp" line 79)
>     invoked from within
> "source .../src/ld/testsuite/ld-elfvers/vers.exp"
>     ("uplevel" body line 1)
>     invoked from within
> "uplevel #0 source .../src/ld/testsuite/ld-elfvers/vers.exp"
>     invoked from within
> "catch "uplevel #0 source $test_file_name""
> Running .../src/ld/testsuite/ld-elfvsb/elfvsb.exp ...
> [...]
>
> on a system whose GCC reports:
>
> gcc (GCC) 4.1.2
> Copyright (C) 2006 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>
>  I think the version check should be liberal on what it accepts, so I went
> back a little and checked a couple of GCC binaries I have handy:
>
> egcs-2.91.60
> gcc (GCC) 3.4
> gcc (GCC) 3.4 20031107 (experimental)
> gcc (GCC) 4.1.2
>
> Of these the former reports nothing else and the three latters follow with
> the copyright notice quoted above, with the copyright year varying.
> Unfortunately I have lost anything before 2.91.60.
>
>  As a result I came with the following clean-up -- the regexp used
> correctly extracts the major and the minor version as long as there are
> two numbers separated with a dot anywhere in input, preceded by a
> non-numerical, non-dot character and optionally followed by a dot and a
> third number.  I have verified that it handles all the four variants
> quoted above; it is expected handle some reasonable others as well,
> however if it still fails, then the error is reported properly without
> throwing an exception.
>
>  OK to apply?
>
> 2012-08-02  Maciej W. Rozycki  <macro@codesourcery.com>
>
>         ld/testsuite/
>         * lib/ld-lib.exp (at_least_gcc_version): Accept more version
>         number formats, avoid throwing exceptions in any cases.
>
>   Maciej
>
> binutils-ld-test-gcc-ver.diff
> Index: src/ld/testsuite/lib/ld-lib.exp
> ===================================================================
> --- src.orig/ld/testsuite/lib/ld-lib.exp
> +++ src/ld/testsuite/lib/ld-lib.exp
> @@ -41,14 +41,19 @@ proc at_least_gcc_version { major minor
>      set state [remote_exec host $CC --version]
>      set tmp "[lindex $state 1]\n"
>      # Look for (eg) 4.6.1 in the version output.
> -    regexp " .* (\[1-9\])\\.(\[0-9\])\\.\[0-9\]* .*" "$tmp" fred maj min
> +    set ver_re "\[^\\.0-9\]+(\[1-9\]\[0-9\]*)\\.(\[0-9\]+)(?:\\.\[0-9\]+)?"
> +    regexp $ver_re $tmp fred maj min
>      verbose "gcc version: $tmp"
> +    if { ![info exists maj] || ![info exists min] } then {
> +       perror "can't decipher gcc version number, fix the framework!"
> +       return 0
> +    }
>      verbose "major gcc version is $maj, want at least $major"
>      if { $maj == $major } then {
>         verbose "minor gcc version is $min, want at least $minor"
> -       return [expr  $min >= $minor ]
> +       return [expr $min >= $minor]
>      } else {
> -       return [expr $maj > $major ]
> +       return [expr $maj > $major]
>      }
>  }
>



More information about the Binutils mailing list