diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/concretize.py | 15 | ||||
-rw-r--r-- | lib/spack/spack/test/concretize.py | 13 |
2 files changed, 26 insertions, 2 deletions
diff --git a/lib/spack/spack/concretize.py b/lib/spack/spack/concretize.py index 8814d03d06..e460f45600 100644 --- a/lib/spack/spack/concretize.py +++ b/lib/spack/spack/concretize.py @@ -362,7 +362,16 @@ class Concretizer(object): # compiler_for_spec Should think whether this can be more # efficient def _proper_compiler_style(cspec, aspec): - return spack.compilers.compilers_for_spec(cspec, arch_spec=aspec) + compilers = spack.compilers.compilers_for_spec( + cspec, arch_spec=aspec + ) + # If the spec passed as argument is concrete we want to check + # the versions match exactly + if (cspec.concrete and compilers and + cspec.version not in [c.version for c in compilers]): + return [] + + return compilers if spec.compiler and spec.compiler.concrete: if (self.check_for_compiler_existence and not @@ -403,7 +412,9 @@ class Concretizer(object): return True else: # No compiler with a satisfactory spec was found - raise UnavailableCompilerVersionError(other_compiler) + raise UnavailableCompilerVersionError( + other_compiler, spec.architecture + ) else: # We have no hints to go by, grab any compiler compiler_list = spack.compilers.all_compiler_specs() diff --git a/lib/spack/spack/test/concretize.py b/lib/spack/spack/test/concretize.py index 72092a956f..9024c99cad 100644 --- a/lib/spack/spack/test/concretize.py +++ b/lib/spack/spack/test/concretize.py @@ -620,3 +620,16 @@ class TestConcretize(object): with spack.concretize.disable_compiler_existence_check(): s = Spec(spec).concretized() assert str(s.architecture.target) == str(expected) + + @pytest.mark.regression('8735,14730') + def test_compiler_version_matches_any_entry_in_compilers_yaml(self): + # Ensure that a concrete compiler with different compiler version + # doesn't match (here it's 4.5 vs. 4.5.0) + with pytest.raises(spack.concretize.UnavailableCompilerVersionError): + s = Spec('mpileaks %gcc@4.5') + s.concretize() + + # An abstract compiler with a version list could resolve to 4.5.0 + s = Spec('mpileaks %gcc@4.5:') + s.concretize() + assert str(s.compiler.version) == '4.5.0' |