Raise UnsupportedCompilerFlag when a flag is not supported
This commit is contained in:
parent
2d40025ae3
commit
0bd8ca4e08
@ -14,6 +14,8 @@
|
|||||||
import llnl.util.tty as tty
|
import llnl.util.tty as tty
|
||||||
from llnl.util.lang import classproperty, memoized
|
from llnl.util.lang import classproperty, memoized
|
||||||
|
|
||||||
|
import spack
|
||||||
|
import spack.compilers.error
|
||||||
import spack.compilers.libraries
|
import spack.compilers.libraries
|
||||||
import spack.config
|
import spack.config
|
||||||
import spack.package_base
|
import spack.package_base
|
||||||
@ -166,12 +168,13 @@ def determine_variants(cls, exes: Sequence[Path], version_str: str) -> Tuple:
|
|||||||
def standard_flag(self, *, language: str, standard: str) -> str:
|
def standard_flag(self, *, language: str, standard: str) -> str:
|
||||||
"""Returns the flag used to enforce a given standard for a language"""
|
"""Returns the flag used to enforce a given standard for a language"""
|
||||||
if language not in self.supported_languages:
|
if language not in self.supported_languages:
|
||||||
# FIXME (compiler as nodes): Use UnsupportedCompilerFlag ?
|
raise spack.compilers.error.UnsupportedCompilerFlag(
|
||||||
raise RuntimeError(f"{self.spec} does not provide the '{language}' language")
|
f"{self.spec} does not provide the '{language}' language"
|
||||||
|
)
|
||||||
try:
|
try:
|
||||||
return self._standard_flag(language=language, standard=standard)
|
return self._standard_flag(language=language, standard=standard)
|
||||||
except (KeyError, RuntimeError) as e:
|
except (KeyError, RuntimeError) as e:
|
||||||
raise RuntimeError(
|
raise spack.compilers.error.UnsupportedCompilerFlag(
|
||||||
f"{self.spec} does not provide the '{language}' standard {standard}"
|
f"{self.spec} does not provide the '{language}' standard {standard}"
|
||||||
) from e
|
) from e
|
||||||
|
|
||||||
@ -303,18 +306,18 @@ def _compiler_output(
|
|||||||
version_argument: the argument used to extract version information
|
version_argument: the argument used to extract version information
|
||||||
"""
|
"""
|
||||||
compiler = spack.util.executable.Executable(compiler_path)
|
compiler = spack.util.executable.Executable(compiler_path)
|
||||||
compiler_invocation_args = {
|
if not version_argument:
|
||||||
"output": str,
|
return compiler(
|
||||||
"error": str,
|
output=str, error=str, ignore_errors=ignore_errors, timeout=120, fail_on_error=True
|
||||||
"ignore_errors": ignore_errors,
|
)
|
||||||
"timeout": 120,
|
return compiler(
|
||||||
"fail_on_error": True,
|
version_argument,
|
||||||
}
|
output=str,
|
||||||
if version_argument:
|
error=str,
|
||||||
output = compiler(version_argument, **compiler_invocation_args)
|
ignore_errors=ignore_errors,
|
||||||
else:
|
timeout=120,
|
||||||
output = compiler(**compiler_invocation_args)
|
fail_on_error=True,
|
||||||
return output
|
)
|
||||||
|
|
||||||
|
|
||||||
def compiler_output(
|
def compiler_output(
|
||||||
|
@ -13,10 +13,6 @@ def __init__(self, compiler, paths):
|
|||||||
|
|
||||||
|
|
||||||
class UnsupportedCompilerFlag(SpackError):
|
class UnsupportedCompilerFlag(SpackError):
|
||||||
def __init__(self, compiler, feature, flag_name, ver_string=None):
|
"""Raised when a compiler does not support a flag type (e.g. a flag to enforce a
|
||||||
super().__init__(
|
language standard).
|
||||||
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."
|
|
||||||
)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user