Skip to contentSkip to conversation

python3-pydantic-core: Fix build on rv32

PATCH New Khem Raj 1 participant 1 message Jul 23, 2025

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 python3-pydantic-core: Fix build on rv32

version needs getrandom from musl libc on musl targets but rust libc locked in for this target is older than the change needed for this to work on newer architectures

Fixes
| error[E0425]: cannot find value getrandom in crate libc
| --> /usr/src/debug/python3-pydantic-core/2.35.2/sources/cargo_home/bitbake/getrandom-0.3.3/src/backends/linux_android_with_fallback.rs:34:39

---
 ...able-getrandom-on-all-musl-platforms.patch | 81 +++++++++++++++++++
 .../python/python3-pydantic-core_2.35.2.bb    |  1 +
 2 files changed, 82 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-pydantic-core/0001-musl-enable-getrandom-on-all-musl-platforms.patch
meta-python/recipes-devtools/python/python3-pydantic-core/0001-musl-enable-getrandom-on-all-musl-platforms.patch new file +81 -0
new file mode 100644
index 0000000000..fd94526686
@@ -0,0 +1,81 @@
+From 4253e25b7f31d207c69b9997f403b6e4e560e258 Mon Sep 17 00:00:00 2001
+From: Tamir Duberstein <[email protected]>
+Date: Thu, 20 Mar 2025 11:45:08 -0400
+Subject: [PATCH] musl: enable `getrandom` on all musl platforms
+
+The existing bindings were added in #1399 and limited to targets where
+rustc used musl version >= 1.1.20 which was not all musl targets at that
+time. Since https://github.com/rust-lang/rust/pull/107129 all musl
+targets use musl 1.2.3. Hence, move the binding to the module root so it
+is available for all musl targets.
+
+Upstream-Status: Backport [https://github.com/rust-lang/libc/pull/4346]
+Signed-off-by: Khem Raj <[email protected]>
+---
+ src/unix/linux_like/linux/musl/b32/arm/mod.rs | 4 ----
+ src/unix/linux_like/linux/musl/b32/powerpc.rs | 4 ----
+ src/unix/linux_like/linux/musl/b32/x86/mod.rs | 4 ----
+ src/unix/linux_like/linux/musl/b64/mod.rs     | 4 ----
+ src/unix/linux_like/linux/musl/mod.rs         | 2 ++
+ 5 files changed, 2 insertions(+), 16 deletions(-)
+
+--- a/src/unix/linux_like/linux/musl/b32/arm/mod.rs
++++ b/src/unix/linux_like/linux/musl/b32/arm/mod.rs
+@@ -841,10 +841,6 @@ pub const SYS_process_mrelease: ::c_long
+ pub const SYS_futex_waitv: ::c_long = 449;
+ pub const SYS_set_mempolicy_home_node: ::c_long = 450;
+ 
+-extern "C" {
+-    pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t;
+-}
+-
+ cfg_if! {
+     if #[cfg(libc_align)] {
+         mod align;
+--- a/src/unix/linux_like/linux/musl/b32/powerpc.rs
++++ b/src/unix/linux_like/linux/musl/b32/powerpc.rs
+@@ -796,7 +796,3 @@ pub const SYS_memfd_secret: ::c_long = 4
+ pub const SYS_process_mrelease: ::c_long = 448;
+ pub const SYS_futex_waitv: ::c_long = 449;
+ pub const SYS_set_mempolicy_home_node: ::c_long = 450;
+-
+-extern "C" {
+-    pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t;
+-}
+--- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs
++++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs
+@@ -956,10 +956,6 @@ pub const EFL: ::c_int = 14;
+ pub const UESP: ::c_int = 15;
+ pub const SS: ::c_int = 16;
+ 
+-extern "C" {
+-    pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t;
+-}
+-
+ cfg_if! {
+     if #[cfg(libc_align)] {
+         mod align;
+--- a/src/unix/linux_like/linux/musl/b64/mod.rs
++++ b/src/unix/linux_like/linux/musl/b64/mod.rs
+@@ -134,10 +134,6 @@ pub const __SIZEOF_PTHREAD_RWLOCK_T: usi
+ pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40;
+ pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32;
+ 
+-extern "C" {
+-    pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t;
+-}
+-
+ cfg_if! {
+     if #[cfg(target_arch = "aarch64")] {
+         mod aarch64;
+--- a/src/unix/linux_like/linux/musl/mod.rs
++++ b/src/unix/linux_like/linux/musl/mod.rs
+@@ -885,6 +885,8 @@ extern "C" {
+ 
+     pub fn dirname(path: *mut ::c_char) -> *mut ::c_char;
+     pub fn basename(path: *mut ::c_char) -> *mut ::c_char;
++    // Addded in `musl` 1.1.20
++    pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t;
+ }
+ 
+ // Alias <foo> to <foo>64 to mimic glibc's LFS64 support
meta-python/recipes-devtools/python/python3-pydantic-core_2.35.2.bb +1 -0
index 1d0d1f477b..788cbd2ceb 100644
@@ -11,6 +11,7 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=ab599c188b4a314d2856b3a55030c75c"
 require ${BPN}-crates.inc
 
 SRC_URI += "file://0001-Upgrade-radium-to-1.0.patch;patchdir=${UNPACKDIR}/cargo_home/bitbake/bitvec-1.0.1/"
+SRC_URI += "file://0001-musl-enable-getrandom-on-all-musl-platforms.patch;patchdir=${UNPACKDIR}/cargo_home/bitbake/libc-0.2.155/"
 SRC_URI += "file://0001-cargo.toml-Update-bitvec-to-use-radium-1.x.patch"
 SRC_URI[sha256sum] = "e010b13ff0d6375ee83f7478fbda42e1fbf55f1b2feef76b673c40861ffd31e6"