Openembedded Devel Discussions
 help / color / mirror / Atom feed
From: Khem Raj <raj.khem@gmail.com>
To: openembedded-devel@lists.openembedded.org
Cc: Khem Raj <raj.khem@gmail.com>
Subject: [meta-oe][PATCH] cbindgen: Fix getrandom build with musl/riscv32
Date: Thu, 13 Nov 2025 19:56:27 -0800	[thread overview]
Message-ID: <20251114035628.157073-1-raj.khem@gmail.com> (raw)

New upgrade to 0.29.2 broke it.

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 ...Use-libc-SYS_futex_time64-on-riscv32.patch | 53 +++++++++++++++++++
 .../cbindgen/cbindgen_0.29.2.bb               |  2 +
 2 files changed, 55 insertions(+)
 create mode 100644 meta-oe/recipes-devtools/cbindgen/cbindgen/0001-Use-libc-SYS_futex_time64-on-riscv32.patch

diff --git a/meta-oe/recipes-devtools/cbindgen/cbindgen/0001-Use-libc-SYS_futex_time64-on-riscv32.patch b/meta-oe/recipes-devtools/cbindgen/cbindgen/0001-Use-libc-SYS_futex_time64-on-riscv32.patch
new file mode 100644
index 0000000000..4bb30a78cf
--- /dev/null
+++ b/meta-oe/recipes-devtools/cbindgen/cbindgen/0001-Use-libc-SYS_futex_time64-on-riscv32.patch
@@ -0,0 +1,53 @@
+From a552c6891070bf400d4fe1f7c39c50b1a0b17748 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Tue, 22 Jul 2025 09:46:03 -0700
+Subject: [PATCH] Use libc::SYS_futex_time64 on riscv32
+
+On RISC-V 32-bit (riscv32), the SYS_futex system call is
+often handled indirectly due to the use of a 64-bit time_t
+type. Specifically, while SYS_futex is not directly defined,
+a related syscall like SYS_futex_time64 can be used,
+
+Upstream-Status: Backport [https://github.com/rust-random/getrandom/pull/698/commits/03d2c9f164099a714c3141c53221ccb68101c460]
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ src/backends/use_file.rs | 17 +++++++++++++++++
+ 1 file changed, 17 insertions(+)
+
+diff --git a/src/backends/use_file.rs b/src/backends/use_file.rs
+index 7b48d43..baa0c66 100644
+--- a/src/backends/use_file.rs
++++ b/src/backends/use_file.rs
+@@ -158,7 +158,18 @@ mod sync {
+     pub(super) fn wait() {
+         let op = libc::FUTEX_WAIT | libc::FUTEX_PRIVATE_FLAG;
+         let timeout_ptr = core::ptr::null::<libc::timespec>();
++        #[cfg(not(target_arch = "riscv32"))]
+         let ret = unsafe { libc::syscall(libc::SYS_futex, &FD, op, FD_ONGOING_INIT, timeout_ptr) };
++        #[cfg(target_arch = "riscv32")]
++        let ret = unsafe {
++            libc::syscall(
++                libc::SYS_futex_time64,
++                &FD,
++                op,
++                FD_ONGOING_INIT,
++                timeout_ptr,
++            )
++        };
+         // FUTEX_WAIT should return either 0 or EAGAIN error
+         debug_assert!({
+             match ret {
+@@ -172,7 +183,13 @@ mod sync {
+     /// Wake up all threads which wait for value of atomic `FD` to change.
+     pub(super) fn wake() {
+         let op = libc::FUTEX_WAKE | libc::FUTEX_PRIVATE_FLAG;
++
++        #[cfg(not(target_arch = "riscv32"))]
+         let ret = unsafe { libc::syscall(libc::SYS_futex, &FD, op, libc::INT_MAX) };
++
++        #[cfg(target_arch = "riscv32")]
++        let ret = unsafe { libc::syscall(libc::SYS_futex_time64, &FD, op, libc::INT_MAX) };
++
+         debug_assert!(ret >= 0);
+     }
+
diff --git a/meta-oe/recipes-devtools/cbindgen/cbindgen_0.29.2.bb b/meta-oe/recipes-devtools/cbindgen/cbindgen_0.29.2.bb
index 0ba5392d6c..6b5fac9d47 100644
--- a/meta-oe/recipes-devtools/cbindgen/cbindgen_0.29.2.bb
+++ b/meta-oe/recipes-devtools/cbindgen/cbindgen_0.29.2.bb
@@ -5,6 +5,8 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=9741c346eef56131163e13b9db1241b3"

 require cbindgen-crates.inc
 SRC_URI += "git://github.com/mozilla/cbindgen.git;protocol=https;branch=main;tag=v${PV}"
+SRC_URI += "file://0001-Use-libc-SYS_futex_time64-on-riscv32.patch;patchdir=${UNPACKDIR}/cargo_home/bitbake/getrandom-0.3.3/"
+
 SRCREV = "76f41c090c0587d940a0ef81a41c8b995f074926"

 inherit cargo pkgconfig


                 reply	other threads:[~2025-11-14  3:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251114035628.157073-1-raj.khem@gmail.com \
    --to=raj.khem@gmail.com \
    --cc=openembedded-devel@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox