1From 065d7c263091118437465d714d8a29dbb6296921 Mon Sep 17 00:00:00 2001
2From: Alexander Kanavin <alex@linutronix.de>
3Date: Mon, 13 May 2024 14:57:54 +0200
4Subject: [PATCH] cargo: do not write host information into compilation unit
5 hashes
6
7This breaks reproducibility in cross-builds where the cross-target
8can be the same, but build hosts are different, as seen with
9"rustc --version -v":
10...
11host: x86_64-unknown-linux-gnu
12
13vs.
14
15host: aarch64-unknown-linux-gnu
16
17This can possibly be improved by only hashing host info if the build
18is a native one (e.g. there's no --target option passed to cargo
19invocation) but I'm not sure how.
20
21Upstream-Status: Inappropriate [reported at https://github.com/rust-lang/cargo/issues/13922]
22Signed-off-by: Alexander Kanavin <alex@linutronix.de>
23---
24 .../src/cargo/core/compiler/context/compilation_files.rs      | 4 ++--
25 1 file changed, 2 insertions(+), 2 deletions(-)
26
27diff --git a/src/tools/cargo/src/cargo/core/compiler/context/compilation_files.rs b/src/tools/cargo/src/cargo/core/compiler/context/compilation_files.rs
28index d83dbf10c..b2ad8d9f3 100644
29--- a/src/tools/cargo/src/cargo/core/compiler/context/compilation_files.rs
30+++ b/src/tools/cargo/src/cargo/core/compiler/context/compilation_files.rs
31@@ -652,7 +652,7 @@ fn hash_rustc_version(bcx: &BuildContext<'_, '_>, hasher: &mut StableHasher) {
32     if vers.pre.is_empty() || bcx.config.cli_unstable().separate_nightlies {
33         // For stable, keep the artifacts separate. This helps if someone is
34         // testing multiple versions, to avoid recompiles.
35-        bcx.rustc().verbose_version.hash(hasher);
36+        //bcx.rustc().verbose_version.hash(hasher);
37         return;
38     }
39     // On "nightly"/"beta"/"dev"/etc, keep each "channel" separate. Don't hash
40@@ -665,7 +665,7 @@ fn hash_rustc_version(bcx: &BuildContext<'_, '_>, hasher: &mut StableHasher) {
41     // Keep "host" since some people switch hosts to implicitly change
42     // targets, (like gnu vs musl or gnu vs msvc). In the future, we may want
43     // to consider hashing `unit.kind.short_name()` instead.
44-    bcx.rustc().host.hash(hasher);
45+    //bcx.rustc().host.hash(hasher);
46     // None of the other lines are important. Currently they are:
47     // binary: rustc  <-- or "rustdoc"
48     // commit-hash: 38114ff16e7856f98b2b4be7ab4cd29b38bed59a
49--
502.39.2
51
52