summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2024-04-29 08:20:33 +0200
committerGitHub <noreply@github.com>2024-04-29 08:20:33 +0200
commitddabb8b12c8f1fe2463736444dcd4d5c2c6d601d (patch)
treef18040fb779e26ecb81b2e47695295322d8d3aa4
parent16bba321248673f514a4b4932bded145311f9f0d (diff)
downloadspack-ddabb8b12c8f1fe2463736444dcd4d5c2c6d601d.tar.gz
spack-ddabb8b12c8f1fe2463736444dcd4d5c2c6d601d.tar.bz2
spack-ddabb8b12c8f1fe2463736444dcd4d5c2c6d601d.tar.xz
spack-ddabb8b12c8f1fe2463736444dcd4d5c2c6d601d.zip
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.
-rw-r--r--lib/spack/spack/solver/asp.py10
-rw-r--r--lib/spack/spack/test/concretize.py21
2 files changed, 29 insertions, 2 deletions
diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py
index 2b86200a30..b3be999a1b 100644
--- a/lib/spack/spack/solver/asp.py
+++ b/lib/spack/spack/solver/asp.py
@@ -2519,12 +2519,18 @@ class SpackSolverSetup:
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",
diff --git a/lib/spack/spack/test/concretize.py b/lib/spack/spack/test/concretize.py
index 3bbd9e5bb8..f69ab54a58 100644
--- a/lib/spack/spack/test/concretize.py
+++ b/lib/spack/spack/test/concretize.py
@@ -24,6 +24,7 @@ import spack.hash_types as ht
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 @@ class TestConcretize:
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():