summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2020-11-05 15:04:54 +0100
committerTodd Gamblin <tgamblin@llnl.gov>2020-11-17 10:04:13 -0800
commit2231dfc89826f64d7ccdd7a9f9559cf417817688 (patch)
tree3f2372facc5f2636444434810ea082c0c6b9af21 /lib
parent522be6cadfadc7c69a3cee75a78a3c440c34bca6 (diff)
downloadspack-2231dfc89826f64d7ccdd7a9f9559cf417817688.tar.gz
spack-2231dfc89826f64d7ccdd7a9f9559cf417817688.tar.bz2
spack-2231dfc89826f64d7ccdd7a9f9559cf417817688.tar.xz
spack-2231dfc89826f64d7ccdd7a9f9559cf417817688.zip
concretizer: add a rule to avoid cycles in the graph of dependencies
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/solver/concretize.lp5
-rw-r--r--lib/spack/spack/spec.py9
2 files changed, 9 insertions, 5 deletions
diff --git a/lib/spack/spack/solver/concretize.lp b/lib/spack/spack/solver/concretize.lp
index bf1d07a63d..9f8ab81161 100644
--- a/lib/spack/spack/solver/concretize.lp
+++ b/lib/spack/spack/solver/concretize.lp
@@ -111,6 +111,11 @@ needed(Dependency) :- needed(Package), depends_on(Package, Dependency).
% real dependencies imply new nodes.
node(Dependency) :- node(Package), depends_on(Package, Dependency).
+% Avoid cycles in the DAG
+path(Parent, Child) :- depends_on(Parent, Child).
+path(Parent, Descendant) :- path(Parent, A), depends_on(A, Descendant).
+:- path(A, B), path(B, A).
+
% do not warn if generated program contains none of these.
#defined depends_on/3.
#defined declared_dependency/3.
diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py
index 127091d8da..8a4fc12861 100644
--- a/lib/spack/spack/spec.py
+++ b/lib/spack/spack/spec.py
@@ -2372,11 +2372,10 @@ class Spec(object):
patches = []
for cond, dependency in pkg_deps[dspec.spec.name].items():
- if dspec.parent.satisfies(cond, strict=True):
- for pcond, patch_list in dependency.patches.items():
- if dspec.spec.satisfies(pcond):
- for patch in patch_list:
- patches.append(patch)
+ for pcond, patch_list in dependency.patches.items():
+ if (dspec.parent.satisfies(cond, strict=True)
+ and dspec.spec.satisfies(pcond)):
+ patches.extend(patch_list)
if patches:
all_patches = spec_to_patches.setdefault(id(dspec.spec), [])
all_patches.extend(patches)