Skip to contentSkip to conversation

cargo-c,rust: Fix build on risv32

PATCH Superseded Khem Raj 1 participant 1 message Apr 5, 2025 RISC-V

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

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

Apply fixes needed for rustix-0.38 release. once upgraded to 1.x these patches are not needed anymore

---
 .../0001-Fix-cargo-build-on-riscv32.patch     |  59 +++++
 .../rust/cargo-c_0.10.5+cargo-0.83.0.bb       |   1 +
 .../0001-Fix-cargo-build-on-riscv32.patch     |  65 +++++
 ...-Fix-rustix-0.38.42-build-on-riscv32.patch |  77 ++++++
 .../files/rv32-cargo-rustix-0.38.40-fix.patch | 236 ------------------
 meta/recipes-devtools/rust/rust-source.inc    |   3 +-
 6 files changed, 204 insertions(+), 237 deletions(-)
 create mode 100644 meta/recipes-devtools/rust/cargo-c/0001-Fix-cargo-build-on-riscv32.patch
 create mode 100644 meta/recipes-devtools/rust/files/0001-Fix-cargo-build-on-riscv32.patch
 create mode 100644 meta/recipes-devtools/rust/files/0001-Fix-rustix-0.38.42-build-on-riscv32.patch
 delete mode 100644 meta/recipes-devtools/rust/files/rv32-cargo-rustix-0.38.40-fix.patch
meta/recipes-devtools/rust/cargo-c/0001-Fix-cargo-build-on-riscv32.patch new file +59 -0
new file mode 100644
index 00000000000..38109f363bb
@@ -0,0 +1,59 @@
+From b85c7b406f017589eb959cd619ba442837ada470 Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Fri, 4 Apr 2025 00:29:22 -0700
+Subject: [PATCH] Fix cargo build on riscv32
+
+riscv32 support is added to latest rustix already
+therefore this patch is limited to rustix-0.38.19
+once cargo/rust moves beyond rustix-0.38.19 as dependency
+we can remove this patch
+
+Upstream-Status: Inappropriate [Specific to rustix-0.38.19]
+
+Signed-off-by: Khem Raj <[email protected]>
+---
+ src/fs/ioctl.rs | 10 ++++++----
+ 1 file changed, 6 insertions(+), 4 deletions(-)
+
+diff --git a/src/fs/ioctl.rs b/src/fs/ioctl.rs
+index 718a2a4..794ab89 100644
+--- a/src/fs/ioctl.rs
++++ b/src/fs/ioctl.rs
+@@ -10,6 +10,9 @@ use {
+ };
+ 
+ use bitflags::bitflags;
++use linux_raw_sys::ioctl::FICLONE;
++use linux_raw_sys::ioctl::FS_IOC32_GETFLAGS;
++use linux_raw_sys::ioctl::FS_IOC32_SETFLAGS;
+ 
+ #[cfg(all(linux_kernel, not(any(target_arch = "sparc", target_arch = "sparc64"))))]
+ use crate::fd::{AsRawFd, BorrowedFd};
+@@ -79,7 +82,7 @@ unsafe impl ioctl::Ioctl for Ficlone<'_> {
+     type Output = ();
+ 
+     const IS_MUTATING: bool = false;
+-    const OPCODE: ioctl::Opcode = ioctl::Opcode::old(c::FICLONE as ioctl::RawOpcode);
++    const OPCODE: ioctl::Opcode = ioctl::Opcode::old(FICLONE as ioctl::RawOpcode);
+ 
+     fn as_ptr(&mut self) -> *mut c::c_void {
+         self.0.as_raw_fd() as *mut c::c_void
+@@ -139,7 +142,7 @@ bitflags! {
+ pub fn ioctl_getflags<Fd: AsFd>(fd: Fd) -> io::Result<IFlags> {
+     unsafe {
+         #[cfg(target_pointer_width = "32")]
+-        let ctl = ioctl::Getter::<ioctl::BadOpcode<{ c::FS_IOC32_GETFLAGS }>, u32>::new();
++        let ctl = ioctl::Getter::<ioctl::BadOpcode<{ FS_IOC32_GETFLAGS }>, u32>::new();
+         #[cfg(target_pointer_width = "64")]
+         let ctl = ioctl::Getter::<ioctl::BadOpcode<{ c::FS_IOC_GETFLAGS }>, u32>::new();
+ 
+@@ -156,8 +159,7 @@ pub fn ioctl_getflags<Fd: AsFd>(fd: Fd) -> io::Result<IFlags> {
+ pub fn ioctl_setflags<Fd: AsFd>(fd: Fd, flags: IFlags) -> io::Result<()> {
+     unsafe {
+         #[cfg(target_pointer_width = "32")]
+-        let ctl =
+-            ioctl::Setter::<ioctl::BadOpcode<{ c::FS_IOC32_SETFLAGS }>, u32>::new(flags.bits());
++        let ctl = ioctl::Setter::<ioctl::BadOpcode<{ FS_IOC32_SETFLAGS }>, u32>::new(flags.bits());
+ 
+         #[cfg(target_pointer_width = "64")]
+         let ctl = ioctl::Setter::<ioctl::BadOpcode<{ c::FS_IOC_SETFLAGS }>, u32>::new(flags.bits());
meta/recipes-devtools/rust/cargo-c_0.10.5+cargo-0.83.0.bb +1 -0
index c6e88e6fadb..e2de4784937 100644
@@ -6,6 +6,7 @@ LIC_FILES_CHKSUM = " \
 "
 
 SRC_URI = "crate://crates.io/cargo-c/${PV};name=cargo-c"
+SRC_URI += "file://0001-Fix-cargo-build-on-riscv32.patch;patchdir=${CARGO_VENDORING_DIRECTORY}/rustix-0.38.37"
 SRC_URI[cargo-c.sha256sum] = "5bfa9ba93806384d940e71dafbc185316e0a6a47561b33b7105fcf67f99df70a"
 S = "${CARGO_VENDORING_DIRECTORY}/cargo-c-${PV}"
 
meta/recipes-devtools/rust/files/0001-Fix-cargo-build-on-riscv32.patch new file +65 -0

65 lines not on this page · raw message

meta/recipes-devtools/rust/files/0001-Fix-rustix-0.38.42-build-on-riscv32.patch new file +77 -0

77 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 +2 -1
index 8400a4875dd..8b4ec501a81 100644
@@ -1,7 +1,8 @@
 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-Fix-rustix-0.38.42-build-on-riscv32.patch;patchdir=${RUSTSRC} \
+            file://0001-Fix-cargo-build-on-riscv32.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} \