Skip to content

Commit 0e6cf94

Browse files
committed
cargo: make filenames predictable
source_id changes based on innocuous things like the path of the work directory. This breaks sstate badly, because two builds with the same inputs will produce different, incompatible outputs. Removing source_id from the hash calculation makes the value stable enough for sstate.
1 parent 852263e commit 0e6cf94

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

recipes-devtools/cargo/cargo.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ DEPENDS = "openssl zlib libgit2 curl ca-certificates libssh2"
1010

1111
SRC_URI = "\
1212
http://static-rust-lang-org.s3.amazonaws.com/cargo-dist/${CARGO_SNAPSHOT} \
13+
file://0001-Don-t-hash-source_id.patch \
1314
"
1415

1516
B = "${S}"
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
From a65784be8fdbc7dffa6d568bcc364cb67655ebfe Mon Sep 17 00:00:00 2001
2+
From: Steven Walter <stevenrwalter@gmail.com>
3+
Date: Fri, 27 Jan 2017 11:24:57 -0500
4+
Subject: [PATCH] Don't hash source_id
5+
6+
This makes hashes reproducible when building directly in the source as
7+
well as from a registry. Reproducible file names are necessary for
8+
linking against externally built crates.
9+
---
10+
src/cargo/core/package_id.rs | 1 -
11+
1 file changed, 1 deletion(-)
12+
13+
diff --git a/src/cargo/core/package_id.rs b/src/cargo/core/package_id.rs
14+
index b29b8ca..7691d38 100644
15+
--- a/src/cargo/core/package_id.rs
16+
+++ b/src/cargo/core/package_id.rs
17+
@@ -66,7 +66,6 @@ impl Hash for PackageId {
18+
fn hash<S: hash::Hasher>(&self, state: &mut S) {
19+
self.inner.name.hash(state);
20+
self.inner.version.hash(state);
21+
- self.inner.source_id.hash(state);
22+
}
23+
}
24+
25+
--
26+
2.7.4
27+

0 commit comments

Comments
 (0)