diff options
author | Massimiliano Culpo <massimiliano.culpo@gmail.com> | 2020-02-20 21:20:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-20 12:20:12 -0800 |
commit | d1929b2ea7a3dd694ede128520cd07bd3183ad47 (patch) | |
tree | 5d77873a5159557e515edfce8d7c3de3ef2d8160 | |
parent | a1e3a1653a5772f6b4d119b0778e662ea3177026 (diff) | |
download | spack-d1929b2ea7a3dd694ede128520cd07bd3183ad47.tar.gz spack-d1929b2ea7a3dd694ede128520cd07bd3183ad47.tar.bz2 spack-d1929b2ea7a3dd694ede128520cd07bd3183ad47.tar.xz spack-d1929b2ea7a3dd694ede128520cd07bd3183ad47.zip |
Compilers require an exact match on version during concretization (#14752)
Spack now requires an exact match of the compiler version
requested by the user. A loose constraint can be given to
Spack by using a version range instead of a concrete version
(e.g. 4.5: instead of 4.5).
-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' |