Skip to content

Commit

Permalink
Implement WASI "preview0" in wasmtime-wasi
Browse files Browse the repository at this point in the history
This commit implements the `wasi_unstable` module, sometimes referred to
as "preview0", in the `wasmtime-wasi` crate. Previously this was only
implemented by the `wasi-common` crate but now this is implemented for
both meaning that the switch to preview2 won't lose this functionality.

The preview0 WITX files are vendored like the preview1 files and the
implementation of preview0 is exclusively implemented by delegating to
the preview1 implementation.
  • Loading branch information
alexcrichton committed Nov 15, 2023
1 parent bba4ee7 commit 45f9f9c
Show file tree
Hide file tree
Showing 12 changed files with 2,212 additions and 40 deletions.
3 changes: 2 additions & 1 deletion crates/cli-flags/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ wasmtime_option_group! {
pub inherit_network: Option<bool>,
/// Indicates whether `wasi:sockets/ip-name-lookup` is enabled or not.
pub allow_ip_name_lookup: Option<bool>,

/// Allows imports from the `wasi_unstable` core wasm module.
pub preview0: Option<bool>,
}

enum Wasi {
Expand Down
20 changes: 20 additions & 0 deletions crates/wasi/foo.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--- witx/preview0/typenames.witx 2023-11-15 13:25:21
+++ witx/preview1/typenames.witx 2023-10-19 15:44:01
@@ -270,6 +270,8 @@
$poll_fd_readwrite
;;; The right to invoke `sock_shutdown`.
$sock_shutdown
+ ;;; The right to invoke `sock_accept`.
+ $sock_accept
)
)

@@ -545,8 +549,6 @@
;;; The contents of a `subscription` when type is `eventtype::clock`.
(typename $subscription_clock
(record
- ;;; The user-defined unique identifier of the clock.
- (field $identifier $userdata)
;;; The clock against which to compare the timestamp.
(field $id $clockid)
;;; The absolute or relative timestamp.
2 changes: 2 additions & 0 deletions crates/wasi/src/preview2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ mod network;
pub mod pipe;
mod poll;
#[cfg(feature = "preview1-on-preview2")]
pub mod preview0;
#[cfg(feature = "preview1-on-preview2")]
pub mod preview1;
mod random;
mod stdio;
Expand Down
Loading

0 comments on commit 45f9f9c

Please sign in to comment.