From 33464a70383556663e42e9a036c7da06bf517490 Mon Sep 17 00:00:00 2001 From: Massimiliano Culpo Date: Wed, 21 Aug 2024 16:36:07 +0200 Subject: gcc: simplify version_regex, change string to filter out Apple clang (#45852) --- .../repos/builtin/packages/gcc/detection_test.yaml | 28 ++++++++++++++++++++-- var/spack/repos/builtin/packages/gcc/package.py | 4 ++-- 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"(?