Skip to content

Commit cb1ffab

Browse files
authored
Fix compilation under wasm32-wasi under various feature combinations. (#960)
1 parent 90513bc commit cb1ffab

3 files changed

Lines changed: 9 additions & 11 deletions

File tree

src/maybe_polyfill/no_std/os/fd/owned.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,11 @@ impl OwnedFd {
112112
Ok(fd.into())
113113
}
114114

115+
/// Creates a new `OwnedFd` instance that shares the same underlying file handle
116+
/// as the existing `OwnedFd` instance.
115117
#[cfg(target_arch = "wasm32")]
116118
pub fn try_clone(&self) -> crate::io::Result<Self> {
117-
Err(crate::io::const_io_error!(
118-
crate::io::ErrorKind::Unsupported,
119-
"operation not supported on WASI yet",
120-
))
119+
Err(crate::io::Errno::NOSYS)
121120
}
122121
}
123122

@@ -150,10 +149,7 @@ impl BorrowedFd<'_> {
150149
#[cfg(any(target_arch = "wasm32", target_os = "hermit"))]
151150
#[cfg_attr(staged_api, stable(feature = "io_safety", since = "1.63.0"))]
152151
pub fn try_clone_to_owned(&self) -> crate::io::Result<OwnedFd> {
153-
Err(crate::io::const_io_error!(
154-
crate::io::ErrorKind::Unsupported,
155-
"operation not supported on WASI yet",
156-
))
152+
Err(crate::io::Errno::NOSYS)
157153
}
158154
}
159155

src/param/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
//! between different processes on the same system.
77
88
mod auxv;
9-
#[cfg(feature = "use-explicitly-provided-auxv")]
9+
#[cfg(all(feature = "use-explicitly-provided-auxv", not(libc)))]
1010
mod init;
1111

1212
pub use auxv::*;
13-
#[cfg(feature = "use-explicitly-provided-auxv")]
13+
#[cfg(all(feature = "use-explicitly-provided-auxv", not(libc)))]
1414
pub use init::init;

src/path/arg.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1063,10 +1063,12 @@ where
10631063

10641064
#[cfg(not(feature = "alloc"))]
10651065
{
1066-
#[cfg(libc)]
1066+
#[cfg(all(libc, not(target_os = "wasi")))]
10671067
const LARGE_PATH_BUFFER_SIZE: usize = libc::PATH_MAX as usize;
10681068
#[cfg(linux_raw)]
10691069
const LARGE_PATH_BUFFER_SIZE: usize = linux_raw_sys::general::PATH_MAX as usize;
1070+
#[cfg(target_os = "wasi")]
1071+
const LARGE_PATH_BUFFER_SIZE: usize = 4096 as usize; // TODO: upstream this
10701072

10711073
// Taken from
10721074
// <https://github.com/rust-lang/rust/blob/a00f8ba7fcac1b27341679c51bf5a3271fa82df3/library/std/src/sys/common/small_c_string.rs>

0 commit comments

Comments
 (0)