about summary refs log tree commit diff
path: root/library/std/src/sys/unix/process/process_unix.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-07-10 21:42:40 +0000
committerbors <bors@rust-lang.org>2021-07-10 21:42:40 +0000
commitdfd7b8d03fb93d0e03147d28b3be6d93260fa94d (patch)
tree4a4310069f11ed4d0f2fdd3aadaf02fbc67a5fb3 /library/std/src/sys/unix/process/process_unix.rs
parent432e145bd5a974c5b6f4dd9b352891bd7502b69d (diff)
parent5999a5fbdc91ac07d4103095ed532d8cd4d3443b (diff)
downloadrust-dfd7b8d03fb93d0e03147d28b3be6d93260fa94d.tar.gz
rust-dfd7b8d03fb93d0e03147d28b3be6d93260fa94d.zip
Auto merge of #85953 - inquisitivecrystal:weak-linkat-in-fs-hardlink, r=joshtriplett
Fix linker error

Currently, `fs::hard_link` determines whether platforms have `linkat` based on the OS, and uses `link` if they don't. However, this heuristic does not work well if a platform provides `linkat` on newer versions but not on older ones. On old MacOS, this currently causes a linking error.

This commit fixes `fs::hard_link` by telling it to use `weak!` on macOS. This means that, on  that operating system, we now check for `linkat` at runtime and use `link` if it is not available.

Fixes #80804.

`@rustbot` label T-libs-impl
Diffstat (limited to 'library/std/src/sys/unix/process/process_unix.rs')
-rw-r--r--library/std/src/sys/unix/process/process_unix.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/library/std/src/sys/unix/process/process_unix.rs b/library/std/src/sys/unix/process/process_unix.rs
index ed55e1aa715..c888dd0d87d 100644
--- a/library/std/src/sys/unix/process/process_unix.rs
+++ b/library/std/src/sys/unix/process/process_unix.rs
@@ -9,6 +9,14 @@ use crate::sys;
 use crate::sys::cvt;
 use crate::sys::process::process_common::*;
 
+#[cfg(any(
+    target_os = "macos",
+    target_os = "freebsd",
+    all(target_os = "linux", target_env = "gnu"),
+    all(target_os = "linux", target_env = "musl"),
+))]
+use crate::sys::weak::weak;
+
 #[cfg(target_os = "vxworks")]
 use libc::RTP_ID as pid_t;