diff --git a/lib/spack/llnl/util/lang.py b/lib/spack/llnl/util/lang.py index 4913a50fad9..1cd7091aa3e 100644 --- a/lib/spack/llnl/util/lang.py +++ b/lib/spack/llnl/util/lang.py @@ -995,11 +995,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 337ac4c6f9c..4f381a5aeda 100644 --- a/lib/spack/spack/bootstrap/clingo.py +++ b/lib/spack/spack/bootstrap/clingo.py @@ -63,9 +63,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/bootstrap/core.py b/lib/spack/spack/bootstrap/core.py index 3d23ea24cc0..82c60b275ac 100644 --- a/lib/spack/spack/bootstrap/core.py +++ b/lib/spack/spack/bootstrap/core.py @@ -322,11 +322,10 @@ def create_bootstrapper(conf: ConfigDictionary): return _bootstrap_methods[btype](conf) -def source_is_enabled_or_raise(conf: ConfigDictionary): +def source_is_enabled(conf: ConfigDictionary): """Raise ValueError if the source is not enabled for bootstrapping""" trusted, name = spack.config.get("bootstrap:trusted"), conf["name"] - if not trusted.get(name, False): - raise ValueError("source is not trusted") + return trusted.get(name, False) def ensure_module_importable_or_raise(module: str, abstract_spec: Optional[str] = None): @@ -356,8 +355,10 @@ def ensure_module_importable_or_raise(module: str, abstract_spec: Optional[str] exception_handler = GroupedExceptionHandler() for current_config in bootstrapping_sources(): + if not source_is_enabled(current_config): + continue + with exception_handler.forward(current_config["name"], Exception): - source_is_enabled_or_raise(current_config) current_bootstrapper = create_bootstrapper(current_config) if current_bootstrapper.try_import(module, abstract_spec): return @@ -369,11 +370,7 @@ def ensure_module_importable_or_raise(module: str, abstract_spec: Optional[str] msg = f'cannot bootstrap the "{module}" Python module ' if abstract_spec: msg += f'from spec "{abstract_spec}" ' - if tty.is_debug(): - msg += exception_handler.grouped_message(with_tracebacks=True) - else: - msg += exception_handler.grouped_message(with_tracebacks=False) - msg += "\nRun `spack --debug ...` for more detailed errors" + msg += exception_handler.grouped_message(with_tracebacks=tty.is_debug()) raise ImportError(msg) @@ -411,8 +408,9 @@ def ensure_executables_in_path_or_raise( exception_handler = GroupedExceptionHandler() for current_config in bootstrapping_sources(): + if not source_is_enabled(current_config): + continue with exception_handler.forward(current_config["name"], Exception): - source_is_enabled_or_raise(current_config) current_bootstrapper = create_bootstrapper(current_config) if current_bootstrapper.try_search_path(executables, abstract_spec): # Additional environment variables needed diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index c6bafc48d75..47eb9c5d75a 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -5217,9 +5217,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."""