diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py index fec214a3fad..3fb88a274dd 100644 --- a/lib/spack/spack/solver/asp.py +++ b/lib/spack/spack/solver/asp.py @@ -2977,11 +2977,15 @@ def possible_compilers(*, configuration) -> List["spack.spec.Spec"]: # FIXME (compiler as nodes): Discard early specs that are not marked for this target? if using_libc_compatibility() and not c_compiler_runs(c): - compiler = c.extra_attributes["compilers"]["c"] - tty.debug( - f"the C compiler {compiler} does not exist, or does not run correctly." - f" The compiler {c} will not be used during concretization." - ) + try: + compiler = c.extra_attributes["compilers"]["c"] + tty.debug( + f"the C compiler {compiler} does not exist, or does not run correctly." + f" The compiler {c} will not be used during concretization." + ) + except KeyError: + tty.debug(f"the spec {c} does not provide a C compiler.") + continue if using_libc_compatibility() and not CompilerPropertyDetector(c).default_libc():