summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2021-01-05 15:42:22 +0100
committerTodd Gamblin <tgamblin@llnl.gov>2021-01-05 16:59:15 -0800
commit0111a18b23e847021f0ef17fdcb2d3dca25005d6 (patch)
tree39eedcf11de469321f3b66035a9dd3cccf4e05f8
parent67ce1939a32fd2c90f989087a07aa0723f254063 (diff)
downloadspack-0111a18b23e847021f0ef17fdcb2d3dca25005d6.tar.gz
spack-0111a18b23e847021f0ef17fdcb2d3dca25005d6.tar.bz2
spack-0111a18b23e847021f0ef17fdcb2d3dca25005d6.tar.xz
spack-0111a18b23e847021f0ef17fdcb2d3dca25005d6.zip
concretizer: make rules on virtual packages more linear
fixes #20679 In this refactor we have a single cardinality rule on the provider, which triggers a rule transforming a dependency on a virtual package into a dependency on the provider of the virtual.
-rw-r--r--lib/spack/spack/solver/concretize.lp20
1 files changed, 9 insertions, 11 deletions
diff --git a/lib/spack/spack/solver/concretize.lp b/lib/spack/spack/solver/concretize.lp
index a5ff15b6ce..c673c65d19 100644
--- a/lib/spack/spack/solver/concretize.lp
+++ b/lib/spack/spack/solver/concretize.lp
@@ -137,22 +137,21 @@ attr(Name, Arg1, Arg2, Arg3) :-
%-----------------------------------------------------------------------------
% Virtual dependencies
%-----------------------------------------------------------------------------
-% if you declare a dependency on a virtual AND the package is not an external,
-% you depend on one of its providers
-1 {
- depends_on(Package, Provider, Type) : possible_provider(Provider, Virtual)
-} 1
+
+% 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
+depends_on(Package, Provider, Type)
:- dependency_conditions(Package, Virtual, Type),
- virtual(Virtual),
+ provides_virtual(Provider, Virtual),
not external(Package).
-% if a virtual was required by some package, one provider is in the DAG
-1 { node(Package) : provider(Package, Virtual) } 1
+% if there's a virtual node, we must select one provider
+1 { provides_virtual(Package, Virtual) : possible_provider(Package, Virtual) } 1
:- virtual_node(Virtual).
% virtual roots imply virtual nodes, and that one provider is a root
virtual_node(Virtual) :- virtual_root(Virtual).
-1 { root(Package) : possible_provider(Package, Virtual) } 1
+1 { root(Package) : provides_virtual(Package, Virtual) } 1
:- virtual_root(Virtual).
% all virtual providers come from provider conditions like this
@@ -179,8 +178,7 @@ virtual_node(Virtual)
virtual(Virtual), not external(Package).
% for any virtual, there can be at most one provider in the DAG
-0 { provider(Package, Virtual) :
- node(Package), provides_virtual(Package, Virtual) } 1 :- virtual(Virtual).
+0 { node(Package) : provides_virtual(Package, Virtual) } 1 :- virtual(Virtual).
%-----------------------------------------------------------------------------
% Virtual dependency weights