summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
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)