Cache compilers parsed from config files
- Spack ends up constructing compilers frequently from YAML data. - This caches the result of parsing the compiler config - The logic in compilers/__init__.py could use a bigger cleanup, but this makes concretization much faster for now. - on macOS, this also ensures that xcrun is called only twice, as opposed to every time a new compiler object is constructed.
This commit is contained in:
parent
2e1aa0a5e9
commit
55f85f2307
@ -45,6 +45,9 @@
|
||||
'extra_rpaths']
|
||||
_cache_config_file = []
|
||||
|
||||
#: cache of compilers constructed from config data, keyed by config entry id.
|
||||
_compiler_cache = {}
|
||||
|
||||
|
||||
def _auto_compiler_spec(function):
|
||||
def converter(cspec_like, *args, **kwargs):
|
||||
@ -251,6 +254,10 @@ def compilers_for_arch(arch_spec, scope=None):
|
||||
|
||||
|
||||
def compiler_from_config_entry(items):
|
||||
config_id = id(items)
|
||||
compiler = _compiler_cache.get(config_id, None)
|
||||
|
||||
if compiler is None:
|
||||
cspec = spack.spec.CompilerSpec(items['spec'])
|
||||
os = items.get('operating_system', None)
|
||||
target = items.get('target', None)
|
||||
@ -278,8 +285,11 @@ def compiler_from_config_entry(items):
|
||||
environment = items.get('environment', {})
|
||||
extra_rpaths = items.get('extra_rpaths', [])
|
||||
|
||||
return cls(cspec, os, target, compiler_paths, mods, alias,
|
||||
compiler = cls(cspec, os, target, compiler_paths, mods, alias,
|
||||
environment, extra_rpaths, **compiler_flags)
|
||||
_compiler_cache[id(items)] = compiler
|
||||
|
||||
return compiler
|
||||
|
||||
|
||||
def get_compilers(config, cspec=None, arch_spec=None):
|
||||
|
Loading…
Reference in New Issue
Block a user