summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2023-11-03 12:56:37 +0100
committerGitHub <noreply@github.com>2023-11-03 12:56:37 +0100
commitdb16335aec9add0ce838f9fcd4eb426352e35b07 (patch)
tree3ebb714fcb129f89757440b49e1cc01d9ffb6045 /lib
parent3082ce6a22b1c1356da533a26225150298264a4b (diff)
downloadspack-db16335aec9add0ce838f9fcd4eb426352e35b07.tar.gz
spack-db16335aec9add0ce838f9fcd4eb426352e35b07.tar.bz2
spack-db16335aec9add0ce838f9fcd4eb426352e35b07.tar.xz
spack-db16335aec9add0ce838f9fcd4eb426352e35b07.zip
ASP-based solver: fix for unsplittable providers (#40859)
Some providers must provide virtuals "together", i.e. if they provide one virtual of a set, they must be the providers also of the others. There was a bug though, where we were not checking if the other virtuals in the set were needed at all in the DAG. This commit fixes the bug.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/solver/concretize.lp4
-rw-r--r--lib/spack/spack/test/concretize.py13
2 files changed, 16 insertions, 1 deletions
diff --git a/lib/spack/spack/solver/concretize.lp b/lib/spack/spack/solver/concretize.lp
index b5a9ebf77a..2207fa9f9a 100644
--- a/lib/spack/spack/solver/concretize.lp
+++ b/lib/spack/spack/solver/concretize.lp
@@ -492,7 +492,9 @@ error(100, "Package '{0}' needs to provide both '{1}' and '{2}' together, but pr
pkg_fact(Package, provided_together(ID, SetID, Virtual2)),
Virtual1 != Virtual2,
attr("virtual_on_incoming_edges", node(X, Package), Virtual1),
- not attr("virtual_on_incoming_edges", node(X, Package), Virtual2).
+ not attr("virtual_on_incoming_edges", node(X, Package), Virtual2),
+ attr("virtual_node", node(_, Virtual1)),
+ attr("virtual_node", node(_, Virtual2)).
% if a package depends on a virtual, it's not external and we have a
% provider for that virtual then it depends on the provider
diff --git a/lib/spack/spack/test/concretize.py b/lib/spack/spack/test/concretize.py
index 1dd530ac70..915f6ca39b 100644
--- a/lib/spack/spack/test/concretize.py
+++ b/lib/spack/spack/test/concretize.py
@@ -2360,3 +2360,16 @@ class TestConcretizeEdges:
for not_expected in expected_not_satisfies:
assert not s.satisfies(not_expected), str(not_expected)
+
+ def test_virtuals_provided_together_but_only_one_required_in_dag(self):
+ """Tests that we can use a provider that provides more than one virtual together,
+ and is providing only one, iff the others are not needed in the DAG.
+
+ o blas-only-client
+ | [virtual=blas]
+ o openblas (provides blas and lapack together)
+
+ """
+ s = Spec("blas-only-client ^openblas").concretized()
+ assert s.satisfies("^[virtuals=blas] openblas")
+ assert not s.satisfies("^[virtuals=blas,lapack] openblas")