From c2d5c641325fe0859bf991928bbc85089fbe39e0 Mon Sep 17 00:00:00 2001 From: Marcus Calhoun-Lopez <marcuscalhounlopez@gmail.com> Date: Sun, 27 Mar 2022 11:18:01 -0700 Subject: [PATCH 1/2] Fix build on i686-apple-darwin systems Replace `target_arch = "x86_64"` with `not(target_arch = "aarch64")` so that i686-apple-darwin systems dynamically choose implementation. --- library/std/src/sys/unix/fs.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/library/std/src/sys/unix/fs.rs b/library/std/src/sys/unix/fs.rs index b93a3d67771..6a0088a8940 100644 --- a/library/std/src/sys/unix/fs.rs +++ b/library/std/src/sys/unix/fs.rs @@ -1535,12 +1535,12 @@ mod remove_dir_impl { use crate::sync::Arc; use crate::sys::{cvt, cvt_r}; - #[cfg(not(all(target_os = "macos", target_arch = "x86_64"),))] + #[cfg(not(all(target_os = "macos", not(target_arch = "aarch64")),))] use libc::{fdopendir, openat, unlinkat}; - #[cfg(all(target_os = "macos", target_arch = "x86_64"))] + #[cfg(all(target_os = "macos", not(target_arch = "aarch64")))] use macos_weak::{fdopendir, openat, unlinkat}; - #[cfg(all(target_os = "macos", target_arch = "x86_64"))] + #[cfg(all(target_os = "macos", not(target_arch = "aarch64")))] mod macos_weak { use crate::sys::weak::weak; use libc::{c_char, c_int, DIR}; @@ -1699,12 +1699,12 @@ mod remove_dir_impl { } } - #[cfg(not(all(target_os = "macos", target_arch = "x86_64")))] + #[cfg(not(all(target_os = "macos", not(target_arch = "aarch64"))))] pub fn remove_dir_all(p: &Path) -> io::Result<()> { remove_dir_all_modern(p) } - #[cfg(all(target_os = "macos", target_arch = "x86_64"))] + #[cfg(all(target_os = "macos", not(target_arch = "aarch64")))] pub fn remove_dir_all(p: &Path) -> io::Result<()> { if macos_weak::has_openat() { // openat() is available with macOS 10.10+, just like unlinkat() and fdopendir() From 8c188443249ed3b6b0a034800af367b9b43cc190 Mon Sep 17 00:00:00 2001 From: Marcus Calhoun-Lopez <marcuscalhounlopez@gmail.com> Date: Mon, 28 Mar 2022 12:44:19 -0700 Subject: [PATCH 2/2] Fix build on i686-apple-darwin systems On 32-bit systems, fdopendir is called `_fdopendir$INODE64$UNIX2003`. On 64-bit systems, fdopendir is called `_fdopendir$INODE64`. --- library/std/src/sys/unix/fs.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/library/std/src/sys/unix/fs.rs b/library/std/src/sys/unix/fs.rs index 6a0088a8940..7181451de57 100644 --- a/library/std/src/sys/unix/fs.rs +++ b/library/std/src/sys/unix/fs.rs @@ -1562,6 +1562,9 @@ mod remove_dir_impl { } pub unsafe fn fdopendir(fd: c_int) -> *mut DIR { + #[cfg(all(target_os = "macos", target_arch = "x86"))] + weak!(fn fdopendir(c_int) -> *mut DIR, "fdopendir$INODE64$UNIX2003"); + #[cfg(all(target_os = "macos", target_arch = "x86_64"))] weak!(fn fdopendir(c_int) -> *mut DIR, "fdopendir$INODE64"); fdopendir.get().map(|fdopendir| fdopendir(fd)).unwrap_or_else(|| { crate::sys::unix::os::set_errno(libc::ENOSYS);