Skip to content
Snippets Groups Projects
Unverified Commit d1929b2e authored by Massimiliano Culpo's avatar Massimiliano Culpo Committed by GitHub
Browse files

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).
parent a1e3a165
No related branches found
No related tags found
No related merge requests found
...@@ -362,7 +362,16 @@ def concretize_compiler(self, spec): ...@@ -362,7 +362,16 @@ def concretize_compiler(self, spec):
# compiler_for_spec Should think whether this can be more # compiler_for_spec Should think whether this can be more
# efficient # efficient
def _proper_compiler_style(cspec, aspec): 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 spec.compiler and spec.compiler.concrete:
if (self.check_for_compiler_existence and not if (self.check_for_compiler_existence and not
...@@ -403,7 +412,9 @@ def _proper_compiler_style(cspec, aspec): ...@@ -403,7 +412,9 @@ def _proper_compiler_style(cspec, aspec):
return True return True
else: else:
# No compiler with a satisfactory spec was found # No compiler with a satisfactory spec was found
raise UnavailableCompilerVersionError(other_compiler) raise UnavailableCompilerVersionError(
other_compiler, spec.architecture
)
else: else:
# We have no hints to go by, grab any compiler # We have no hints to go by, grab any compiler
compiler_list = spack.compilers.all_compiler_specs() compiler_list = spack.compilers.all_compiler_specs()
......
...@@ -620,3 +620,16 @@ def test_adjusting_default_target_based_on_compiler( ...@@ -620,3 +620,16 @@ def test_adjusting_default_target_based_on_compiler(
with spack.concretize.disable_compiler_existence_check(): with spack.concretize.disable_compiler_existence_check():
s = Spec(spec).concretized() s = Spec(spec).concretized()
assert str(s.architecture.target) == str(expected) 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'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment