From: Alejandro Hernandez <alhe@linux.microsoft.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH v3] rust: Avoid passing host-specific information to crates Strict Version Hash
Date: Wed, 26 Aug 2026 15:54:17 +0000 [thread overview]
Message-ID: <20260826155417.2774608-1-alhe@linux.microsoft.com> (raw)
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
next reply other threads:[~2026-08-26 15:54 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-26 15:54 Alejandro Hernandez [this message]
2026-08-26 18:25 ` [PATCH v3] rust: Avoid passing host-specific information to crates Strict Version Hash 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260826155417.2774608-1-alhe@linux.microsoft.com \
--to=alhe@linux.microsoft.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox