Fix concretization when installing missing compilers (#43876)
Restore the previous behavior when config:install_missing_compilers is True. The libc of the missing compiler is inferred from the Python process.
This commit is contained in:
parent
16bba32124
commit
ddabb8b12c
2 changed files with 29 additions and 2 deletions
|
@ -2519,12 +2519,18 @@ def define_runtime_constraints(self):
|
|||
if not compiler.available:
|
||||
continue
|
||||
|
||||
if using_libc_compatibility() and compiler.compiler_obj.default_libc:
|
||||
current_libc = compiler.compiler_obj.default_libc
|
||||
# If this is a compiler yet to be built (config:install_missing_compilers:true)
|
||||
# infer libc from the Python process
|
||||
if not current_libc and compiler.compiler_obj.cc is None:
|
||||
current_libc = spack.util.libc.libc_from_current_python_process()
|
||||
|
||||
if using_libc_compatibility() and current_libc:
|
||||
recorder("*").depends_on(
|
||||
"libc", when=f"%{compiler.spec}", type="link", description="Add libc"
|
||||
)
|
||||
recorder("*").depends_on(
|
||||
str(compiler.compiler_obj.default_libc),
|
||||
str(current_libc),
|
||||
when=f"%{compiler.spec}",
|
||||
type="link",
|
||||
description="Add libc",
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
import spack.platforms
|
||||
import spack.repo
|
||||
import spack.solver.asp
|
||||
import spack.util.libc
|
||||
import spack.variant as vt
|
||||
from spack.concretize import find_spec
|
||||
from spack.spec import CompilerSpec, Spec
|
||||
|
@ -2427,6 +2428,26 @@ def test_externals_with_platform_explicitly_set(self, tmp_path):
|
|||
s = Spec("mpich").concretized()
|
||||
assert s.external
|
||||
|
||||
@pytest.mark.regression("43875")
|
||||
def test_concretize_missing_compiler(self, mutable_config, monkeypatch):
|
||||
"""Tests that Spack can concretize a spec with a missing compiler when the
|
||||
option is active.
|
||||
"""
|
||||
|
||||
def _default_libc(self):
|
||||
if self.cc is None:
|
||||
return None
|
||||
return Spec("glibc@=2.28")
|
||||
|
||||
monkeypatch.setattr(spack.concretize.Concretizer, "check_for_compiler_existence", False)
|
||||
monkeypatch.setattr(spack.compiler.Compiler, "default_libc", property(_default_libc))
|
||||
monkeypatch.setattr(
|
||||
spack.util.libc, "libc_from_current_python_process", lambda: Spec("glibc@=2.28")
|
||||
)
|
||||
mutable_config.set("config:install_missing_compilers", True)
|
||||
s = Spec("a %gcc@=13.2.0").concretized()
|
||||
assert s.satisfies("%gcc@13.2.0")
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def duplicates_test_repository():
|
||||
|
|
Loading…
Reference in a new issue