From: Sunil Dora <[email protected]> cargo hashes the "host:" line of "rustc -vV" into the metadata of build scripts and proc-macros. Every target crate that depends on one picks it up, so the same crate gets a different -C metadata and StableCrateId on an x86_64 and an aarch64 build host. The added patch drops the host line from that hash.
[YOCTO #16376] Signed-off-by: Alejandro Enedino Hernandez Samaniego <[email protected]> Signed-off-by: Sunil Dora <[email protected]> --- v2: added Alejandro's Signed-off-by, dropped the link paragraph from the commit message. No code change. ...-host-triple-from-unit-metadata-hash.patch | 62 +++++++++++++++++++ meta/recipes-devtools/rust/rust-source.inc | 1 + 2 files changed, 63 insertions(+) create mode 100644 meta/recipes-devtools/rust/files/0007-cargo-omit-host-triple-from-unit-metadata-hash.patch diff --git a/meta/recipes-devtools/rust/files/0007-cargo-omit-host-triple-from-unit-metadata-hash.patch b/meta/recipes-devtools/rust/files/0007-cargo-omit-host-triple-from-unit-metadata-hash.patch new file mode 100644 index 0000000000..d4cb48a7a3 --- /dev/null +++ b/meta/recipes-devtools/rust/files/0007-cargo-omit-host-triple-from-unit-metadata-hash.patch @@ -0,0 +1,62 @@ +From 5c4fd7d8b85f4de5be387777a782fc3ddd1227d8 Mon Sep 17 00:00:00 2001 +From: Alejandro Enedino Hernandez Samaniego <[email protected]> +Date: Tue, 15 Sep 2026 17:05:36 +0530 +Subject: [PATCH] rust: keep the build host triple out of cargo unit metadata + +cargo hashes the "host:" line of "rustc -vV" into the metadata of host +units, that is build scripts and proc-macros. Every target crate that +depends on one picks that up through its own metadata, so the same crate +gets a different -C metadata and StableCrateId on an x86_64 and an aarch64 +build host. Drop the host from the hash. The same class of problem is +reported upstream, framed as OS differences, in +https://github.com/rust-lang/cargo/issues/8140. + +Patch by Alejandro Enedino Hernandez Samaniego, from his strict-version-hash +v5 series for openembedded-core: +https://lists.openembedded.org/g/openembedded-core/topic/120939810 + +Upstream-Status: Inappropriate [OE-specific] + +Signed-off-by: Alejandro Enedino Hernandez Samaniego <[email protected]> +Signed-off-by: Sunil Dora <[email protected]> +--- + .../core/compiler/build_runner/compilation_files.rs | 10 ++-------- + 1 file changed, 2 insertions(+), 8 deletions(-) + +diff --git a/src/tools/cargo/src/cargo/core/compiler/build_runner/compilation_files.rs b/src/tools/cargo/src/cargo/core/compiler/build_runner/compilation_files.rs +index 88cab85..9dbd203 100644 +--- a/src/tools/cargo/src/cargo/core/compiler/build_runner/compilation_files.rs ++++ b/src/tools/cargo/src/cargo/core/compiler/build_runner/compilation_files.rs +@@ -877,7 +877,7 @@ fn has_remap_path_prefix(args: &[String]) -> bool { + } + + /// Hash the version of rustc being used during the build process. +-fn hash_rustc_version(bcx: &BuildContext<'_, '_>, hasher: &mut StableHasher, unit: &Unit) { ++fn hash_rustc_version(bcx: &BuildContext<'_, '_>, hasher: &mut StableHasher, _unit: &Unit) { + let vers = &bcx.rustc().version; + if vers.pre.is_empty() || bcx.gctx.cli_unstable().separate_nightlies { + // For stable, keep the artifacts separate. This helps if someone is +@@ -886,7 +886,7 @@ fn hash_rustc_version(bcx: &BuildContext<'_, '_>, hasher: &mut StableHasher, uni + // omitted since rustc should produce the same output for each target + // regardless of the host. + for line in bcx.rustc().verbose_version.lines() { +- if unit.kind.is_host() || !line.starts_with("host: ") { ++ if !line.starts_with("host: ") { + line.hash(hasher); + } + } +@@ -899,12 +899,6 @@ fn hash_rustc_version(bcx: &BuildContext<'_, '_>, hasher: &mut StableHasher, uni + // This assumes that the first segment is the important bit ("nightly", + // "beta", "dev", etc.). Skip other parts like the `.3` in `-beta.3`. + vers.pre.split('.').next().hash(hasher); +- // 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. +- if unit.kind.is_host() { +- bcx.rustc().host.hash(hasher); +- } + // None of the other lines are important. Currently they are: + // binary: rustc <-- or "rustdoc" + // commit-hash: 38114ff16e7856f98b2b4be7ab4cd29b38bed59a +-- +2.43.0 diff --git a/meta/recipes-devtools/rust/rust-source.inc b/meta/recipes-devtools/rust/rust-source.inc index 54502ccc9e..a294201c6e 100644 --- a/meta/recipes-devtools/rust/rust-source.inc +++ b/meta/recipes-devtools/rust/rust-source.inc @@ -9,6 +9,7 @@ SRC_URI += "https://static.rust-lang.org/dist/rustc-${RUST_VERSION}-src.tar.xz;n file://0003-bootstrap-skip-StdarchVerify-when-remote-testing.patch;patchdir=${RUSTSRC} \ file://0004-Backport-commits-from-rust-Fix-selftest-llvm23.patch;patchdir=${RUSTSRC} \ file://0005-rustc_codegen_llvm-Do-not-pass-amx-tf32-to-LLVM-23.patch;patchdir=${RUSTSRC} \ + file://0007-cargo-omit-host-triple-from-unit-metadata-hash.patch;patchdir=${RUSTSRC} \ " SRC_URI[rust.sha256sum] = "be1816e7f6c40abb90245ad6e024bed2a7e88d7dda4561e4d5470207df616b9f" -- 2.43.0
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#245984): https://lists.openembedded.org/g/openembedded-core/message/245984 Mute This Topic: https://lists.openembedded.org/mt/121280458/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
