From 2c69195b6161ba3a00c2ebfe0695debeaa569def Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Thu, 22 Oct 2026 23:40:57 -0700 Subject: [PATCH] gnome-commander: Fix build on targets without 64-bit atomics The object id counter in src/weak_ref.rs is a std AtomicU64, which is not available on targets without 64-bit atomics, so the build fails for riscv32: error[E0432]: unresolved import `std::sync::atomic::AtomicU64` Add a patch that keeps the 64-bit counter in a Mutex instead. The code has since been removed upstream. AI-Generated: Uses Claude Code Signed-off-by: Khem Raj --- ...se-a-Mutex-for-the-object-id-counter.patch | 59 +++++++++++++++++++ .../gnome-commander/gnome-commander_2.0.3.bb | 4 +- 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 meta-gnome/recipes-gnome/gnome-commander/gnome-commander/0002-weak_ref-Use-a-Mutex-for-the-object-id-counter.patch diff --git a/meta-gnome/recipes-gnome/gnome-commander/gnome-commander/0002-weak_ref-Use-a-Mutex-for-the-object-id-counter.patch b/meta-gnome/recipes-gnome/gnome-commander/gnome-commander/0002-weak_ref-Use-a-Mutex-for-the-object-id-counter.patch new file mode 100644 index 0000000000..eb253d9dc4 --- /dev/null +++ b/meta-gnome/recipes-gnome/gnome-commander/gnome-commander/0002-weak_ref-Use-a-Mutex-for-the-object-id-counter.patch @@ -0,0 +1,59 @@ +From: Khem Raj +Date: Thu, 22 Oct 2026 20:00:00 -0700 +Subject: [PATCH] weak_ref: Use a Mutex for the object id counter + +std only provides AtomicU64 on targets with 64-bit atomics, so +gnome-commander fails to build for e.g. riscv32: + + error[E0432]: unresolved import `std::sync::atomic::AtomicU64` + --> src/weak_ref.rs:8:14 + +The counter hands out the ids IdentityWeakRef uses for equality and +hashing, so it has to stay 64-bit and must not wrap. Keep it in a +Mutex, which works on every target. Ids are only allocated when an +object gets its first weak reference, so the lock is uncontended in +practice. + +Upstream-Status: Inappropriate [the code was removed upstream after 2.0.3] +Signed-off-by: Khem Raj +--- + src/weak_ref.rs | 16 ++++++++++------ + 1 file changed, 10 insertions(+), 6 deletions(-) + +--- a/src/weak_ref.rs ++++ b/src/weak_ref.rs +@@ -3,10 +3,7 @@ + // SPDX-License-Identifier: GPL-3.0-or-later + + use gtk::{glib, glib::prelude::*}; +-use std::sync::{ +- LazyLock, +- atomic::{AtomicU64, Ordering}, +-}; ++use std::sync::{LazyLock, Mutex}; + + #[derive(Clone, Debug)] + pub struct IdentityWeakRef { +@@ -24,13 +21,20 @@ + } + + fn set_object_id(obj: &T) -> u64 { +- static SEQ: AtomicU64 = AtomicU64::new(1); ++ // A Mutex rather than an AtomicU64, which std only provides on targets ++ // with 64-bit atomics. The id has to stay 64-bit so it does not wrap. ++ static SEQ: Mutex = Mutex::new(1); + + unsafe { + match obj.qdata::(*ID_QUARK) { + Some(existing_id) => *(existing_id.as_ref()), + None => { +- let new_id = SEQ.fetch_add(1, Ordering::SeqCst); ++ let new_id = { ++ let mut seq = SEQ.lock().unwrap(); ++ let id = *seq; ++ *seq += 1; ++ id ++ }; + obj.set_qdata(*ID_QUARK, new_id); + new_id + } diff --git a/meta-gnome/recipes-gnome/gnome-commander/gnome-commander_2.0.3.bb b/meta-gnome/recipes-gnome/gnome-commander/gnome-commander_2.0.3.bb index 0be81a7290..c4c674b421 100644 --- a/meta-gnome/recipes-gnome/gnome-commander/gnome-commander_2.0.3.bb +++ b/meta-gnome/recipes-gnome/gnome-commander/gnome-commander_2.0.3.bb @@ -24,7 +24,9 @@ REQUIRED_DISTRO_FEATURES = "opengl gobject-introspection-data" GIR_MESON_OPTION = "" SRC_URI[archive.sha256sum] = "e51178f3256de45324ffd928a4a144fa859a865662bf295129f0188d8d243b57" -SRC_URI += "file://0001-meson-Support-cross-compilation-via-a-rust_target-cr.patch" +SRC_URI += "file://0001-meson-Support-cross-compilation-via-a-rust_target-cr.patch \ + file://0002-weak_ref-Use-a-Mutex-for-the-object-id-counter.patch \ +" require ${BPN}-crates.inc