compilers: don't raise errors for duplicate compiler definitions (#11910)
Summary: - Allow multiple definitions of compiler in compilers.yaml (use first instance) - Still print debug messages when there are duplicates, to assist users in finding this issue. Merging configs from different scopes can result in multiple compiler being present in the same configuration list. Instead of raising when there are duplicates, take the one with highest precedence. Print a debug message instead of raising, so that we can still diagnose this. We don't have a good way of warning the user about inconsistent configuration *in the same file* -- we'd need to dig into YAML file/line info for that.
This commit is contained in:
parent
993ee7f199
commit
8ec098716b
@ -383,7 +383,9 @@ def compiler_for_spec(compiler_spec, arch_spec):
|
|||||||
if len(compilers) < 1:
|
if len(compilers) < 1:
|
||||||
raise NoCompilerForSpecError(compiler_spec, arch_spec.os)
|
raise NoCompilerForSpecError(compiler_spec, arch_spec.os)
|
||||||
if len(compilers) > 1:
|
if len(compilers) > 1:
|
||||||
raise CompilerDuplicateError(compiler_spec, arch_spec)
|
msg = 'Multiple definitions of compiler %s' % compiler_spec
|
||||||
|
msg += 'for architecture %s:\n %s' % (arch_spec, compilers)
|
||||||
|
tty.debug(msg)
|
||||||
return compilers[0]
|
return compilers[0]
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,6 +50,32 @@ class MockOs(object):
|
|||||||
return _factory
|
return _factory
|
||||||
|
|
||||||
|
|
||||||
|
def test_multiple_conflicting_compiler_definitions(mutable_config):
|
||||||
|
compiler_def = {
|
||||||
|
'compiler': {
|
||||||
|
'flags': {},
|
||||||
|
'modules': [],
|
||||||
|
'paths': {
|
||||||
|
'cc': 'cc',
|
||||||
|
'cxx': 'cxx',
|
||||||
|
'f77': 'null',
|
||||||
|
'fc': 'null'},
|
||||||
|
'extra_rpaths': [],
|
||||||
|
'operating_system': 'test',
|
||||||
|
'target': 'test',
|
||||||
|
'environment': {},
|
||||||
|
'spec': 'clang@0.0.0'}}
|
||||||
|
|
||||||
|
compiler_config = [compiler_def, compiler_def]
|
||||||
|
compiler_config[0]['compiler']['paths']['f77'] = 'f77'
|
||||||
|
mutable_config.update_config('compilers', compiler_config)
|
||||||
|
|
||||||
|
arch_spec = spack.spec.ArchSpec('test', 'test', 'test')
|
||||||
|
cspec = compiler_config[0]['compiler']['spec']
|
||||||
|
cmp = compilers.compiler_for_spec(cspec, arch_spec)
|
||||||
|
assert cmp.f77 == 'f77'
|
||||||
|
|
||||||
|
|
||||||
def test_get_compiler_duplicates(config):
|
def test_get_compiler_duplicates(config):
|
||||||
# In this case there is only one instance of the specified compiler in
|
# In this case there is only one instance of the specified compiler in
|
||||||
# the test configuration (so it is not actually a duplicate), but the
|
# the test configuration (so it is not actually a duplicate), but the
|
||||||
|
Loading…
Reference in New Issue
Block a user