Do not detect a compiler without a C compiler (#43778)
This commit is contained in:
parent
d210425eef
commit
7d5e27d5e8
2 changed files with 52 additions and 2 deletions
|
@ -967,10 +967,11 @@ def _default_make_compilers(cmp_id, paths):
|
||||||
make_mixed_toolchain(flat_compilers)
|
make_mixed_toolchain(flat_compilers)
|
||||||
|
|
||||||
# Finally, create the compiler list
|
# Finally, create the compiler list
|
||||||
compilers = []
|
compilers: List["spack.compiler.Compiler"] = []
|
||||||
for compiler_id, _, compiler in flat_compilers:
|
for compiler_id, _, compiler in flat_compilers:
|
||||||
make_compilers = getattr(compiler_id.os, "make_compilers", _default_make_compilers)
|
make_compilers = getattr(compiler_id.os, "make_compilers", _default_make_compilers)
|
||||||
compilers.extend(make_compilers(compiler_id, compiler))
|
candidates = make_compilers(compiler_id, compiler)
|
||||||
|
compilers.extend(x for x in candidates if x.cc is not None)
|
||||||
|
|
||||||
return compilers
|
return compilers
|
||||||
|
|
||||||
|
|
|
@ -894,3 +894,52 @@ def prepare_executable(name):
|
||||||
# Test that null entries don't fail
|
# Test that null entries don't fail
|
||||||
compiler.cc = None
|
compiler.cc = None
|
||||||
compiler.verify_executables()
|
compiler.verify_executables()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"detected_versions,expected_length",
|
||||||
|
[
|
||||||
|
# If we detect a C compiler we expect the result to be valid
|
||||||
|
(
|
||||||
|
[
|
||||||
|
spack.compilers.DetectVersionArgs(
|
||||||
|
id=spack.compilers.CompilerID(
|
||||||
|
os="ubuntu20.04", compiler_name="clang", version="12.0.0"
|
||||||
|
),
|
||||||
|
variation=spack.compilers.NameVariation(prefix="", suffix="-12"),
|
||||||
|
language="cc",
|
||||||
|
path="/usr/bin/clang-12",
|
||||||
|
),
|
||||||
|
spack.compilers.DetectVersionArgs(
|
||||||
|
id=spack.compilers.CompilerID(
|
||||||
|
os="ubuntu20.04", compiler_name="clang", version="12.0.0"
|
||||||
|
),
|
||||||
|
variation=spack.compilers.NameVariation(prefix="", suffix="-12"),
|
||||||
|
language="cxx",
|
||||||
|
path="/usr/bin/clang++-12",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
1,
|
||||||
|
),
|
||||||
|
# If we detect only a C++ compiler we expect the result to be discarded
|
||||||
|
(
|
||||||
|
[
|
||||||
|
spack.compilers.DetectVersionArgs(
|
||||||
|
id=spack.compilers.CompilerID(
|
||||||
|
os="ubuntu20.04", compiler_name="clang", version="12.0.0"
|
||||||
|
),
|
||||||
|
variation=spack.compilers.NameVariation(prefix="", suffix="-12"),
|
||||||
|
language="cxx",
|
||||||
|
path="/usr/bin/clang++-12",
|
||||||
|
)
|
||||||
|
],
|
||||||
|
0,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_detection_requires_c_compiler(detected_versions, expected_length):
|
||||||
|
"""Tests that compilers automatically added to the configuration have
|
||||||
|
at least a C compiler.
|
||||||
|
"""
|
||||||
|
result = spack.compilers.make_compiler_list(detected_versions)
|
||||||
|
assert len(result) == expected_length
|
||||||
|
|
Loading…
Reference in a new issue