mirror of
https://codeberg.org/kiss-community/repo
synced 2024-08-24 23:06:19 +00:00
166 lines
6.1 KiB
Diff
166 lines
6.1 KiB
Diff
|
Patch-Source: https://github.com/rust-lang/rust/pull/106246
|
||
|
--
|
||
|
From e2355ea7f22219f1fb3919a45e4f07502652ee5c Mon Sep 17 00:00:00 2001
|
||
|
From: Khem Raj <raj.khem@gmail.com>
|
||
|
Date: Fri, 19 May 2023 09:22:21 -0700
|
||
|
Subject: [PATCH] Do not use LFS64 on linux with musl
|
||
|
|
||
|
glibc is providing open64 and other lfs64 functions but musl aliases
|
||
|
them to normal equivalents since off_t is always 64-bit on musl,
|
||
|
therefore check for target env along when target OS is linux before
|
||
|
using open64, this is more available. Latest Musl has made these
|
||
|
namespace changes [1]
|
||
|
|
||
|
[1] https://git.musl-libc.org/cgit/musl/commit/?id=246f1c811448f37a44b41cd8df8d0ef9736d95f4
|
||
|
|
||
|
Signed-off-by: Khem Raj <raj.khem@gmail.com>
|
||
|
---
|
||
|
library/std/src/os/linux/fs.rs | 9 ++++++++-
|
||
|
library/std/src/sys/unix/fd.rs | 14 ++++++++++----
|
||
|
library/std/src/sys/unix/fs.rs | 25 +++++++++++++++++++------
|
||
|
3 files changed, 37 insertions(+), 11 deletions(-)
|
||
|
|
||
|
diff --git a/library/std/src/os/linux/fs.rs b/library/std/src/os/linux/fs.rs
|
||
|
index 479bbcc17a89e..ab0b2a3eda3f5 100644
|
||
|
--- a/library/std/src/os/linux/fs.rs
|
||
|
+++ b/library/std/src/os/linux/fs.rs
|
||
|
@@ -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
|
||
|
diff --git a/library/std/src/sys/unix/fd.rs b/library/std/src/sys/unix/fd.rs
|
||
|
index cb630eede6da0..c1e0c05213ac2 100644
|
||
|
--- a/library/std/src/sys/unix/fd.rs
|
||
|
+++ b/library/std/src/sys/unix/fd.rs
|
||
|
@@ -122,9 +122,12 @@ impl FileDesc {
|
||
|
}
|
||
|
|
||
|
pub fn read_at(&self, buf: &mut [u8], offset: u64) -> io::Result<usize> {
|
||
|
- #[cfg(not(any(target_os = "linux", target_os = "android")))]
|
||
|
+ #[cfg(not(any(
|
||
|
+ all(target_os = "linux", not(target_env = "musl")),
|
||
|
+ target_os = "android"
|
||
|
+ )))]
|
||
|
use libc::pread as pread64;
|
||
|
- #[cfg(any(target_os = "linux", target_os = "android"))]
|
||
|
+ #[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
|
||
|
use libc::pread64;
|
||
|
|
||
|
unsafe {
|
||
|
@@ -277,9 +280,12 @@ impl FileDesc {
|
||
|
}
|
||
|
|
||
|
pub fn write_at(&self, buf: &[u8], offset: u64) -> io::Result<usize> {
|
||
|
- #[cfg(not(any(target_os = "linux", target_os = "android")))]
|
||
|
+ #[cfg(not(any(
|
||
|
+ all(target_os = "linux", not(target_env = "musl")),
|
||
|
+ target_os = "android"
|
||
|
+ )))]
|
||
|
use libc::pwrite as pwrite64;
|
||
|
- #[cfg(any(target_os = "linux", target_os = "android"))]
|
||
|
+ #[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
|
||
|
use libc::pwrite64;
|
||
|
|
||
|
unsafe {
|
||
|
diff --git a/library/std/src/sys/unix/fs.rs b/library/std/src/sys/unix/fs.rs
|
||
|
index 09db5b11dbfd3..e31f987c7dc9a 100644
|
||
|
--- a/library/std/src/sys/unix/fs.rs
|
||
|
+++ b/library/std/src/sys/unix/fs.rs
|
||
|
@@ -47,9 +47,13 @@ use libc::{c_int, mode_t};
|
||
|
all(target_os = "linux", target_env = "gnu")
|
||
|
))]
|
||
|
use libc::c_char;
|
||
|
-#[cfg(any(target_os = "linux", target_os = "emscripten", target_os = "android"))]
|
||
|
+#[cfg(any(
|
||
|
+ all(target_os = "linux", not(target_env = "musl")),
|
||
|
+ target_os = "emscripten",
|
||
|
+ target_os = "android"
|
||
|
+))]
|
||
|
use libc::dirfd;
|
||
|
-#[cfg(any(target_os = "linux", target_os = "emscripten"))]
|
||
|
+#[cfg(any(not(target_env = "musl"), target_os = "emscripten"))]
|
||
|
use libc::fstatat64;
|
||
|
#[cfg(any(
|
||
|
target_os = "android",
|
||
|
@@ -58,9 +62,10 @@ use libc::fstatat64;
|
||
|
target_os = "redox",
|
||
|
target_os = "illumos",
|
||
|
target_os = "nto",
|
||
|
+ target_env = "musl",
|
||
|
))]
|
||
|
use libc::readdir as readdir64;
|
||
|
-#[cfg(target_os = "linux")]
|
||
|
+#[cfg(all(target_os = "linux", not(target_env = "musl")))]
|
||
|
use libc::readdir64;
|
||
|
#[cfg(any(target_os = "emscripten", target_os = "l4re"))]
|
||
|
use libc::readdir64_r;
|
||
|
@@ -81,7 +86,13 @@ use libc::{
|
||
|
dirent as dirent64, fstat as fstat64, fstatat as fstatat64, ftruncate64, lseek64,
|
||
|
lstat as lstat64, off64_t, open as open64, stat as stat64,
|
||
|
};
|
||
|
+#[cfg(target_env = "musl")]
|
||
|
+use libc::{
|
||
|
+ dirent as dirent64, fstat as fstat64, ftruncate as ftruncate64, lseek as lseek64,
|
||
|
+ lstat as lstat64, off_t as off64_t, open as open64, stat as stat64,
|
||
|
+};
|
||
|
#[cfg(not(any(
|
||
|
+ target_env = "musl",
|
||
|
target_os = "linux",
|
||
|
target_os = "emscripten",
|
||
|
target_os = "l4re",
|
||
|
@@ -91,7 +102,7 @@ use libc::{
|
||
|
dirent as dirent64, fstat as fstat64, ftruncate as ftruncate64, lseek as lseek64,
|
||
|
lstat as lstat64, off_t as off64_t, open as open64, stat as stat64,
|
||
|
};
|
||
|
-#[cfg(any(target_os = "linux", target_os = "emscripten", target_os = "l4re"))]
|
||
|
+#[cfg(any(not(target_env = "musl"), target_os = "emscripten", target_os = "l4re"))]
|
||
|
use libc::{dirent64, fstat64, ftruncate64, lseek64, lstat64, off64_t, open64, stat64};
|
||
|
|
||
|
pub use crate::sys_common::fs::try_exists;
|
||
|
@@ -278,6 +289,7 @@ unsafe impl Sync for Dir {}
|
||
|
#[cfg(any(
|
||
|
target_os = "android",
|
||
|
target_os = "linux",
|
||
|
+ not(target_env = "musl"),
|
||
|
target_os = "solaris",
|
||
|
target_os = "illumos",
|
||
|
target_os = "fuchsia",
|
||
|
@@ -312,6 +324,7 @@ struct dirent64_min {
|
||
|
}
|
||
|
|
||
|
#[cfg(not(any(
|
||
|
+ target_env = "musl",
|
||
|
target_os = "android",
|
||
|
target_os = "linux",
|
||
|
target_os = "solaris",
|
||
|
@@ -798,7 +811,7 @@ impl DirEntry {
|
||
|
}
|
||
|
|
||
|
#[cfg(all(
|
||
|
- any(target_os = "linux", target_os = "emscripten", target_os = "android"),
|
||
|
+ any(not(target_env = "musl"), target_os = "emscripten", target_os = "android"),
|
||
|
not(miri)
|
||
|
))]
|
||
|
pub fn metadata(&self) -> io::Result<FileAttr> {
|
||
|
@@ -822,7 +835,7 @@ impl DirEntry {
|
||
|
}
|
||
|
|
||
|
#[cfg(any(
|
||
|
- not(any(target_os = "linux", target_os = "emscripten", target_os = "android")),
|
||
|
+ not(any(not(target_env = "musl"), target_os = "emscripten", target_os = "android")),
|
||
|
miri
|
||
|
))]
|
||
|
pub fn metadata(&self) -> io::Result<FileAttr> {
|