Skip to content

Commit a92e2fc

Browse files
authored
Unrolled build for #149864
Rollup merge of #149864 - alexcrichton:wasi-avoid-linkat, r=joboet std: Don't use `linkat` on the `wasm32-wasi*` targets This commit is a follow-up to #147572 and the issue reported at the end of that PR where the `std::fs::hard_link` function is broken after that PR landed. The true culprit and bug here is fixed in WebAssembly/wasi-libc#690 but until that's released in a wasi-sdk version it should be reasonable, on WASI, to skip the `linkat` function.
2 parents 0208ee0 + 71d7ae2 commit a92e2fc

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

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

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2077,12 +2077,25 @@ pub fn symlink(original: &CStr, link: &CStr) -> io::Result<()> {
20772077

20782078
pub fn link(original: &CStr, link: &CStr) -> io::Result<()> {
20792079
cfg_select! {
2080-
any(target_os = "vxworks", target_os = "redox", target_os = "android", target_os = "espidf", target_os = "horizon", target_os = "vita", target_env = "nto70") => {
2081-
// VxWorks, Redox and ESP-IDF lack `linkat`, so use `link` instead. POSIX leaves
2082-
// it implementation-defined whether `link` follows symlinks, so rely on the
2083-
// `symlink_hard_link` test in library/std/src/fs/tests.rs to check the behavior.
2084-
// Android has `linkat` on newer versions, but we happen to know `link`
2085-
// always has the correct behavior, so it's here as well.
2080+
any(
2081+
// VxWorks, Redox and ESP-IDF lack `linkat`, so use `link` instead.
2082+
// POSIX leaves it implementation-defined whether `link` follows
2083+
// symlinks, so rely on the `symlink_hard_link` test in
2084+
// library/std/src/fs/tests.rs to check the behavior.
2085+
target_os = "vxworks",
2086+
target_os = "redox",
2087+
target_os = "espidf",
2088+
// Android has `linkat` on newer versions, but we happen to know
2089+
// `link` always has the correct behavior, so it's here as well.
2090+
target_os = "android",
2091+
// wasi-sdk-29-and-prior have a buggy `linkat` so use `link` instead
2092+
// until wasi-sdk is updated (see WebAssembly/wasi-libc#690)
2093+
target_os = "wasi",
2094+
// Other misc platforms
2095+
target_os = "horizon",
2096+
target_os = "vita",
2097+
target_env = "nto70",
2098+
) => {
20862099
cvt(unsafe { libc::link(original.as_ptr(), link.as_ptr()) })?;
20872100
}
20882101
_ => {

0 commit comments

Comments
 (0)