diff options
author | Greg Becker <becker33@llnl.gov> | 2024-04-11 11:39:27 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-11 20:39:27 +0200 |
commit | 2077b3a006fbeceb83042bb11d9e94396cc11229 (patch) | |
tree | e8a04d8ba64e18bea299e08a9e72d7bb63bf5522 | |
parent | 8e0c659b51126f57755e3175e3acf593044644d2 (diff) | |
download | spack-2077b3a006fbeceb83042bb11d9e94396cc11229.tar.gz spack-2077b3a006fbeceb83042bb11d9e94396cc11229.tar.bz2 spack-2077b3a006fbeceb83042bb11d9e94396cc11229.tar.xz spack-2077b3a006fbeceb83042bb11d9e94396cc11229.zip |
invalid compiler: warn instead of error (#43491)
-rw-r--r-- | lib/spack/spack/compilers/__init__.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/spack/spack/compilers/__init__.py b/lib/spack/spack/compilers/__init__.py index ed3244da2e..678c1773ab 100644 --- a/lib/spack/spack/compilers/__init__.py +++ b/lib/spack/spack/compilers/__init__.py @@ -10,6 +10,7 @@ import collections import itertools import multiprocessing.pool import os +import warnings from typing import Dict, List, Optional, Tuple import archspec.cpu @@ -341,7 +342,9 @@ def all_compilers_config( from_compilers_yaml = get_compiler_config(configuration, scope=scope, init_config=init_config) result = from_compilers_yaml + from_packages_yaml - key = lambda c: _compiler_from_config_entry(c["compiler"]) + # Dedupe entries by the compiler they represent + # If the entry is invalid, treat it as unique for deduplication + key = lambda c: _compiler_from_config_entry(c["compiler"] or id(c)) return list(llnl.util.lang.dedupe(result, key=key)) @@ -520,7 +523,9 @@ def all_compilers_from(configuration, scope=None, init_config=True): configuration=configuration, scope=scope, init_config=init_config ): items = items["compiler"] - compilers.append(_compiler_from_config_entry(items)) + compiler = _compiler_from_config_entry(items) # can be None in error case + if compiler: + compilers.append(compiler) return compilers @@ -627,7 +632,10 @@ def _compiler_from_config_entry(items): compiler = _compiler_cache.get(config_id, None) if compiler is None: - compiler = compiler_from_dict(items) + try: + compiler = compiler_from_dict(items) + except UnknownCompilerError as e: + warnings.warn(e.message) _compiler_cache[config_id] = compiler return compiler @@ -680,7 +688,9 @@ def get_compilers(config, cspec=None, arch_spec=None): raise ValueError(msg) continue - compilers.append(_compiler_from_config_entry(items)) + compiler = _compiler_from_config_entry(items) + if compiler: + compilers.append(compiler) return compilers |