From df92dad2257da2f1841cc0ff6928383e19e9afac Mon Sep 17 00:00:00 2001 From: Massimiliano Culpo Date: Wed, 4 Dec 2024 18:56:32 +0100 Subject: [PATCH] Raise UnsupportedCompilerFlag when a flag is not supported --- lib/spack/spack/build_systems/compiler.py | 9 ++++++--- lib/spack/spack/compilers/error.py | 10 +++------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/spack/spack/build_systems/compiler.py b/lib/spack/spack/build_systems/compiler.py index 7a80470c03f..ad5c7cc8840 100644 --- a/lib/spack/spack/build_systems/compiler.py +++ b/lib/spack/spack/build_systems/compiler.py @@ -15,6 +15,8 @@ import llnl.util.tty as tty from llnl.util.lang import classproperty, memoized +import spack +import spack.compilers.error import spack.compilers.libraries import spack.config import spack.package_base @@ -167,12 +169,13 @@ def determine_variants(cls, exes: Sequence[Path], version_str: str) -> Tuple: def standard_flag(self, *, language: str, standard: str) -> str: """Returns the flag used to enforce a given standard for a language""" if language not in self.supported_languages: - # FIXME (compiler as nodes): Use UnsupportedCompilerFlag ? - raise RuntimeError(f"{self.spec} does not provide the '{language}' language") + raise spack.compilers.error.UnsupportedCompilerFlag( + f"{self.spec} does not provide the '{language}' language" + ) try: return self._standard_flag(language=language, standard=standard) except (KeyError, RuntimeError) as e: - raise RuntimeError( + raise spack.compilers.error.UnsupportedCompilerFlag( f"{self.spec} does not provide the '{language}' standard {standard}" ) from e diff --git a/lib/spack/spack/compilers/error.py b/lib/spack/spack/compilers/error.py index a86f2fa6044..6411eac0129 100644 --- a/lib/spack/spack/compilers/error.py +++ b/lib/spack/spack/compilers/error.py @@ -14,10 +14,6 @@ def __init__(self, compiler, paths): class UnsupportedCompilerFlag(SpackError): - def __init__(self, compiler, feature, flag_name, ver_string=None): - super().__init__( - f"{compiler.name} ({ver_string if ver_string else compiler.version}) does not support" - f" {feature} (as compiler.{flag_name}). If you think it should, please edit the " - f"compiler.{compiler.name} subclass to implement the {flag_name} property and submit " - f"a pull request or issue." - ) + """Raised when a compiler does not support a flag type (e.g. a flag to enforce a + language standard). + """