gcc: simplify version_regex, change string to filter out Apple clang (#45852)

This commit is contained in:
Massimiliano Culpo 2024-08-21 16:36:07 +02:00 committed by GitHub
parent d3cdb2a344
commit 33464a7038
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 28 additions and 4 deletions

View File

@ -82,8 +82,7 @@ paths:
if [ "$1" = "-dumpversion" ] ; then
echo "9.3-win32"
elif [ "$1" = "-dumpfullversion" ] ; then
echo "9.3-win32" >&2
exit 1
echo "9.3-win32"
elif [ "$1" = "--version" ] ; then
echo "i686-w64-mingw32-gcc (GCC) 9.3-win32 20200320"
echo "Copyright (C) 2019 Free Software Foundation, Inc."
@ -95,3 +94,28 @@ paths:
fi
platforms: [linux]
results: []
# Homebrew GCC should be detected
- layout:
- executables:
- "bin/gcc-14"
script: |
if [ "$1" = "-dumpversion" ] ; then
echo "14"
elif [ "$1" = "-dumpfullversion" ] ; then
echo "14.1.0"
elif [ "$1" = "--version" ] ; then
echo "gcc-14 (Homebrew GCC 14.1.0_2) 14.1.0"
echo "Copyright (C) 2024 Free Software Foundation, Inc."
echo "This is free software; see the source for copying conditions. There is NO"
echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
else
echo "mock executable got an unexpected flag: $1"
exit 1
fi
platforms: [darwin]
results:
- spec: "gcc@14.1.0 languages=c"
extra_attributes:
compilers:
c: ".*/bin/gcc-14$"

View File

@ -536,7 +536,7 @@ def supported_languages(self):
d_names = ["gdc"]
go_names = ["gccgo"]
compiler_suffixes = [r"-mp-\d+(?:\.\d+)?", r"-\d+(?:\.\d+)?", r"\d\d"]
compiler_version_regex = r"(?<!clang version)\s?([0-9.]+)"
compiler_version_regex = r"([0-9.]+)"
compiler_version_argument = ("-dumpfullversion", "-dumpversion")
@classmethod
@ -549,7 +549,7 @@ def filter_detected_exes(cls, prefix, exes_in_prefix):
output = spack.compiler.get_compiler_version_output(exe, "--version")
except Exception:
output = ""
if "Apple" in output:
if "clang version" in output:
continue
not_apple_clang.append(exe)
return not_apple_clang