Skip to content

Commit

Permalink
Rollup merge of rust-lang#115968 - git-bruh:master, r=workingjubilee
Browse files Browse the repository at this point in the history
Don't use LFS64 symbols on musl

Supersedes rust-lang#106246

~~Note to packagers: If your distro's musl package has already been updated, then you won't be able to build a newer version of rust until a new rust release is made with these changes merged (which can be used to bootstrap). I'm using a super hacky method to bypass this by creating a stub library with LFS64 symbols and building a patched rust, so the symbols satisfy the build requirements while the final compiler build has no references to LFS64 symbols, example: https://codeberg.org/kiss-community/repo/pulls/160/files~~ Doesn't seem to be necessary with new rustup nightly builds, likely due to updates to vendored crates

cc `@alyssais`
  • Loading branch information
workingjubilee committed Oct 29, 2023
2 parents bbcc169 + 7a504cc commit 2d0e4db
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 14 deletions.
9 changes: 8 additions & 1 deletion library/std/src/os/linux/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,14 @@ pub trait MetadataExt {
impl MetadataExt for Metadata {
#[allow(deprecated)]
fn as_raw_stat(&self) -> &raw::stat {
unsafe { &*(self.as_inner().as_inner() as *const libc::stat64 as *const raw::stat) }
#[cfg(target_env = "musl")]
unsafe {
&*(self.as_inner().as_inner() as *const libc::stat as *const raw::stat)
}
#[cfg(not(target_env = "musl"))]
unsafe {
&*(self.as_inner().as_inner() as *const libc::stat64 as *const raw::stat)
}
}
fn st_dev(&self) -> u64 {
self.as_inner().as_inner().st_dev as u64
Expand Down
24 changes: 20 additions & 4 deletions library/std/src/sys/unix/fd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,17 @@ impl FileDesc {
}

pub fn read_at(&self, buf: &mut [u8], offset: u64) -> io::Result<usize> {
#[cfg(not(any(target_os = "linux", target_os = "android", target_os = "hurd")))]
#[cfg(not(any(
all(target_os = "linux", not(target_env = "musl")),
target_os = "android",
target_os = "hurd"
)))]
use libc::pread as pread64;
#[cfg(any(target_os = "linux", target_os = "android", target_os = "hurd"))]
#[cfg(any(
all(target_os = "linux", not(target_env = "musl")),
target_os = "android",
target_os = "hurd"
))]
use libc::pread64;

unsafe {
Expand Down Expand Up @@ -285,9 +293,17 @@ impl FileDesc {
}

pub fn write_at(&self, buf: &[u8], offset: u64) -> io::Result<usize> {
#[cfg(not(any(target_os = "linux", target_os = "android", target_os = "hurd")))]
#[cfg(not(any(
all(target_os = "linux", not(target_env = "musl")),
target_os = "android",
target_os = "hurd"
)))]
use libc::pwrite as pwrite64;
#[cfg(any(target_os = "linux", target_os = "android", target_os = "hurd"))]
#[cfg(any(
all(target_os = "linux", not(target_env = "musl")),
target_os = "android",
target_os = "hurd"
))]
use libc::pwrite64;

unsafe {
Expand Down
23 changes: 14 additions & 9 deletions library/std/src/sys/unix/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,17 @@ use libc::{c_int, mode_t};
))]
use libc::c_char;
#[cfg(any(
target_os = "linux",
all(target_os = "linux", not(target_env = "musl")),
target_os = "emscripten",
target_os = "android",
target_os = "hurd",
target_os = "hurd"
))]
use libc::dirfd;
#[cfg(any(target_os = "linux", target_os = "emscripten", target_os = "hurd"))]
#[cfg(any(
all(target_os = "linux", not(target_env = "musl")),
target_os = "emscripten",
target_os = "hurd"
))]
use libc::fstatat64;
#[cfg(any(
target_os = "android",
Expand All @@ -57,9 +61,10 @@ use libc::fstatat64;
target_os = "aix",
target_os = "nto",
target_os = "vita",
all(target_os = "linux", target_env = "musl"),
))]
use libc::readdir as readdir64;
#[cfg(any(target_os = "linux", target_os = "hurd"))]
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "hurd"))]
use libc::readdir64;
#[cfg(any(target_os = "emscripten", target_os = "l4re"))]
use libc::readdir64_r;
Expand All @@ -84,7 +89,7 @@ use libc::{
lstat as lstat64, off64_t, open as open64, stat as stat64,
};
#[cfg(not(any(
target_os = "linux",
all(target_os = "linux", not(target_env = "musl")),
target_os = "emscripten",
target_os = "l4re",
target_os = "android",
Expand All @@ -95,7 +100,7 @@ use libc::{
lstat as lstat64, off_t as off64_t, open as open64, stat as stat64,
};
#[cfg(any(
target_os = "linux",
all(target_os = "linux", not(target_env = "musl")),
target_os = "emscripten",
target_os = "l4re",
target_os = "hurd"
Expand Down Expand Up @@ -853,10 +858,10 @@ impl DirEntry {

#[cfg(all(
any(
target_os = "linux",
all(target_os = "linux", not(target_env = "musl")),
target_os = "emscripten",
target_os = "android",
target_os = "hurd",
target_os = "hurd"
),
not(miri)
))]
Expand All @@ -882,7 +887,7 @@ impl DirEntry {

#[cfg(any(
not(any(
target_os = "linux",
all(target_os = "linux", not(target_env = "musl")),
target_os = "emscripten",
target_os = "android",
target_os = "hurd",
Expand Down

0 comments on commit 2d0e4db

Please sign in to comment.