gcc: restore old detection (#45810)
This commit is contained in:
parent
e8a13642a0
commit
34df21b62c
@ -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: []
|
||||
|
@ -7,7 +7,7 @@
|
||||
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 @@ def supported_languages(self):
|
||||
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):
|
||||
def filter_detected_exes(cls, prefix, exes_in_prefix):
|
||||
# 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 = ""
|
||||
# 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
|
||||
not_apple_clang.append(exe)
|
||||
return not_apple_clang
|
||||
|
||||
result.append(exe)
|
||||
|
||||
return result
|
||||
return exes_in_prefix
|
||||
|
||||
@classmethod
|
||||
def determine_variants(cls, exes, version_str):
|
||||
@ -702,7 +683,7 @@ def get_common_target_flags(self, spec):
|
||||
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 ""
|
||||
|
Loading…
Reference in New Issue
Block a user