diff mbox series

[meta-oe,22/29] librice: Fix build on targets without 64-bit atomics

Message ID 20261023065350.3228996-22-khem.raj@oss.qualcomm.com
State New
Headers show
Series [meta-oe,01/29] castxml: upgrade 0.7.0 -> 0.8.0 | expand

Commit Message

Khem Raj Oct. 23, 2026, 6:53 a.m. UTC
rice-proto counts agents in a core AtomicU64, which is not available on
targets without 64-bit atomics, so it fails to build for riscv32:

  error[E0432]: unresolved import `core::sync::atomic::AtomicU64`

Add a patch that uses AtomicUsize for it, like the other id counters
in rice-proto, keeping the u64 agent id.

AI-Generated: Uses Claude Code
Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
---
 ...se-AtomicUsize-for-the-agent-counter.patch | 50 +++++++++++++++++++
 .../recipes-support/librice/librice_0.4.3.bb  |  4 +-
 2 files changed, 53 insertions(+), 1 deletion(-)
 create mode 100644 meta-oe/recipes-support/librice/librice/0001-rice-proto-Use-AtomicUsize-for-the-agent-counter.patch
diff mbox series

Patch

diff --git a/meta-oe/recipes-support/librice/librice/0001-rice-proto-Use-AtomicUsize-for-the-agent-counter.patch b/meta-oe/recipes-support/librice/librice/0001-rice-proto-Use-AtomicUsize-for-the-agent-counter.patch
new file mode 100644
index 0000000000..dacc6a0a81
--- /dev/null
+++ b/meta-oe/recipes-support/librice/librice/0001-rice-proto-Use-AtomicUsize-for-the-agent-counter.patch
@@ -0,0 +1,50 @@ 
+From: Khem Raj <khem.raj@oss.qualcomm.com>
+Date: Thu, 22 Oct 2026 14:00:00 -0700
+Subject: [PATCH] rice-proto: Use AtomicUsize for the agent counter
+
+core only provides AtomicU64 on targets with 64-bit atomics, so
+rice-proto fails to build for e.g. riscv32:
+
+  error[E0432]: unresolved import `core::sync::atomic::AtomicU64`
+    --> rice-proto/src/agent.rs:19:5
+
+AGENT_COUNT only hands out agent ids, like the STUN agent, connection
+check and check list counters, which are already AtomicUsize. Use
+AtomicUsize for it as well and widen the value to the u64 id, so
+Agent::id() is unchanged.
+
+Upstream-Status: Submitted [https://github.com/ystreet/librice/pull/202]
+Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
+---
+ rice-proto/src/agent.rs | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+--- a/rice-proto/src/agent.rs
++++ b/rice-proto/src/agent.rs
+@@ -16,7 +16,7 @@
+ use core::error::Error;
+ use core::fmt::Display;
+ use core::net::SocketAddr;
+-use core::sync::atomic::AtomicU64;
++use core::sync::atomic::AtomicUsize;
+ use core::time::Duration;
+
+ use stun_proto::Instant;
+@@ -189,7 +189,7 @@
+         turn_client_proto::types::debug_init();
+         rice_stun_types::debug_init();
+
+-        let id = AGENT_COUNT.fetch_add(1, core::sync::atomic::Ordering::SeqCst);
++        let id = AGENT_COUNT.fetch_add(1, core::sync::atomic::Ordering::SeqCst) as u64;
+         let tie_breaker = rand_u64();
+         let controlling = self.controlling;
+         let mut checklistset = ConnCheckListSet::builder(tie_breaker, controlling)
+@@ -210,7 +210,7 @@
+     }
+ }
+
+-static AGENT_COUNT: AtomicU64 = AtomicU64::new(0);
++static AGENT_COUNT: AtomicUsize = AtomicUsize::new(0);
+
+ impl Default for Agent {
+     fn default() -> Self {
diff --git a/meta-oe/recipes-support/librice/librice_0.4.3.bb b/meta-oe/recipes-support/librice/librice_0.4.3.bb
index 61934acd88..95648f97db 100644
--- a/meta-oe/recipes-support/librice/librice_0.4.3.bb
+++ b/meta-oe/recipes-support/librice/librice_0.4.3.bb
@@ -3,7 +3,9 @@  HOMEPAGE = "https://github.com/ystreet/librice"
 LICENSE = "MIT"
 LIC_FILES_CHKSUM = "file://LICENSE-MIT;md5=b377b220f43d747efdec40d69fcaa69d"

-SRC_URI += " git://github.com/ystreet/librice.git;protocol=https;branch=main;tag=v${PV}"
+SRC_URI += " git://github.com/ystreet/librice.git;protocol=https;branch=main;tag=v${PV} \
+            file://0001-rice-proto-Use-AtomicUsize-for-the-agent-counter.patch \
+"
 SRCREV = "afd70fdd7ca96a39824c55e6b373bac97311f2ba"

 DEPENDS += "openssl clang-native"