From 55196252dd4771eef5ced77f4feb129d6a959d4a Mon Sep 17 00:00:00 2001 From: Massimiliano Culpo Date: Wed, 23 Oct 2024 17:14:31 +0200 Subject: [PATCH] Improve reporting when bootstrapping from source Signed-off-by: Massimiliano Culpo --- lib/spack/llnl/util/lang.py | 7 ++----- lib/spack/spack/bootstrap/clingo.py | 10 ++++++++-- lib/spack/spack/spec.py | 3 --- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/spack/llnl/util/lang.py b/lib/spack/llnl/util/lang.py index 3e21e882e36..d2cce42a16d 100644 --- a/lib/spack/llnl/util/lang.py +++ b/lib/spack/llnl/util/lang.py @@ -996,11 +996,8 @@ def _receive_forwarded(self, context: str, exc: Exception, tb: List[str]): def grouped_message(self, with_tracebacks: bool = True) -> str: """Print out an error message coalescing all the forwarded errors.""" each_exception_message = [ - "{0} raised {1}: {2}{3}".format( - context, - exc.__class__.__name__, - exc, - "\n{0}".format("".join(tb)) if with_tracebacks else "", + "\n\t{0} raised {1}: {2}\n{3}".format( + context, exc.__class__.__name__, exc, f"\n{''.join(tb)}" if with_tracebacks else "" ) for context, exc, tb in self.exceptions ] diff --git a/lib/spack/spack/bootstrap/clingo.py b/lib/spack/spack/bootstrap/clingo.py index 9b32296217d..b380fcaa69c 100644 --- a/lib/spack/spack/bootstrap/clingo.py +++ b/lib/spack/spack/bootstrap/clingo.py @@ -62,9 +62,15 @@ def _valid_compiler_or_raise(self): ) candidates.sort(key=lambda x: x.version, reverse=True) best = candidates[0] - # FIXME (compiler as nodes): we need to find a better place for setting namespaces + # Get compilers for bootstrapping from the 'builtin' repository best.namespace = "builtin" - # TODO: check it has C and C++, and supports C++14 + # If the compiler does not support C++ 14, fail with a legible error message + try: + _ = best.package.standard_flag(language="cxx", standard="14") + except RuntimeError as e: + raise RuntimeError( + "cannot find a compiler supporting C++ 14 [needed to bootstrap clingo]" + ) from e return candidates[0] def _externals_from_yaml( diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index 6bf8bb6d6ff..5b24cd7018e 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -5221,9 +5221,6 @@ class DuplicateCompilerSpecError(spack.error.SpecError): class UnsupportedCompilerError(spack.error.SpecError): """Raised when the user asks for a compiler spack doesn't know about.""" - def __init__(self, compiler_name): - super().__init__("The '%s' compiler is not yet supported." % compiler_name) - class DuplicateArchitectureError(spack.error.SpecError): """Raised when the same architecture occurs in a spec twice."""