Adding the type "build" to a dependency with another type results in a change in the hash. Adding a "build" type only dependency instead doesn't affect the hash.
Steps to reproduce the issue
Change the xz package adding a:
depends_on('zlib', type='link')
and check the dag hash and dependency types by:
$ spack spec -lt xz
Input spec
--------------------------------
[ ] xz
Concretized
--------------------------------
ry7x4qn [ ] xz@5.2.5%gcc@10.1.0~pic arch=linux-ubuntu18.04-broadwell
kepdmuv [ l ] ^zlib@1.2.11%gcc@10.1.0+optimize+pic+shared arch=linux-ubuntu18.04-broadwell
Now modify the directive above into:
This results in:
$ spack spec -lt xz
Input spec
--------------------------------
[ ] xz
Concretized
--------------------------------
eaa3ko3 [ ] xz@5.2.5%gcc@10.1.0~pic arch=linux-ubuntu18.04-broadwell
kepdmuv [bl ] ^zlib@1.2.11%gcc@10.1.0+optimize+pic+shared arch=linux-ubuntu18.04-broadwell
Error Message
No error message, but an unexpected behavior.
Information on your system
- Spack: 0.16.0-1128-39a429b2a3
- Python: 3.8.5
- Platform: linux-ubuntu18.04-broadwell
- Concretizer: original
Additional information
This diff seems to make the hash computation invariant with respect to build type edges, regardless of other types that may be applied to the same edge:
diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py
index 06767d6c7d..4d0550add1 100644
--- a/lib/spack/spack/spec.py
+++ b/lib/spack/spack/spec.py
@@ -1633,13 +1633,18 @@ def to_node_dict(self, hash=ht.dag_hash):
deps = self.dependencies_dict(deptype=hash.deptype)
if deps:
- d['dependencies'] = syaml.syaml_dict([
+ sorted_items = [x for x in sorted(deps.items())]
+ entries = [
(name,
syaml.syaml_dict([
('hash', dspec.spec._cached_hash(hash)),
- ('type', sorted(str(s) for s in dspec.deptypes))])
- ) for name, dspec in sorted(deps.items())
- ])
+ ('type', sorted(str(s) for s in dspec.deptypes
+ if str(s) in hash.deptype)
+ )])
+ ) for name, dspec in sorted_items
+ ]
+ dependency_dictionary = syaml.syaml_dict(entries)
+ d['dependencies'] = dependency_dictionary
It makes a lot of tests fail though, so further modifications may be needed.
Adding the type "build" to a dependency with another type results in a change in the hash. Adding a "build" type only dependency instead doesn't affect the hash.
Steps to reproduce the issue
Change the
xzpackage adding a:and check the dag hash and dependency types by:
Now modify the directive above into:
This results in:
Error Message
No error message, but an unexpected behavior.
Information on your system
Additional information
This diff seems to make the hash computation invariant with respect to build type edges, regardless of other types that may be applied to the same edge:
It makes a lot of tests fail though, so further modifications may be needed.
spack debug reportand reported the version of Spack/Python/Platform