gcc: restore old detection (#45810)
This commit is contained in:
parent
e8a13642a0
commit
34df21b62c
@ -52,27 +52,6 @@ paths:
|
|||||||
cxx: ".*/bin/g[+][+]-5$"
|
cxx: ".*/bin/g[+][+]-5$"
|
||||||
fortran: ".*/bin/gfortran-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
|
# Apple clang under disguise as gcc should not be detected
|
||||||
- layout:
|
- layout:
|
||||||
- executables:
|
- executables:
|
||||||
@ -94,3 +73,25 @@ paths:
|
|||||||
fi
|
fi
|
||||||
platforms: ["darwin"]
|
platforms: ["darwin"]
|
||||||
results: []
|
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 os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from archspec.cpu import UnsupportedMicroarchitecture
|
import archspec.cpu
|
||||||
|
|
||||||
import llnl.util.tty as tty
|
import llnl.util.tty as tty
|
||||||
from llnl.util.symlink import readlink
|
from llnl.util.symlink import readlink
|
||||||
@ -535,45 +535,26 @@ def supported_languages(self):
|
|||||||
fortran_names = ["gfortran"]
|
fortran_names = ["gfortran"]
|
||||||
d_names = ["gdc"]
|
d_names = ["gdc"]
|
||||||
go_names = ["gccgo"]
|
go_names = ["gccgo"]
|
||||||
compiler_prefixes = [r"\w+-\w+-\w+-"]
|
|
||||||
compiler_suffixes = [r"-mp-\d+(?:\.\d+)?", r"-\d+(?:\.\d+)?", r"\d\d"]
|
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"(?<!clang version)\s?([0-9.]+)"
|
||||||
compiler_version_argument = ("-dumpfullversion", "-dumpversion")
|
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
|
@classmethod
|
||||||
def filter_detected_exes(cls, prefix, exes_in_prefix):
|
def filter_detected_exes(cls, prefix, exes_in_prefix):
|
||||||
result = []
|
# Apple's gcc is actually apple clang, so skip it.
|
||||||
for exe in exes_in_prefix:
|
if str(spack.platforms.host()) == "darwin":
|
||||||
# On systems like Ubuntu we might get multiple executables
|
not_apple_clang = []
|
||||||
# with the string "gcc" in them. See:
|
for exe in exes_in_prefix:
|
||||||
# https://helpmanual.io/packages/apt/gcc/
|
try:
|
||||||
basename = os.path.basename(exe)
|
output = spack.compiler.get_compiler_version_output(exe, "--version")
|
||||||
substring_to_be_filtered = [
|
except Exception:
|
||||||
"c99-gcc",
|
output = ""
|
||||||
"c89-gcc",
|
if "Apple" in output:
|
||||||
"-nm",
|
continue
|
||||||
"-ar",
|
not_apple_clang.append(exe)
|
||||||
"ranlib",
|
return not_apple_clang
|
||||||
"clang", # clang++ matches g++ -> clan[g++]
|
|
||||||
]
|
|
||||||
if any(x in basename for x in substring_to_be_filtered):
|
|
||||||
continue
|
|
||||||
|
|
||||||
result.append(exe)
|
return exes_in_prefix
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def determine_variants(cls, exes, version_str):
|
def determine_variants(cls, exes, version_str):
|
||||||
@ -702,7 +683,7 @@ def get_common_target_flags(self, spec):
|
|||||||
for uarch in microarchitectures:
|
for uarch in microarchitectures:
|
||||||
try:
|
try:
|
||||||
return uarch.optimization_flags("gcc", str(spec.version))
|
return uarch.optimization_flags("gcc", str(spec.version))
|
||||||
except UnsupportedMicroarchitecture:
|
except archspec.cpu.UnsupportedMicroarchitecture:
|
||||||
pass
|
pass
|
||||||
# no arch specific flags in common, unlikely to happen.
|
# no arch specific flags in common, unlikely to happen.
|
||||||
return ""
|
return ""
|
||||||
|
Loading…
Reference in New Issue
Block a user