From cbcfc7e10a62282f5d0ee6366b8a3d46a9a0d7a3 Mon Sep 17 00:00:00 2001 From: Massimiliano Culpo Date: Tue, 21 May 2024 14:09:29 +0200 Subject: [PATCH] Demote a warning to debug message, if C compiler is not there (#44182) --- lib/spack/spack/solver/asp.py | 11 +++++++++++ lib/spack/spack/test/conftest.py | 8 ++++++++ 2 files changed, 19 insertions(+) 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