Skip to content

Commit fd3fed2

Browse files
authored
Enable some rustix features on wasm32-wasip2. (#1271)
* Enable some rustix features on wasm32-wasip2. Enable features that don't depend on `OsStrExt` to be used on wasm32-wasip2 on stable Rust. * Fix missing-abi warnings.
1 parent 472196d commit fd3fed2

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

src/lib.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
// wasip2 conditionally gates stdlib APIs.
1+
// wasip2 conditionally gates stdlib APIs such as `OsStrExt`.
22
// https://github.com/rust-lang/rust/issues/130323
3-
#![cfg_attr(all(target_os = "wasi", target_env = "p2"), feature(wasip2))]
3+
#![cfg_attr(
4+
all(
5+
target_os = "wasi",
6+
target_env = "p2",
7+
any(feature = "fs", feature = "mount", feature = "net")
8+
),
9+
feature(wasip2)
10+
)]
411
//! `rustix` provides efficient memory-safe and [I/O-safe] wrappers to
512
//! POSIX-like, Unix-like, Linux, and Winsock syscall-like APIs, with
613
//! configurable backends.

src/maybe_polyfill/std/mod.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,12 @@ pub mod os {
2121
pub mod fd {
2222
// Change to use `std::os::fd` when MSRV becomes 1.66 or higher.
2323

24+
#[cfg(target_os = "wasi")]
25+
pub use std::os::fd::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd};
2426
#[cfg(unix)]
2527
pub use std::os::unix::io::{
2628
AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd,
2729
};
28-
#[cfg(target_os = "wasi")]
29-
pub use std::os::wasi::io::{
30-
AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd,
31-
};
3230
}
3331

3432
#[cfg(windows)]

src/weak.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const INVALID: *mut c_void = 1 as *mut c_void;
4444
macro_rules! weak {
4545
($vis:vis fn $name:ident($($t:ty),*) -> $ret:ty) => (
4646
#[allow(non_upper_case_globals)]
47-
$vis static $name: $crate::weak::Weak<unsafe extern fn($($t),*) -> $ret> =
47+
$vis static $name: $crate::weak::Weak<unsafe extern "C" fn($($t),*) -> $ret> =
4848
$crate::weak::Weak::new(concat!(stringify!($name), '\0'));
4949
)
5050
}

tests/param/weak.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const INVALID: *mut c_void = 1 as *mut c_void;
4242
macro_rules! weak {
4343
($vis:vis fn $name:ident($($t:ty),*) -> $ret:ty) => (
4444
#[allow(non_upper_case_globals)]
45-
$vis static $name: $crate::weak::Weak<unsafe extern fn($($t),*) -> $ret> =
45+
$vis static $name: $crate::weak::Weak<unsafe extern "C" fn($($t),*) -> $ret> =
4646
$crate::weak::Weak::new(concat!(stringify!($name), '\0'));
4747
)
4848
}

0 commit comments

Comments
 (0)