summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGreg Becker <becker33@llnl.gov>2019-07-20 02:42:12 -0500
committerTodd Gamblin <tgamblin@llnl.gov>2019-07-20 00:42:12 -0700
commit8ec098716b977544ed16eb45cfa78f74d19f51ff (patch)
treef63db87c4ba19d15b95d8f99695400459f052ae1 /lib
parent993ee7f199063890cbd0589c377c8da059cf6f05 (diff)
downloadspack-8ec098716b977544ed16eb45cfa78f74d19f51ff.tar.gz
spack-8ec098716b977544ed16eb45cfa78f74d19f51ff.tar.bz2
spack-8ec098716b977544ed16eb45cfa78f74d19f51ff.tar.xz
spack-8ec098716b977544ed16eb45cfa78f74d19f51ff.zip
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/compilers/__init__.py4
-rw-r--r--lib/spack/spack/test/compilers.py26
2 files changed, 29 insertions, 1 deletions
diff --git a/lib/spack/spack/compilers/__init__.py b/lib/spack/spack/compilers/__init__.py
index 84f767d1dd..5adfd17b1a 100644
--- a/lib/spack/spack/compilers/__init__.py
+++ b/lib/spack/spack/compilers/__init__.py
@@ -383,7 +383,9 @@ def compiler_for_spec(compiler_spec, arch_spec):
if len(compilers) < 1:
raise NoCompilerForSpecError(compiler_spec, arch_spec.os)
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]
diff --git a/lib/spack/spack/test/compilers.py b/lib/spack/spack/test/compilers.py
index 1b66b692e0..84233d604f 100644
--- a/lib/spack/spack/test/compilers.py
+++ b/lib/spack/spack/test/compilers.py
@@ -50,6 +50,32 @@ def make_args_for_version(monkeypatch):
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):
# 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