summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2024-08-21 16:36:07 +0200
committerGitHub <noreply@github.com>2024-08-21 16:36:07 +0200
commit33464a70383556663e42e9a036c7da06bf517490 (patch)
treeafe5bdc6d47565d5ff1b647547abfe000be18dd2
parentd3cdb2a3447d148066355535fef4e81f6e8450db (diff)
downloadspack-33464a70383556663e42e9a036c7da06bf517490.tar.gz
spack-33464a70383556663e42e9a036c7da06bf517490.tar.bz2
spack-33464a70383556663e42e9a036c7da06bf517490.tar.xz
spack-33464a70383556663e42e9a036c7da06bf517490.zip
gcc: simplify version_regex, change string to filter out Apple clang (#45852)
-rw-r--r--var/spack/repos/builtin/packages/gcc/detection_test.yaml28
-rw-r--r--var/spack/repos/builtin/packages/gcc/package.py4
2 files changed, 28 insertions, 4 deletions
diff --git a/var/spack/repos/builtin/packages/gcc/detection_test.yaml b/var/spack/repos/builtin/packages/gcc/detection_test.yaml
index ced4af1590..c0195bb8ca 100644
--- a/var/spack/repos/builtin/packages/gcc/detection_test.yaml
+++ b/var/spack/repos/builtin/packages/gcc/detection_test.yaml
@@ -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$"
diff --git a/var/spack/repos/builtin/packages/gcc/package.py b/var/spack/repos/builtin/packages/gcc/package.py
index b4ca189159..ba0379bf37 100644
--- a/var/spack/repos/builtin/packages/gcc/package.py
+++ b/var/spack/repos/builtin/packages/gcc/package.py
@@ -536,7 +536,7 @@ class Gcc(AutotoolsPackage, GNUMirrorPackage, CompilerPackage):
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 @@ class Gcc(AutotoolsPackage, GNUMirrorPackage, CompilerPackage):
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