invalid compiler: warn instead of error (#43491)

This commit is contained in:
Greg Becker 2024-04-11 11:39:27 -07:00 committed by GitHub
parent 8e0c659b51
commit 2077b3a006
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -10,6 +10,7 @@
import itertools import itertools
import multiprocessing.pool import multiprocessing.pool
import os import os
import warnings
from typing import Dict, List, Optional, Tuple from typing import Dict, List, Optional, Tuple
import archspec.cpu import archspec.cpu
@ -341,7 +342,9 @@ def all_compilers_config(
from_compilers_yaml = get_compiler_config(configuration, scope=scope, init_config=init_config) from_compilers_yaml = get_compiler_config(configuration, scope=scope, init_config=init_config)
result = from_compilers_yaml + from_packages_yaml 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)) 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 configuration=configuration, scope=scope, init_config=init_config
): ):
items = items["compiler"] 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 return compilers
@ -627,7 +632,10 @@ def _compiler_from_config_entry(items):
compiler = _compiler_cache.get(config_id, None) compiler = _compiler_cache.get(config_id, None)
if compiler is 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 _compiler_cache[config_id] = compiler
return compiler return compiler
@ -680,7 +688,9 @@ def get_compilers(config, cspec=None, arch_spec=None):
raise ValueError(msg) raise ValueError(msg)
continue continue
compilers.append(_compiler_from_config_entry(items)) compiler = _compiler_from_config_entry(items)
if compiler:
compilers.append(compiler)
return compilers return compilers