Skip to content

Commit cbbd524

Browse files
committed
Auto merge of rust-lang#115968 - git-bruh:master, r=workingjubilee
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`
2 parents 17659c7 + 65475f5 commit cbbd524

File tree

3 files changed

+42
-14
lines changed

3 files changed

+42
-14
lines changed

library/std/src/os/linux/fs.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,14 @@ pub trait MetadataExt {
329329
impl MetadataExt for Metadata {
330330
#[allow(deprecated)]
331331
fn as_raw_stat(&self) -> &raw::stat {
332-
unsafe { &*(self.as_inner().as_inner() as *const libc::stat64 as *const raw::stat) }
332+
#[cfg(target_env = "musl")]
333+
unsafe {
334+
&*(self.as_inner().as_inner() as *const libc::stat as *const raw::stat)
335+
}
336+
#[cfg(not(target_env = "musl"))]
337+
unsafe {
338+
&*(self.as_inner().as_inner() as *const libc::stat64 as *const raw::stat)
339+
}
333340
}
334341
fn st_dev(&self) -> u64 {
335342
self.as_inner().as_inner().st_dev as u64

library/std/src/sys/unix/fd.rs

+20-4
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,17 @@ impl FileDesc {
126126
}
127127

128128
pub fn read_at(&self, buf: &mut [u8], offset: u64) -> io::Result<usize> {
129-
#[cfg(not(any(target_os = "linux", target_os = "android", target_os = "hurd")))]
129+
#[cfg(not(any(
130+
all(target_os = "linux", not(target_env = "musl")),
131+
target_os = "android",
132+
target_os = "hurd"
133+
)))]
130134
use libc::pread as pread64;
131-
#[cfg(any(target_os = "linux", target_os = "android", target_os = "hurd"))]
135+
#[cfg(any(
136+
all(target_os = "linux", not(target_env = "musl")),
137+
target_os = "android",
138+
target_os = "hurd"
139+
))]
132140
use libc::pread64;
133141

134142
unsafe {
@@ -285,9 +293,17 @@ impl FileDesc {
285293
}
286294

287295
pub fn write_at(&self, buf: &[u8], offset: u64) -> io::Result<usize> {
288-
#[cfg(not(any(target_os = "linux", target_os = "android", target_os = "hurd")))]
296+
#[cfg(not(any(
297+
all(target_os = "linux", not(target_env = "musl")),
298+
target_os = "android",
299+
target_os = "hurd"
300+
)))]
289301
use libc::pwrite as pwrite64;
290-
#[cfg(any(target_os = "linux", target_os = "android", target_os = "hurd"))]
302+
#[cfg(any(
303+
all(target_os = "linux", not(target_env = "musl")),
304+
target_os = "android",
305+
target_os = "hurd"
306+
))]
291307
use libc::pwrite64;
292308

293309
unsafe {

library/std/src/sys/unix/fs.rs

+14-9
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,17 @@ use libc::{c_int, mode_t};
4040
))]
4141
use libc::c_char;
4242
#[cfg(any(
43-
target_os = "linux",
43+
all(target_os = "linux", not(target_env = "musl")),
4444
target_os = "emscripten",
4545
target_os = "android",
46-
target_os = "hurd",
46+
target_os = "hurd"
4747
))]
4848
use libc::dirfd;
49-
#[cfg(any(target_os = "linux", target_os = "emscripten", target_os = "hurd"))]
49+
#[cfg(any(
50+
all(target_os = "linux", not(target_env = "musl")),
51+
target_os = "emscripten",
52+
target_os = "hurd"
53+
))]
5054
use libc::fstatat64;
5155
#[cfg(any(
5256
target_os = "android",
@@ -57,9 +61,10 @@ use libc::fstatat64;
5761
target_os = "aix",
5862
target_os = "nto",
5963
target_os = "vita",
64+
all(target_os = "linux", target_env = "musl"),
6065
))]
6166
use libc::readdir as readdir64;
62-
#[cfg(any(target_os = "linux", target_os = "hurd"))]
67+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "hurd"))]
6368
use libc::readdir64;
6469
#[cfg(any(target_os = "emscripten", target_os = "l4re"))]
6570
use libc::readdir64_r;
@@ -84,7 +89,7 @@ use libc::{
8489
lstat as lstat64, off64_t, open as open64, stat as stat64,
8590
};
8691
#[cfg(not(any(
87-
target_os = "linux",
92+
all(target_os = "linux", not(target_env = "musl")),
8893
target_os = "emscripten",
8994
target_os = "l4re",
9095
target_os = "android",
@@ -95,7 +100,7 @@ use libc::{
95100
lstat as lstat64, off_t as off64_t, open as open64, stat as stat64,
96101
};
97102
#[cfg(any(
98-
target_os = "linux",
103+
all(target_os = "linux", not(target_env = "musl")),
99104
target_os = "emscripten",
100105
target_os = "l4re",
101106
target_os = "hurd"
@@ -853,10 +858,10 @@ impl DirEntry {
853858

854859
#[cfg(all(
855860
any(
856-
target_os = "linux",
861+
all(target_os = "linux", not(target_env = "musl")),
857862
target_os = "emscripten",
858863
target_os = "android",
859-
target_os = "hurd",
864+
target_os = "hurd"
860865
),
861866
not(miri)
862867
))]
@@ -882,7 +887,7 @@ impl DirEntry {
882887

883888
#[cfg(any(
884889
not(any(
885-
target_os = "linux",
890+
all(target_os = "linux", not(target_env = "musl")),
886891
target_os = "emscripten",
887892
target_os = "android",
888893
target_os = "hurd",

0 commit comments

Comments
 (0)