]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
fix the framework error
authorAlan Modra <amodra@gmail.com>
Tue, 30 Jul 2024 22:32:24 +0000 (08:02 +0930)
committerAlan Modra <amodra@gmail.com>
Wed, 31 Jul 2024 01:13:05 +0000 (10:43 +0930)
Running the testsuite for an x86_64-w64-mingw32 target using the
Ubuntu package gcc-mingw-w64-x86-64 version 13.2.0-6ubuntu1+26.1
results in a number of messages:
ERROR: can't decipher gcc version number, fix the framework!

Someone in their wisdom decided this compiler should advertise itself
with a version of 13-win32, breaking the ld testsuite version checks.
(It is also configured using --with-as=/usr/bin/x86_64-w64-mingw32-as
--with-ld=/usr/bin/x86_64-w64-mingw32-ld which renders the -B flag
inoperative for testing the newly built gas and ld.  You'd need to
install binutils over the top of the Ubuntu versions before testing, a
rather unsatisfactory process.)

* testsuite/lib/ld-lib.exp (at_least_gcc_version): Use
preprocessor test of __GNUC__ and __GNUC_MINOR__ rather than
output of gcc --version.  Correct removal of -Wl options.

ld/testsuite/lib/ld-lib.exp

index aeef82a9ae2d88ba3824a165069b704dc42d9bb0..5d5905dc260ee7616de81ed903c29be341f6c02d 100644 (file)
@@ -33,27 +33,14 @@ proc at_least_gcc_version { major minor } {
        return 0
     }
     # Filter out -Wl, options.
-    regsub -all -- "-Wl,\[^ ^\t\]+" $CC_FOR_TARGET "" cc_cmd
-    set state [remote_exec host $cc_cmd --version]
+    regsub -all -- {-Wl,[^ \t]+} $CC_FOR_TARGET {} cc_cmd
+    set prog "\"#if $major < __GNUC__ + ($minor <= __GNUC_MINOR__)\nyes\n#endif\""
+    set cmd "echo $prog | $cc_cmd -E -"
+    set state [remote_exec host [concat sh -c [list "$cmd 2>/dev/null"]]]
     if { [lindex $state 0] != 0 } {
        return 0;
     }
-    set tmp "[lindex $state 1]\n"
-    # Look for (eg) 4.6.1 in the version output.
-    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]
-    } else {
-       return [expr $maj > $major]
-    }
+    return [regexp {(?x)yes} [lindex $state 1]]
 }
 
 # Extract and print the version number of ld.