Skip to content

Commit 382a946

Browse files
glandiumgitster
authored andcommitted
Handle some compiler versions containing a dash
The version reported by e.g. x86_64-w64-mingw32-gcc on Debian bullseye looks like: gcc version 10-win32 2021011 (GCC) This ends up with detect-compiler failing with: ./detect-compiler: 30: test: Illegal number: 10-win32 This change removes the two known suffixes known to exist in GCC versions in Debian: -win32 and -posix. Signed-off-by: Mike Hommey <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2807bd2 commit 382a946

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

detect-compiler

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,15 @@ get_family() {
1717
}
1818

1919
get_version() {
20-
get_version_line | sed 's/^.* version \([0-9][^ ]*\).*/\1/'
20+
# A string that begins with a digit up to the next SP
21+
ver=$(get_version_line | sed 's/^.* version \([0-9][^ ]*\).*/\1/')
22+
23+
# There are known -variant suffixes that do not affect the
24+
# meaning of the main version number. Strip them.
25+
ver=${ver%-win32}
26+
ver=${ver%-posix}
27+
28+
echo "$ver"
2129
}
2230

2331
print_flags() {

0 commit comments

Comments
 (0)