bytecodealliance / rustix

Safe Rust bindings to POSIX-ish APIs
Other
1.5k stars 164 forks source link

Several compilation issues on uClibc targets in version 0.38.28. #980

Closed spritetong closed 10 months ago

spritetong commented 10 months ago
  1. msghdr::msg_iovlen is ::c_int on uClibc targets of arm mips32. libc/src/unix/linux_like/linux/uclibc/arm/mod.rs libc/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs

  2. There is no prlimit64() function on uClibc targets. libc/src/unix/linux_like/linux/uclibc/mod.rs

I have made a patch for these issues, for your reference.

diff --git a/src/backend/libc/c.rs b/src/backend/libc/c.rs
index d3a1e5f4..5af91571 100644
--- a/src/backend/libc/c.rs
+++ b/src/backend/libc/c.rs
@@ -166,7 +166,7 @@ pub(super) use libc::{pread64 as pread, pwrite64 as pwrite};
 #[cfg(any(target_os = "linux", target_os = "hurd", target_os = "emscripten"))]
 pub(super) use libc::{preadv64 as preadv, pwritev64 as pwritev};

-#[cfg(all(target_os = "linux", target_env = "gnu"))]
+#[cfg(all(target_os = "linux", any(target_env = "gnu", target_env = "uclibc")))]
 pub(super) unsafe fn prlimit(
     pid: libc::pid_t,
     resource: libc::__rlimit_resource_t,
diff --git a/src/backend/libc/conv.rs b/src/backend/libc/conv.rs
index 25395100..1f9bcaf2 100644
--- a/src/backend/libc/conv.rs
+++ b/src/backend/libc/conv.rs
@@ -182,7 +182,11 @@ pub(super) fn ret_send_recv(len: i32) -> io::Result<usize> {
     not(any(windows, target_os = "espidf", target_os = "redox", target_os = "wasi")),
     any(
         target_os = "android",
-        all(target_os = "linux", not(target_env = "musl"))
+        all(
+            target_os = "linux",
+            not(target_env = "musl"),
+            not(all(target_env = "uclibc", any(target_arch = "arm", target_arch = "mips")))
+        )
     )
 ))]
 #[inline]
@@ -201,7 +205,11 @@ pub(super) fn msg_iov_len(len: usize) -> c::size_t {
     )),
     not(any(
         target_os = "android",
-        all(target_os = "linux", not(target_env = "musl"))
+        all(
+            target_os = "linux",
+            not(target_env = "musl"),
+            not(all(target_env = "uclibc", any(target_arch = "arm", target_arch = "mips")))
+        )
     ))
 ))]
 #[inline]
sunfishcode commented 10 months ago

This is released in rustix 0.38.29.

spritetong commented 10 months ago

Thanks. 😊