summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/solver/asp.py6
-rw-r--r--lib/spack/spack/test/concretize.py22
2 files changed, 28 insertions, 0 deletions
diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py
index f0437b9309..8c9108fea9 100644
--- a/lib/spack/spack/solver/asp.py
+++ b/lib/spack/spack/solver/asp.py
@@ -1463,6 +1463,12 @@ class SpackSolverSetup(object):
if concrete_build_deps or dtype != "build":
clauses.append(fn.depends_on(spec.name, dep.name, dtype))
+ # Ensure Spack will not coconcretize this with another provider
+ # for the same virtual
+ for virtual in dep.package.virtuals_provided:
+ clauses.append(fn.virtual_node(virtual.name))
+ clauses.append(fn.provider(dep.name, virtual.name))
+
# imposing hash constraints for all but pure build deps of
# already-installed concrete specs.
if concrete_build_deps or dspec.deptypes != ("build",):
diff --git a/lib/spack/spack/test/concretize.py b/lib/spack/spack/test/concretize.py
index b943fad755..ab3337da5e 100644
--- a/lib/spack/spack/test/concretize.py
+++ b/lib/spack/spack/test/concretize.py
@@ -1706,6 +1706,28 @@ class TestConcretize(object):
counter += 1
assert counter == occurances, concrete_specs
+ def test_coconcretize_reuse_and_virtuals(self):
+ import spack.solver.asp
+
+ if spack.config.get("config:concretizer") == "original":
+ pytest.skip("Original concretizer cannot reuse")
+
+ reusable_specs = []
+ for s in ["mpileaks ^mpich", "zmpi"]:
+ reusable_specs.extend(spack.spec.Spec(s).concretized().traverse(root=True))
+
+ root_specs = [spack.spec.Spec("mpileaks"), spack.spec.Spec("zmpi")]
+
+ import spack.solver.asp
+
+ with spack.config.override("concretizer:reuse", True):
+ solver = spack.solver.asp.Solver()
+ setup = spack.solver.asp.SpackSolverSetup()
+ result, _, _ = solver.driver.solve(setup, root_specs, reuse=reusable_specs)
+
+ for spec in result.specs:
+ assert "zmpi" in spec
+
@pytest.mark.regression("30864")
def test_misleading_error_message_on_version(self, mutable_database):
# For this bug to be triggered we need a reusable dependency