fix the framework error
Alan Modra
amodra@gmail.com
Wed Jul 31 05:21:41 GMT 2024
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.)
So use gcc -E to test __GNUC__ and __GNUC_MINOR__ directly. (You
can't compile and run anything, this is a target not a host compiler.)
I've also fixed a minor bug in the -Wl option removal where an extra ^
appeared in the regular expression, and used {} to quote.
* 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.
diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp
index aeef82a9ae2..5d5905dc260 100644
--- a/ld/testsuite/lib/ld-lib.exp
+++ b/ld/testsuite/lib/ld-lib.exp
@@ -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.
--
Alan Modra
More information about the Binutils
mailing list