Skip to contentSkip to conversation

cargo-c,rust: Fix build on risv32

PATCH New Khem Raj 1 participant 2 messages Apr 6, 2025 RISC-V

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH v4 1/2 cargo-c,rust: Fix build on risv32

Apply fix in libc that are needed for rustix-0.38 to build.

---
v2: Update all rustix patches to same change thats submitted upstream
v3: Update Upstream-Status to submitted
v4: Right fix it to have this in libc as proposed upstream as well

 ...l-codes-on-riscv32gc-unknown-linux-g.patch |  38 +++
 .../rust/cargo-c_0.10.5+cargo-0.83.0.bb       |   1 +
 ...l-codes-on-riscv32gc-unknown-linux-g.patch | 112 +++++++++
 .../files/rv32-cargo-rustix-0.38.40-fix.patch | 236 ------------------
 meta/recipes-devtools/rust/rust-source.inc    |   2 +-
 5 files changed, 152 insertions(+), 237 deletions(-)
 create mode 100644 meta/recipes-devtools/rust/cargo-c/0001-Define-more-ioctl-codes-on-riscv32gc-unknown-linux-g.patch
 create mode 100644 meta/recipes-devtools/rust/files/0001-Define-more-ioctl-codes-on-riscv32gc-unknown-linux-g.patch
 delete mode 100644 meta/recipes-devtools/rust/files/rv32-cargo-rustix-0.38.40-fix.patch
meta/recipes-devtools/rust/cargo-c/0001-Define-more-ioctl-codes-on-riscv32gc-unknown-linux-g.patch new file +38 -0
new file mode 100644
index 00000000000..3b9936131ac
@@ -0,0 +1,38 @@
+From 3665e73b2f087370f8058c12911996b109d8e93a Mon Sep 17 00:00:00 2001
+From: Dan Gohman <[email protected]>
+Date: Sun, 6 Apr 2025 05:22:49 -0700
+Subject: [PATCH] Define more ioctl codes on riscv32gc-unknown-linux-gnu
+
+Define ioctl codes including `FICLONE` and `FS_IOC32_GETVERSION` on
+riscv32gc-unknown-linux-gnu.
+
+Upstream-Status: Submitted [https://github.com/rust-lang/libc/pull/4382]
+Signed-off-by: Khem Raj <[email protected]>
+---
+ src/unix/linux_like/linux/arch/generic/mod.rs | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/src/unix/linux_like/linux/arch/generic/mod.rs b/src/unix/linux_like/linux/arch/generic/mod.rs
+index 2f437e1..fdac4bb 100644
+--- a/src/unix/linux_like/linux/arch/generic/mod.rs
++++ b/src/unix/linux_like/linux/arch/generic/mod.rs
+@@ -114,6 +114,7 @@ cfg_if! {
+                  target_arch = "x86_64",
+                  target_arch = "arm",
+                  target_arch = "aarch64",
++                 target_arch = "riscv32",
+                  target_arch = "riscv64",
+                  target_arch = "s390x",
+                  target_arch = "csky",
+@@ -218,7 +219,10 @@ cfg_if! {
+     // where S stands for size (int, long, struct...)
+     // where T stands for type ('f','v','X'...)
+     // where N stands for NR (NumbeR)
+-    if #[cfg(any(target_arch = "x86", target_arch = "arm", target_arch = "csky"))] {
++    if #[cfg(any(target_arch = "x86",
++                 target_arch = "arm",
++                 target_arch = "csky",
++                 target_arch = "riscv32"))] {
+         pub const FS_IOC_GETFLAGS: ::Ioctl = 0x80046601;
+         pub const FS_IOC_SETFLAGS: ::Ioctl = 0x40046602;
+         pub const FS_IOC_GETVERSION: ::Ioctl = 0x80047601;
meta/recipes-devtools/rust/cargo-c_0.10.5+cargo-0.83.0.bb +1 -0
index c6e88e6fadb..b8b646e3849 100644
@@ -6,6 +6,7 @@ LIC_FILES_CHKSUM = " \
 "
 
 SRC_URI = "crate://crates.io/cargo-c/${PV};name=cargo-c"
+SRC_URI += "file://0001-Define-more-ioctl-codes-on-riscv32gc-unknown-linux-g.patch;patchdir=${CARGO_VENDORING_DIRECTORY}/libc-0.2.161"
 SRC_URI[cargo-c.sha256sum] = "5bfa9ba93806384d940e71dafbc185316e0a6a47561b33b7105fcf67f99df70a"
 S = "${CARGO_VENDORING_DIRECTORY}/cargo-c-${PV}"
 
meta/recipes-devtools/rust/files/0001-Define-more-ioctl-codes-on-riscv32gc-unknown-linux-g.patch new file +112 -0

112 lines not on this page · raw message

meta/recipes-devtools/rust/files/rv32-cargo-rustix-0.38.40-fix.patch deleted +0 -236

236 lines not on this page · raw message

meta/recipes-devtools/rust/rust-source.inc +1 -1
index 8400a4875dd..25c0a1ce52a 100644
@@ -1,7 +1,7 @@
 RUST_VERSION ?= "${@d.getVar('PV').split('-')[0]}"
 
 SRC_URI += "https://static.rust-lang.org/dist/rustc-${RUST_VERSION}-src.tar.xz;name=rust \
-            file://rv32-cargo-rustix-0.38.40-fix.patch;patchdir=${RUSTSRC} \
+            file://0001-Define-more-ioctl-codes-on-riscv32gc-unknown-linux-g.patch;patchdir=${RUSTSRC} \
             file://rust-oe-selftest.patch;patchdir=${RUSTSRC} \
             file://repro-issue-fix-with-cc-crate-hashmap.patch;patchdir=${RUSTSRC} \
             file://oeqa-selftest-Increase-timeout-in-process-sigpipe-ru.patch;patchdir=${RUSTSRC} \
author
#1 lore raw

PATCH v2 2/2 python3-maturin: Fix build on riscv32

There is a libc patch needed to fix rustix 0.38.x build It is already submitted to libc upstream but until its applied it needs to be patched

---
v2: Right fix is in libc not rustix, update the patch accordingly

 ...l-codes-on-riscv32gc-unknown-linux-g.patch | 36 +++++++++++++++++++
 .../python/python3-maturin_1.8.3.bb           |  1 +
 2 files changed, 37 insertions(+)
 create mode 100644 meta/recipes-devtools/python/python3-maturin/0001-Define-more-ioctl-codes-on-riscv32gc-unknown-linux-g.patch
meta/recipes-devtools/python/python3-maturin/0001-Define-more-ioctl-codes-on-riscv32gc-unknown-linux-g.patch new file +36 -0
new file mode 100644
index 00000000000..84e0b5d4f88
@@ -0,0 +1,36 @@
+From 7da2aecff6de042424b0e54b631bfcdbccdcfc89 Mon Sep 17 00:00:00 2001
+From: Dan Gohman <[email protected]>
+Date: Sun, 6 Apr 2025 05:22:49 -0700
+Subject: [PATCH] Define more ioctl codes on riscv32gc-unknown-linux-gnu
+
+Define ioctl codes including `FICLONE` and `FS_IOC32_GETVERSION` on
+riscv32gc-unknown-linux-gnu.
+
+Upstream-Status: Submitted [https://github.com/rust-lang/libc/pull/4382]
+Signed-off-by: Khem Raj <[email protected]>
+---
+ src/unix/linux_like/linux/arch/generic/mod.rs | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/src/unix/linux_like/linux/arch/generic/mod.rs b/src/unix/linux_like/linux/arch/generic/mod.rs
+index 10953fe..e9fd7fc 100644
+--- a/src/unix/linux_like/linux/arch/generic/mod.rs
++++ b/src/unix/linux_like/linux/arch/generic/mod.rs
+@@ -122,6 +122,7 @@ cfg_if! {
+         target_arch = "x86_64",
+         target_arch = "arm",
+         target_arch = "aarch64",
++        target_arch = "riscv32",
+         target_arch = "riscv64",
+         target_arch = "s390x",
+         target_arch = "csky",
+@@ -258,7 +259,8 @@ cfg_if! {
+     if #[cfg(any(
+         target_arch = "x86",
+         target_arch = "arm",
+-        target_arch = "csky"
++        target_arch = "csky",
++        target_arch = "riscv32"
+     ))] {
+         pub const FS_IOC_GETFLAGS: Ioctl = 0x80046601;
+         pub const FS_IOC_SETFLAGS: Ioctl = 0x40046602;
meta/recipes-devtools/python/python3-maturin_1.8.3.bb +1 -0
index 17c8fb7083b..3ec4d0c103b 100644
@@ -5,6 +5,7 @@ LICENSE = "MIT | Apache-2.0"
 LIC_FILES_CHKSUM = "file://license-apache;md5=1836efb2eb779966696f473ee8540542 \
                     file://license-mit;md5=85fd3b67069cff784d98ebfc7d5c0797"
 
+SRC_URI += "file://0001-Define-more-ioctl-codes-on-riscv32gc-unknown-linux-g.patch;patchdir=${CARGO_VENDORING_DIRECTORY}/libc-0.2.167"
 SRC_URI[sha256sum] = "304762f86fd53a8031b1bf006d12572a2aa0a5235485031113195cc0152e1e12"
 
 S = "${WORKDIR}/maturin-${PV}"