-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
When I upgraded to a recent toolchain (2021-03-25) and updated some crates to today's latest as a result, I started getting errors about missing libc::pwrite64() for my uclibc-based target. I haven't tracked it all the way back to see when the error first started happening, but I think the issue is that the standard library source requires pwrite64() for non-Android Linux:
https://github.com/rust-lang/rust/blob/48691ea6e639640f110b43e33d4aba1f07e7415c/library/std/src/sys/unix/fd.rs#L167-L183
#[cfg(target_os = "linux")]
use libc::pwrite64;
cvt(pwrite64(fd, buf, count, offset))Whereas pwrite64() is disallowed for uclibc in the libc crate:
libc/src/unix/linux_like/mod.rs
Lines 1671 to 1685 in f913fc5
| cfg_if! { | |
| if #[cfg(not(target_env = "uclibc"))] { | |
| extern "C" { | |
| pub fn preadv64( | |
| fd: ::c_int, | |
| iov: *const ::iovec, | |
| iovcnt: ::c_int, | |
| offset: ::off64_t, | |
| ) -> ::ssize_t; | |
| pub fn pwrite64( | |
| fd: ::c_int, | |
| buf: *const ::c_void, | |
| count: ::size_t, | |
| offset: off64_t, | |
| ) -> ::ssize_t; |
However, the companion function pread64() is permitted for uclibc:
libc/src/unix/linux_like/mod.rs
Lines 1543 to 1548 in f913fc5
| pub fn pread64( | |
| fd: ::c_int, | |
| buf: *mut ::c_void, | |
| count: ::size_t, | |
| offset: off64_t, | |
| ) -> ::ssize_t; |
The actual pwrite64() function is available on my uclibc target. Considering that libc contains a SYS_pwrite64 value for uclibc targets, I suspect this is just an oversight in the libc crate, and that pwrite64() was not intended to be caveated by cfg(not(target_env = "uclibc")). Unless there is some other reason for disallowing pwrite64() on uclibc-based Linux targets, could this function be promoted to work for uclibc variants?