rust: Avoid passing host-specific information to crates Strict Version Hash
PATCH v3 1/1 rust: Avoid passing host-specific information to crates Strict Version Hash
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]
--- ...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
meta/recipes-devtools/rust/files/0003-rustc-span-add-oe-knob-to-elide-cfg-version-from-stable-crate-id.patch new file +35 -0
@@ -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 <[email protected]> +--- +--- 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()) + }
meta/recipes-devtools/rust/rust-source.inc +1 -0
@@ -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"
Signature · 1 line
2.43.0
Hi Alejandro,
Thanks for chasing this one down. Small notes on v3:
The commit is tagged [YOCTO #15554], but that bug is "reproducibility failures with 'rustdoc' on rust 1.75" (path-length dependent), RESOLVED FIXED since 2024-08-01 via codegen-units=1 / lto=off.
What you describe here - artifacts differing by build host arch, causing cross-architecture sstate matches - looks like:
[YOCTO #16376] AB-INT: build system architecture reproducibility issue
https://bugzilla.yoctoproject.org/show_bug.cgi?id=16376
which is still open. Could you retag it in v4, unless you had a reason to point at 15554 that I'm missing?
---
One pointer that may or may not be relevant: the 1.97.1 upgrade (65271a5d3b) carries an LLVM backport:
0043-LoopUnroll-Iterate-exit-fold-candidates-in-determini.patch
added for a repro issue seen with rust 1.97.0. I haven't looked at whether it interacts with the SVH path at all - just flagging it in case it's useful context.
Thanks,
Sunil Dora
Quoted 20 lines · Sunil Kumar via lists.openembedded.org
Hi Alejandro,
Thanks for chasing this one down. Small notes on v3:
The commit is tagged [YOCTO #15554], but that bug is "reproducibility failures with 'rustdoc' on rust 1.75" (path-length dependent), RESOLVED FIXED since 2024-08-01 via codegen-units=1 / lto=off.
What you describe here - artifacts differing by build host arch, causing cross-architecture sstate matches - looks like:
[YOCTO #16376] AB-INT: build system architecture reproducibility issue
https://bugzilla.yoctoproject.org/show_bug.cgi?id=16376which is still open. Could you retag it in v4, unless you had a reason to point at 15554 that I'm missing?
---
One pointer that may or may not be relevant: the 1.97.1 upgrade (65271a5d3b) carries an LLVM backport:
Quoted 4 lines
0043-LoopUnroll-Iterate-exit-fold-candidates-in-determini.patch
added for a repro issue seen with rust 1.97.0. I haven't looked at whether it interacts with the SVH path at all - just flagging it in case it's useful context.
I put v3 in for testing on the autobuilder and it looks promising, there are some rust test suite failures though:
https://autobuilder.yoctoproject.org/valkyrie/#/builders/28/builds/4472
https://autobuilder.yoctoproject.org/valkyrie/#/builders/66/builds/4577
and probably more to follow. We may need to exclude those tests?
I also triggered the reproducibility test targets:
https://autobuilder.yoctoproject.org/valkyrie/#/builders/121/builds/3
https://autobuilder.yoctoproject.org/valkyrie/#/builders/119/builds/3
https://autobuilder.yoctoproject.org/valkyrie/#/builders/120/builds/3
those builds are ongoing.
Cheers,
Richard
Quoted 21 lines · Richard Purdie via lists.openembedded.org
Quoted 20 lines · Sunil Kumar via lists.openembedded.org
Hi Alejandro,
Thanks for chasing this one down. Small notes on v3:
The commit is tagged [YOCTO #15554], but that bug is "reproducibility failures with 'rustdoc' on rust 1.75" (path-length dependent), RESOLVED FIXED since 2024-08-01 via codegen-units=1 / lto=off.
What you describe here - artifacts differing by build host arch, causing cross-architecture sstate matches - looks like:
[YOCTO #16376] AB-INT: build system architecture reproducibility issue
https://bugzilla.yoctoproject.org/show_bug.cgi?id=16376which is still open. Could you retag it in v4, unless you had a reason to point at 15554 that I'm missing?
---
One pointer that may or may not be relevant: the 1.97.1 upgrade (65271a5d3b) carries an LLVM backport:
Quoted 4 lines
Quoted 4 lines
0043-LoopUnroll-Iterate-exit-fold-candidates-in-determini.patch
added for a repro issue seen with rust 1.97.0. I haven't looked at whether it interacts with the SVH path at all - just flagging it in case it's useful context.
Hey Richard,
Sorry for the incorrect tag.
I'll look into these failures as well and send a v4
Alejandro
Quoted 27 lines
I put v3 in for testing on the autobuilder and it looks promising, there are some rust test suite failures though:
https://autobuilder.yoctoproject.org/valkyrie/#/builders/28/builds/4472
https://autobuilder.yoctoproject.org/valkyrie/#/builders/66/builds/4577and probably more to follow. We may need to exclude those tests?
I also triggered the reproducibility test targets:
https://autobuilder.yoctoproject.org/valkyrie/#/builders/121/builds/3
https://autobuilder.yoctoproject.org/valkyrie/#/builders/119/builds/3
https://autobuilder.yoctoproject.org/valkyrie/#/builders/120/builds/3those builds are ongoing.
Cheers,
Richard
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#244412): https://lists.openembedded.org/g/openembedded-core/message/244412
Mute This Topic: https://lists.openembedded.org/mt/120939810/4354175
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Quoted 39 lines · Alejandro Hernandez
Quoted 28 lines · Richard Purdie via lists.openembedded.org
Quoted 26 lines · Sunil Kumar via lists.openembedded.org
Hi Alejandro,
Thanks for chasing this one down. Small notes on v3:
The commit is tagged [YOCTO #15554], but that bug is "reproducibility
failures with 'rustdoc' on rust 1.75" (path-length dependent), RESOLVED FIXED
since 2024-08-01 via codegen-units=1 / lto=off.What you describe here - artifacts differing by build host arch, causing
cross-architecture sstate matches - looks like:[YOCTO #16376] AB-INT: build system architecture reproducibility issue
https://bugzilla.yoctoproject.org/show_bug.cgi?id=16376which is still open. Could you retag it in v4, unless you had a reason to
point at 15554 that I'm missing?
---
One pointer that may or may not be relevant: the 1.97.1 upgrade (65271a5d3b)
carries an LLVM backport:Quoted 7 lines
Quoted 7 lines
0043-LoopUnroll-Iterate-exit-fold-candidates-in- determini.patch
added for a repro issue seen with rust 1.97.0. I haven't looked at whether it
interacts with the SVH path at all - just flagging it in case it's useful context.
Quoted 4 lines
Hey Richard,
Sorry for the incorrect tag.
No problem, that is at least easily fixed!
Quoted 1 line
I'll look into these failures as well and send a v4
Thanks! I appreciate the work on this as it should improve things a lot.
Quoted 8 lines
Quoted 8 lines
I put v3 in for testing on the autobuilder and it looks promising, there are some rust test suite failures though:
https://autobuilder.yoctoproject.org/valkyrie/#/builders/28/builds/4472
https://autobuilder.yoctoproject.org/valkyrie/#/builders/66/builds/4577and probably more to follow. We may need to exclude those tests?
Quoted 7 lines
Quoted 7 lines
I also triggered the reproducibility test targets:
https://autobuilder.yoctoproject.org/valkyrie/#/builders/121/builds/3
https://autobuilder.yoctoproject.org/valkyrie/#/builders/119/builds/3
https://autobuilder.yoctoproject.org/valkyrie/#/builders/120/builds/3those builds are ongoing.
One of these completed:
https://autobuilder.yoctoproject.org/valkyrie/#/builders/120/builds/3
which leads to:
https://valkyrie.yocto.io/pub/repro-fail/oe-reproducible-20260826-plagtpam/packages/diff-html/
There looks to be a locale issue, some python config tweaks, curl- config binconfig needing a tweak and a smaller rust issue left.
Definitely progress, much fewer recipes showing issues and fewer binary ones and more text ones left...
Cheers,
Richard
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 74 lines · Richard Purdie via lists.openembedded.org
Quoted 39 lines · Alejandro Hernandez
Quoted 28 lines · Richard Purdie via lists.openembedded.org
Quoted 26 lines · Sunil Kumar via lists.openembedded.org
Hi Alejandro,
Thanks for chasing this one down. Small notes on v3:
The commit is tagged [YOCTO #15554], but that bug is "reproducibility
failures with 'rustdoc' on rust 1.75" (path-length dependent), RESOLVED FIXED
since 2024-08-01 via codegen-units=1 / lto=off.What you describe here - artifacts differing by build host arch, causing
cross-architecture sstate matches - looks like:[YOCTO #16376] AB-INT: build system architecture reproducibility issue
https://bugzilla.yoctoproject.org/show_bug.cgi?id=16376which is still open. Could you retag it in v4, unless you had a reason to
point at 15554 that I'm missing?
---
One pointer that may or may not be relevant: the 1.97.1 upgrade (65271a5d3b)
carries an LLVM backport:Quoted 7 lines
Quoted 7 lines
0043-LoopUnroll-Iterate-exit-fold-candidates-in- determini.patch
added for a repro issue seen with rust 1.97.0. I haven't looked at whether it
interacts with the SVH path at all - just flagging it in case it's useful context.Quoted 4 lines
Hey Richard,
Sorry for the incorrect tag.
No problem, that is at least easily fixed!
Quoted 1 line
I'll look into these failures as well and send a v4
Thanks! I appreciate the work on this as it should improve things a lot.
Quoted 8 lines
Quoted 8 lines
I put v3 in for testing on the autobuilder and it looks promising, there are some rust test suite failures though:
https://autobuilder.yoctoproject.org/valkyrie/#/builders/28/builds/4472
https://autobuilder.yoctoproject.org/valkyrie/#/builders/66/builds/4577and probably more to follow. We may need to exclude those tests?
Quoted 7 lines
Quoted 7 lines
I also triggered the reproducibility test targets:
https://autobuilder.yoctoproject.org/valkyrie/#/builders/121/builds/3
https://autobuilder.yoctoproject.org/valkyrie/#/builders/119/builds/3
https://autobuilder.yoctoproject.org/valkyrie/#/builders/120/builds/3those builds are ongoing.
One of these completed:
https://autobuilder.yoctoproject.org/valkyrie/#/builders/120/builds/3
which leads to:
Quoted 7 lines
https://valkyrie.yocto.io/pub/repro-fail/oe-reproducible-20260826-plagtpam/packages/diff-html/
There looks to be a locale issue, some python config tweaks, curl- config binconfig needing a tweak and a smaller rust issue left.
Definitely progress, much fewer recipes showing issues and fewer binary ones and more text ones left...
Sadly the other two test runs looked less promising:
https://autobuilder.yoctoproject.org/valkyrie/#/builders/119/builds/3
https://autobuilder.yoctoproject.org/valkyrie/#/builders/121/builds/3
both of which have a lot of rust related looking differences :/
Cheers,
Richard
Quoted 79 lines · Richard Purdie
Quoted 69 lines · Richard Purdie via lists.openembedded.org
Quoted 33 lines · Alejandro Hernandez
Quoted 31 lines · Richard Purdie via lists.openembedded.org
Quoted 29 lines · Sunil Kumar via lists.openembedded.org
Hi Alejandro,
Thanks for chasing this one down. Small notes on v3:
The commit is tagged [YOCTO #15554], but that bug is "reproducibility
failures with 'rustdoc' on rust 1.75" (path-length dependent), RESOLVED FIXED
since 2024-08-01 via codegen-units=1 / lto=off.What you describe here - artifacts differing by build host arch, causing
cross-architecture sstate matches - looks like:[YOCTO #16376] AB-INT: build system architecture
reproducibility issue
https://bugzilla.yoctoproject.org/show_bug.cgi?id=16376which is still open. Could you retag it in v4, unless you had a reason to
point at 15554 that I'm missing?
---
One pointer that may or may not be relevant: the 1.97.1 upgrade (65271a5d3b)
carries an LLVM backport:0043-LoopUnroll-Iterate-exit-fold-candidates-in-
determini.patchQuoted 8 lines
Quoted 4 lines
Quoted 4 lines
added for a repro issue seen with rust 1.97.0. I haven't looked at whether it
interacts with the SVH path at all - just flagging it in case it's useful context.Hey Richard,
Sorry for the incorrect tag.
No problem, that is at least easily fixed!
Quoted 1 line
I'll look into these failures as well and send a v4
Thanks! I appreciate the work on this as it should improve things a lot.
Quoted 8 lines
Quoted 8 lines
I put v3 in for testing on the autobuilder and it looks promising, there are some rust test suite failures though:
https://autobuilder.yoctoproject.org/valkyrie/#/builders/28/builds/4472
https://autobuilder.yoctoproject.org/valkyrie/#/builders/66/builds/4577and probably more to follow. We may need to exclude those tests?
Quoted 7 lines
Quoted 7 lines
I also triggered the reproducibility test targets:
https://autobuilder.yoctoproject.org/valkyrie/#/builders/121/builds/3
https://autobuilder.yoctoproject.org/valkyrie/#/builders/119/builds/3
https://autobuilder.yoctoproject.org/valkyrie/#/builders/120/builds/3those builds are ongoing.
One of these completed:
https://autobuilder.yoctoproject.org/valkyrie/#/builders/120/builds/3
which leads to:
Quoted 7 lines
https://valkyrie.yocto.io/pub/repro-fail/oe-reproducible-20260826-plagtpam/packages/diff-html/
There looks to be a locale issue, some python config tweaks, curl- config binconfig needing a tweak and a smaller rust issue left.
Definitely progress, much fewer recipes showing issues and fewer binary ones and more text ones left...
Sadly the other two test runs looked less promising:
Quoted 8 lines
https://autobuilder.yoctoproject.org/valkyrie/#/builders/119/builds/3
https://autobuilder.yoctoproject.org/valkyrie/#/builders/121/builds/3both of which have a lot of rust related looking differences :/
Cheers,
Richard
Hey Richard,
Apologies, I got a bit confused, is the ask to send a v4 with the correct tag and then look at other reproducibility issues?.
or are these reproducibility issues related to the patch and need to be addressed before sending a v4?
Alejandro
Quoted 2 lines
Quoted 96 lines · Alejandro Hernandez
Quoted 94 lines · Richard Purdie
Quoted 80 lines · Richard Purdie via lists.openembedded.org
Quoted 43 lines · Alejandro Hernandez
Quoted 35 lines · Richard Purdie via lists.openembedded.org
Quoted 33 lines · Sunil Kumar via lists.openembedded.org
Hi Alejandro,
Thanks for chasing this one down. Small notes on v3:
The commit is tagged [YOCTO #15554], but that bug is "reproducibility
failures with 'rustdoc' on rust 1.75" (path-length dependent),
RESOLVED FIXED
since 2024-08-01 via codegen-units=1 / lto=off.What you describe here - artifacts differing by build host arch,
causing
cross-architecture sstate matches - looks like:[YOCTO #16376] AB-INT: build system architecture reproducibility issue
https://bugzilla.yoctoproject.org/show_bug.cgi?id=16376which is still open. Could you retag it in v4, unless you had a
reason to
point at 15554 that I'm missing?
---
One pointer that may or may not be relevant: the 1.97.1 upgrade
(65271a5d3b)
carries an LLVM backport:0043-LoopUnroll-Iterate-exit-fold-candidates-in- determini.patch
Quoted 6 lines
Quoted 6 lines
added for a repro issue seen with rust 1.97.0. I haven't looked
at whether it
interacts with the SVH path at all - just flagging it in case
it's useful context.Quoted 4 lines
Hey Richard,
Sorry for the incorrect tag.
No problem, that is at least easily fixed!
Quoted 1 line
I'll look into these failures as well and send a v4
Thanks! I appreciate the work on this as it should improve things a
lot.Quoted 10 lines
Quoted 10 lines
I put v3 in for testing on the autobuilder and it looks promising,
there are some rust test suite failures though:https://autobuilder.yoctoproject.org/valkyrie/#/builders/28/builds/4472
https://autobuilder.yoctoproject.org/valkyrie/#/builders/66/builds/4577and probably more to follow. We may need to exclude those tests?
Quoted 7 lines
Quoted 7 lines
I also triggered the reproducibility test targets:
https://autobuilder.yoctoproject.org/valkyrie/#/builders/121/builds/3
https://autobuilder.yoctoproject.org/valkyrie/#/builders/119/builds/3
https://autobuilder.yoctoproject.org/valkyrie/#/builders/120/builds/3those builds are ongoing.
One of these completed:
https://autobuilder.yoctoproject.org/valkyrie/#/builders/120/builds/3
which leads to:
https://valkyrie.yocto.io/pub/repro-fail/oe-reproducible-20260826-plagtpam/packages/diff-html/
Quoted 7 lines
There looks to be a locale issue, some python config tweaks, curl-
config binconfig needing a tweak and a smaller rust issue left.Definitely progress, much fewer recipes showing issues and fewer binary
ones and more text ones left...Sadly the other two test runs looked less promising:
https://autobuilder.yoctoproject.org/valkyrie/#/builders/119/builds/3
https://autobuilder.yoctoproject.org/valkyrie/#/builders/121/builds/3
Quoted 7 lines
Quoted 1 line
both of which have a lot of rust related looking differences :/
Apologies, I got a bit confused, is the ask to send a v4 with the correct tag and then look at other reproducibility issues?.
or are these reproducibility issues related to the patch and need to be addressed before sending a v4?
I'm probably a bit confused too. There are still reproducibility issues in there that look rust related and I can't really tell if those are additional issues or whether the original fix isn't working. I suspect I need your help to work that out...
Cheers,
Richard
I'm still working through the remaining Rust packages and will follow up on that separately.
While going through the reproducible-cross diffoscope output, though, I noticed something unrelated to Rust that I think may explain the git/git-dbg entries, so sharing it here in case it's useful or helps narrow things down.
In the 2026-07-29 report from builder 120 [1], git's .rodata has:
-0x001b1780 6769742d 00000000 61617263 68363400 git-....aarch64. +0x001b1780 6769742d 00000000 7838365f 36340000 git-....x86_64..
i.e. the build host's arch string, sitting right next to git's "cpu: %s" format string.
git's Makefile does:
ifeq (,$(HOST_CPU))BASIC_CFLAGS += -DGIT_HOST_CPU="\"$(firstword $(subst -, ,$(uname_M)))\"" elseBASIC_CFLAGS += -DGIT_HOST_CPU="\"$(HOST_CPU)\""
endif
uname_M comes from uname -m on the build machine, and GIT_HOST_CPU ends up in the "cpu:" line of git version --build-options.
Upstream even documents HOST_CPU as the thing to set when cross compiling, but our recipe never sets it, so we always take the uname fallback.
Since "aarch64" and "x86_64" have different lengths, everything after that string shifts, which is why the git diffs look much bigger than they really are (.text, .symtab and so on) - the instructions themselves don't change. git/git-dbg show up in every run I've looked at (119/120/121, before and after the SVH fix, on both x86 and arm hosts),
so it fits a build host leak rather than anything rust related.
The fix should just be:
EXTRA_OEMAKE += "HOST_CPU=${TARGET_ARCH}"
in git_2.55.0.bb. As far as I can tell TARGET_ARCH does the right thing for native (= BUILD_ARCH) and nativesdk (= SDK_ARCH) as well, so no class overrides needed.
I'm cross checking with a locally to make sure the resulting binary really says "aarch64", and will send the patch once that's confirmed.
[1] https://valkyrie.yocto.io/pub/repro-fail/oe-reproducible-20260729-j6j_xpuw/packages/diff-html/
Thanks,
Sunil