From 52ff9e9d54d1f528eb7645706bb3a67fc535050b Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Wed, 31 Jul 2024 08:02:24 +0930 Subject: [PATCH] fix the framework error 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 | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) 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.