Enable the new preview1 implementation by default#7365
Merged
Conversation
Currently Wasmtime has two implementations of the `wasi_snapshot_preview1` set of APIs. The now-historical implementation lives in the `wasi-common` crate and the more recent implementation lives in the `wasmtime-wasi` crate. The main difference is that the `wasmtime-wasi` implementation is based on the implementation of preview2, meaning that the preview1 implementation is a shim in that direction. Additionally currently the preview2 implementation of preview1 is accessible via the `-Spreview2` flag on the CLI. This commit updates the interpretation of the `-Spreview2` flag and the defaults around which implementation to choose. By default the preview1-built-on-preview2 implementation (the new `wasmtime-wasi` implementation) is selected now. This means that the `wasi-common` implementation is disabled by default. There are still two use cases to keep running the `wasi-common` implementation, however: * When running modules that import from `wasi_unstable`, the "snapshot" before `wasi_snapshot_preview1`, currently `wasi-common` is required. The shims to implement `wasi_unstable` have not yet been implemented in the `wasmtime-wasi` crate. * When running with WASI threads (`-Sthreads`) the preview2 implementation does not work. This is because the preview2 implementation expects mutable access to the table which is not granted when threads are enabled. Tests using `wasi_unstable` now pass `-Spreview2=n` to explicitly request the old `wasi-common` implementation. Additionally the `wasi-common` implementation is still selected by default when `-Sthreads` is passed (enabling the WASI threads proposal).
Member
Author
|
I'll also note that I've included a few minor fixes to |
pchickey
approved these changes
Oct 27, 2023
Contributor
pchickey
left a comment
There was a problem hiding this comment.
Thanks. This is an exciting move! If we survive a release of this, I'll start moving the old implementation to be exported by an off-by-default wasmtime_wasi::legacy mod, and move ::preview2 to the root.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently Wasmtime has two implementations of the
wasi_snapshot_preview1set of APIs. The now-historical implementation lives in thewasi-commoncrate and the more recent implementation lives in thewasmtime-wasicrate. The main difference is that thewasmtime-wasiimplementation is based on the implementation of preview2, meaning that the preview1 implementation is a shim in that direction. Additionally currently the preview2 implementation of preview1 is accessible via the-Spreview2flag on the CLI.This commit updates the interpretation of the
-Spreview2flag and the defaults around which implementation to choose. By default the preview1-built-on-preview2 implementation (the newwasmtime-wasiimplementation) is selected now. This means that thewasi-commonimplementation is disabled by default. There are still two use cases to keep running thewasi-commonimplementation, however:When running modules that import from
wasi_unstable, the "snapshot" beforewasi_snapshot_preview1, currentlywasi-commonis required. The shims to implementwasi_unstablehave not yet been implemented in thewasmtime-wasicrate.When running with WASI threads (
-Sthreads) the preview2 implementation does not work. This is because the preview2 implementation expects mutable access to the table which is not granted when threads are enabled.Tests using
wasi_unstablenow pass-Spreview2=nto explicitly request the oldwasi-commonimplementation. Additionally thewasi-commonimplementation is still selected by default when-Sthreadsis passed (enabling the WASI threads proposal).