cargo-c,rust: Fix build on risv32
PATCH v2 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
Signed-off-by Khem Raj <[email protected]>
---
v2: Update all rustix patches to same change thats submitted upstream
.../0001-Fix-cargo-build-on-riscv32.patch | 75 ++++++ .../rust/cargo-c_0.10.5+cargo-0.83.0.bb | 1 + .../0001-Fix-cargo-build-on-riscv32.patch | 82 ++++++ ...-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, 237 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 +75 -0
@@ -0,0 +1,75 @@ +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(-) + +--- a/src/fs/ioctl.rs ++++ b/src/fs/ioctl.rs +@@ -11,6 +11,14 @@ use { + + use bitflags::bitflags; + ++/// The datatype used for the ioctl number ++#[cfg(any(target_os = "android", target_env = "musl"))] ++#[doc(hidden)] ++pub type ioctl_num_type = c::c_int; ++#[cfg(not(any(target_os = "android", target_env = "musl")))] ++#[doc(hidden)] ++pub type ioctl_num_type = c::c_ulong; ++ + #[cfg(all(linux_kernel, not(any(target_arch = "sparc", target_arch = "sparc64"))))] + use crate::fd::{AsRawFd, BorrowedFd}; + +@@ -79,7 +87,8 @@ 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(linux_raw_sys::ioctl::FICLONE as ioctl::RawOpcode); + + fn as_ptr(&mut self) -> *mut c::c_void { + self.0.as_raw_fd() as *mut c::c_void +@@ -138,7 +147,12 @@ bitflags! { + #[doc(alias = "FS_IOC_GETFLAGS")] + pub fn ioctl_getflags<Fd: AsFd>(fd: Fd) -> io::Result<IFlags> { + unsafe { +- #[cfg(target_pointer_width = "32")] ++ #[cfg(target_arch = "riscv32")] ++ let ctl = ioctl::Getter::< ++ ioctl::BadOpcode<{ linux_raw_sys::ioctl::FS_IOC32_GETFLAGS as ioctl_num_type }>, ++ u32, ++ >::new(); ++ #[cfg(all(target_pointer_width = "32", not(target_arch = "riscv32")))] + let ctl = ioctl::Getter::<ioctl::BadOpcode<{ c::FS_IOC32_GETFLAGS }>, u32>::new(); + #[cfg(target_pointer_width = "64")] + let ctl = ioctl::Getter::<ioctl::BadOpcode<{ c::FS_IOC_GETFLAGS }>, u32>::new(); +@@ -154,8 +168,15 @@ pub fn ioctl_getflags<Fd: AsFd>(fd: Fd) + #[inline] + #[doc(alias = "FS_IOC_SETFLAGS")] + pub fn ioctl_setflags<Fd: AsFd>(fd: Fd, flags: IFlags) -> io::Result<()> { ++ use crate::ioctl::Ioctl; ++ + unsafe { +- #[cfg(target_pointer_width = "32")] ++ #[cfg(target_arch = "riscv32")] ++ let ctl = ioctl::Setter::< ++ ioctl::BadOpcode<{ linux_raw_sys::ioctl::FS_IOC32_SETFLAGS as ioctl_num_type }>, ++ u32, ++ >::new(flags.bits()); ++ #[cfg(all(target_pointer_width = "32", not(target_arch = "riscv32")))] + let ctl = + ioctl::Setter::<ioctl::BadOpcode<{ c::FS_IOC32_SETFLAGS }>, u32>::new(flags.bits()); +
meta/recipes-devtools/rust/cargo-c_0.10.5+cargo-0.83.0.bb +1 -0
@@ -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 +82 -0
82 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
@@ -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} \