diff options
author | Massimiliano Culpo <massimiliano.culpo@gmail.com> | 2024-08-21 11:31:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-21 11:31:52 +0200 |
commit | 34df21b62ccf023e672ca6cb9f8fcda4586df627 (patch) | |
tree | c719b5a0cc88393eb6c3bb9f6f6bbca2b8fe8b84 /var | |
parent | e8a13642a090bb5cef31412d389364891e89f225 (diff) | |
download | spack-34df21b62ccf023e672ca6cb9f8fcda4586df627.tar.gz spack-34df21b62ccf023e672ca6cb9f8fcda4586df627.tar.bz2 spack-34df21b62ccf023e672ca6cb9f8fcda4586df627.tar.xz spack-34df21b62ccf023e672ca6cb9f8fcda4586df627.zip |
gcc: restore old detection (#45810)
Diffstat (limited to 'var')
-rw-r--r-- | var/spack/repos/builtin/packages/gcc/detection_test.yaml | 43 | ||||
-rw-r--r-- | var/spack/repos/builtin/packages/gcc/package.py | 49 |
2 files changed, 37 insertions, 55 deletions
diff --git a/var/spack/repos/builtin/packages/gcc/detection_test.yaml b/var/spack/repos/builtin/packages/gcc/detection_test.yaml index 7269c0301c..ced4af1590 100644 --- a/var/spack/repos/builtin/packages/gcc/detection_test.yaml +++ b/var/spack/repos/builtin/packages/gcc/detection_test.yaml @@ -52,27 +52,6 @@ paths: cxx: ".*/bin/g[+][+]-5$" fortran: ".*/bin/gfortran-5$" -# Multiple compilers present at the same time -- layout: - - executables: - - "bin/x86_64-linux-gnu-gcc-6" - script: 'echo 6.5.0' - - executables: - - "bin/x86_64-linux-gnu-gcc-10" - - "bin/x86_64-linux-gnu-g++-10" - script: "echo 10.1.0" - platforms: [darwin, linux] - results: - - spec: "gcc@6.5.0 languages=c" - extra_attributes: - compilers: - c: ".*/bin/x86_64-linux-gnu-gcc-6$" - - spec: "gcc@10.1.0 languages=c,c++" - extra_attributes: - compilers: - c: ".*/bin/x86_64-linux-gnu-gcc-10$" - cxx: ".*/bin/x86_64-linux-gnu-g[+][+]-10$" - # Apple clang under disguise as gcc should not be detected - layout: - executables: @@ -94,3 +73,25 @@ paths: fi platforms: ["darwin"] results: [] + +# Mingw cross compiler on linux should not be detected +- layout: + - executables: + - "bin/i686-w64-mingw32-gcc" + script: | + if [ "$1" = "-dumpversion" ] ; then + echo "9.3-win32" + elif [ "$1" = "-dumpfullversion" ] ; then + echo "9.3-win32" >&2 + exit 1 + elif [ "$1" = "--version" ] ; then + echo "i686-w64-mingw32-gcc (GCC) 9.3-win32 20200320" + echo "Copyright (C) 2019 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: [linux] + results: [] diff --git a/var/spack/repos/builtin/packages/gcc/package.py b/var/spack/repos/builtin/packages/gcc/package.py index d28209f04f..b4ca189159 100644 --- a/var/spack/repos/builtin/packages/gcc/package.py +++ b/var/spack/repos/builtin/packages/gcc/package.py @@ -7,7 +7,7 @@ import itertools import os import sys -from archspec.cpu import UnsupportedMicroarchitecture +import archspec.cpu import llnl.util.tty as tty from llnl.util.symlink import readlink @@ -535,45 +535,26 @@ class Gcc(AutotoolsPackage, GNUMirrorPackage, CompilerPackage): fortran_names = ["gfortran"] d_names = ["gdc"] go_names = ["gccgo"] - compiler_prefixes = [r"\w+-\w+-\w+-"] compiler_suffixes = [r"-mp-\d+(?:\.\d+)?", r"-\d+(?:\.\d+)?", r"\d\d"] compiler_version_regex = r"(?<!clang version)\s?([0-9.]+)" compiler_version_argument = ("-dumpfullversion", "-dumpversion") @classmethod - def determine_version(cls, exe): - try: - output = spack.compiler.get_compiler_version_output(exe, "--version") - except Exception: - output = "" - # Apple's gcc is actually apple clang, so skip it. - if "Apple" in output: - return None - - return super().determine_version(exe) - - @classmethod def filter_detected_exes(cls, prefix, exes_in_prefix): - result = [] - for exe in exes_in_prefix: - # On systems like Ubuntu we might get multiple executables - # with the string "gcc" in them. See: - # https://helpmanual.io/packages/apt/gcc/ - basename = os.path.basename(exe) - substring_to_be_filtered = [ - "c99-gcc", - "c89-gcc", - "-nm", - "-ar", - "ranlib", - "clang", # clang++ matches g++ -> clan[g++] - ] - if any(x in basename for x in substring_to_be_filtered): - continue - - result.append(exe) + # Apple's gcc is actually apple clang, so skip it. + if str(spack.platforms.host()) == "darwin": + not_apple_clang = [] + for exe in exes_in_prefix: + try: + output = spack.compiler.get_compiler_version_output(exe, "--version") + except Exception: + output = "" + if "Apple" in output: + continue + not_apple_clang.append(exe) + return not_apple_clang - return result + return exes_in_prefix @classmethod def determine_variants(cls, exes, version_str): @@ -702,7 +683,7 @@ class Gcc(AutotoolsPackage, GNUMirrorPackage, CompilerPackage): for uarch in microarchitectures: try: return uarch.optimization_flags("gcc", str(spec.version)) - except UnsupportedMicroarchitecture: + except archspec.cpu.UnsupportedMicroarchitecture: pass # no arch specific flags in common, unlikely to happen. return "" |