new file mode 100644
@@ -0,0 +1,58 @@
+From 9c190d14f93bf27c7f1c94d400cda6f48f285a34 Mon Sep 17 00:00:00 2001
+From: Alejandro Enedino Hernandez Samaniego <alejandro@enedino.org>
+Date: Tue, 15 Sep 2026 17:05:36 +0530
+Subject: [PATCH] rust: sort syntax contexts and expansions before encoding
+
+HygieneEncodeContext encodes the pending syntax contexts and expansions in
+hash-map order, so the encoded rmeta depends on the build host. Sort both
+before encoding. Upstream is fixing the same problem with a different
+approach in https://github.com/rust-lang/rust/pull/161450, which is still
+open, so this is a local fix rather than a backport of it.
+
+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 <alejandro@enedino.org>
+Signed-off-by: Sunil Dora <sunilkumar.dora@windriver.com>
+---
+ compiler/rustc_span/src/hygiene.rs | 10 ++++++----
+ 1 file changed, 6 insertions(+), 4 deletions(-)
+
+diff --git a/compiler/rustc_span/src/hygiene.rs b/compiler/rustc_span/src/hygiene.rs
+index 1c74205..a464eca 100644
+--- a/compiler/rustc_span/src/hygiene.rs
++++ b/compiler/rustc_span/src/hygiene.rs
+@@ -1313,12 +1313,12 @@ impl HygieneEncodeContext {
+
+ // Consume the current round of syntax contexts.
+ // Drop the lock() temporary early.
+- // It's fine to iterate over a HashMap, because the serialization of the table
+- // that we insert data into doesn't depend on insertion order.
+ #[allow(rustc::potential_query_instability)]
+- let latest_ctxts = { mem::take(&mut *self.latest_ctxts.lock()) }.into_iter();
++ let mut latest_ctxts: Vec<_> = { mem::take(&mut *self.latest_ctxts.lock()) }.into_iter().collect();
++ latest_ctxts.sort_by_key(|ctxt| ctxt.0);
+ let all_ctxt_data: Vec<_> = HygieneData::with(|data| {
+ latest_ctxts
++ .into_iter()
+ .map(|ctxt| (ctxt, data.syntax_context_data[ctxt.0 as usize].key()))
+ .collect()
+ });
+@@ -1330,9 +1330,11 @@ impl HygieneEncodeContext {
+
+ // Same as above, but for expansions instead of syntax contexts.
+ #[allow(rustc::potential_query_instability)]
+- let latest_expns = { mem::take(&mut *self.latest_expns.lock()) }.into_iter();
++ let mut latest_expns: Vec<_> = { mem::take(&mut *self.latest_expns.lock()) }.into_iter().collect();
++ latest_expns.sort_by_key(|expn| (expn.krate, expn.local_id));
+ let all_expn_data: Vec<_> = HygieneData::with(|data| {
+ latest_expns
++ .into_iter()
+ .map(|expn| (expn, data.expn_data(expn).clone(), data.expn_hash(expn)))
+ .collect()
+ });
+--
+2.43.0
@@ -11,6 +11,7 @@ SRC_URI += "https://static.rust-lang.org/dist/rustc-${RUST_VERSION}-src.tar.xz;n
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} \
file://0008-rustc-hir-make-doc-link-metadata-order-deterministic.patch;patchdir=${RUSTSRC} \
+ file://0009-rustc-span-make-hygiene-encoding-order-deterministic.patch;patchdir=${RUSTSRC} \
"
SRC_URI[rust.sha256sum] = "be1816e7f6c40abb90245ad6e024bed2a7e88d7dda4561e4d5470207df616b9f"