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