diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py index 46e892a835..0083dbc070 100644 --- a/lib/spack/spack/solver/asp.py +++ b/lib/spack/spack/solver/asp.py @@ -314,6 +314,10 @@ def using_libc_compatibility() -> bool: return spack.platforms.host().name == "linux" +def c_compiler_runs(compiler: spack.compiler.Compiler) -> bool: + return compiler.compiler_verbose_output is not None + + def extend_flag_list(flag_list, new_flags): """Extend a list of flags, preserving order and precedence. @@ -2975,6 +2979,13 @@ class CompilerParser: def __init__(self, configuration) -> None: self.compilers: Set[KnownCompiler] = set() for c in all_compilers_in_config(configuration): + if using_libc_compatibility() and not c_compiler_runs(c): + tty.debug( + f"the C compiler {c.cc} does not exist, or does not run correctly." + f" The compiler {c.spec} will not be used during concretization." + ) + continue + if using_libc_compatibility() and not c.default_libc: warnings.warn( f"cannot detect libc from {c.spec}. The compiler will not be used " diff --git a/lib/spack/spack/test/conftest.py b/lib/spack/spack/test/conftest.py index 29c10fb2e3..99eac4004f 100644 --- a/lib/spack/spack/test/conftest.py +++ b/lib/spack/spack/test/conftest.py @@ -2053,3 +2053,11 @@ def _true(x): @pytest.fixture() def do_not_check_runtimes_on_reuse(monkeypatch): monkeypatch.setattr(spack.solver.asp, "_has_runtime_dependencies", _true) + + +@pytest.fixture(autouse=True, scope="session") +def _c_compiler_always_exists(): + fn = spack.solver.asp.c_compiler_runs + spack.solver.asp.c_compiler_runs = _true + yield + spack.solver.asp.c_compiler_runs = fn