Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH v3] rust: Avoid passing host-specific information to crates Strict Version Hash
@ 2026-08-26 15:54 Alejandro Hernandez
  2026-08-26 18:25 ` Dora, Sunil Kumar
  0 siblings, 1 reply; 9+ messages in thread
From: Alejandro Hernandez @ 2026-08-26 15:54 UTC (permalink / raw)
  To: openembedded-core

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 | 35 +++++++++++++++++++
 meta/recipes-devtools/rust/rust-source.inc    |  1 +
 2 files changed, 36 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 --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..f9d171df75
--- /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,35 @@
+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
+@@ -163,7 +163,7 @@
+         crate_name: Symbol,
+         is_exe: bool,
+         mut metadata: Vec<String>,
+-        cfg_version: &'static str,
++        _cfg_version: &'static str,
+     ) -> StableCrateId {
+         let mut hasher = StableHasher::new();
+         // We must hash the string text of the crate name, not the id, as the id is not stable
+@@ -195,11 +195,9 @@
+         //
+         // RUSTC_FORCE_RUSTC_VERSION is used to inject rustc version information
+         // during testing.
+-        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");
+ 
+         StableCrateId(hasher.finish())
+     }
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"
 
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-09-03 18:40 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-26 15:54 [PATCH v3] rust: Avoid passing host-specific information to crates Strict Version Hash Alejandro Hernandez
2026-08-26 18:25 ` Dora, Sunil Kumar
2026-08-26 19:17   ` [OE-core] " Richard Purdie
2026-08-26 20:08     ` Alejandro Hernandez
2026-08-26 20:47       ` Richard Purdie
     [not found]       ` <18CF75EE37DB8543.642712@lists.openembedded.org>
2026-08-27  7:53         ` Richard Purdie
2026-08-28 15:46           ` Alejandro Hernandez
2026-08-28 17:56             ` Richard Purdie
2026-09-03 18:40               ` Dora, Sunil Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox