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).
This commit is contained in:
parent
a1e3a1653a
commit
d1929b2ea7
@ -362,7 +362,16 @@ def concretize_compiler(self, spec):
|
||||
# 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 @@ def _proper_compiler_style(cspec, aspec):
|
||||
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()
|
||||
|
@ -620,3 +620,16 @@ def test_adjusting_default_target_based_on_compiler(
|
||||
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'
|
||||
|
Loading…
Reference in New Issue
Block a user