diff mbox series

[v2] rust: Avoid passing host-specific information to crates Strict Version Hash

Message ID 20260824235606.4035992-1-alhe@linux.microsoft.com
State New
Headers show
Series [v2] rust: Avoid passing host-specific information to crates Strict Version Hash | expand

Commit Message

Alejandro Hernandez Aug. 24, 2026, 11:56 p.m. UTC
rustc computes each crate's Strict Version Hash (SVH) using inputs that include
the *stage0/stage1 bootstrap compiler* fingerprint, which in turn depends on the
build host arch.

This eventually may cause sstate matches across architectures for artifacts that
are actually different, causing autobuilder intermitent reproducibility issues.

To avoid this, pass a fixed value instead of host-specific bits to the specified
hash.

[YOCTO #15554]

Assisted-by: AI - OpenAI
Signed-off-by: Alejandro Hernandez <alhe@linux.microsoft.com>
---
 ...ide-cfg-version-from-stable-crate-id.patch | 20 +++++++++++++++++++
 meta/recipes-devtools/rust/rust-source.inc    |  1 +
 2 files changed, 21 insertions(+)
 create mode 100644 meta/recipes-devtools/rust/files/0003-rustc-span-add-oe-knob-to-elide-cfg-version-from-stable-crate-id.patch
diff mbox series

Patch

diff --git a/meta/recipes-devtools/rust/files/0003-rustc-span-add-oe-knob-to-elide-cfg-version-from-stable-crate-id.patch b/meta/recipes-devtools/rust/files/0003-rustc-span-add-oe-knob-to-elide-cfg-version-from-stable-crate-id.patch
new file mode 100644
index 0000000000..8409d49bbe
--- /dev/null
+++ b/meta/recipes-devtools/rust/files/0003-rustc-span-add-oe-knob-to-elide-cfg-version-from-stable-crate-id.patch
@@ -0,0 +1,20 @@ 
+rust: Avoid passing host-dependent fingerprint to build artifacts
+
+To fix reproducibility issues, pass a fixed value instead of passing a
+host-dependent fingerprint to the rust build artifacts via the Strict
+Version Hash (SVH)
+
+Upstream-Status: Inappropriate [OE-specific reproducibility policy]
+Signed-off-by: Alejandro Hernandez <alhe@linux.microsoft.com>
+---
+--- a/compiler/rustc_span/src/def_id.rs
++++ b/compiler/rustc_span/src/def_id.rs
+@@ -186,5 +186,3 @@
+-        if let Some(val) = std::env::var_os("RUSTC_FORCE_RUSTC_VERSION") {
+-            hasher.write(val.to_string_lossy().into_owned().as_bytes())
+-        } else {
+-            hasher.write(cfg_version.as_bytes())
+-        }
++        // OE reproducible builds use a fixed value so host-varying bootstrap
++        // fingerprints do not perturb StableCrateId.
++        hasher.write(b"oe-stable-crate-id-no-cfg-version")
diff --git a/meta/recipes-devtools/rust/rust-source.inc b/meta/recipes-devtools/rust/rust-source.inc
index 68f3009a7b..2bff69de3d 100644
--- a/meta/recipes-devtools/rust/rust-source.inc
+++ b/meta/recipes-devtools/rust/rust-source.inc
@@ -6,6 +6,7 @@  SRC_URI += "https://static.rust-lang.org/dist/rustc-${RUST_VERSION}-src.tar.xz;n
             file://repro-issue-fix-with-cc-crate-hashmap.patch;patchdir=${RUSTSRC} \
             file://0001-src-core-build_steps-tool.rs-switch-off-lto-for-rust.patch;patchdir=${RUSTSRC} \
             file://0002-Fix-rust-build-failure-with-unstable-options.patch;patchdir=${RUSTSRC} \
+            file://0003-rustc-span-add-oe-knob-to-elide-cfg-version-from-stable-crate-id.patch;patchdir=${RUSTSRC} \
 "
 SRC_URI[rust.sha256sum] = "0ed06fdaffd4722a7702e0b4eebfafc897ab8f513e8e1b247cdd7e5c6df6ded2"