-
Notifications
You must be signed in to change notification settings - Fork 300
Blog post: Changes to Rust's WASI targets #1302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e22aec2
Create 2024-04-10-updates-to-rusts-wasi-targets.md
yoshuawuyts f203865
Update posts/2024-04-10-updates-to-rusts-wasi-targets.md
yoshuawuyts 5f13d05
Address feedback from review
yoshuawuyts f2baed3
unbury the lead
yoshuawuyts 861355e
Change WASI post date to 2024-04-09
yoshuawuyts File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
--- | ||
layout: post | ||
title: Changes to Rust's WASI targets | ||
author: Yosh Wuyts | ||
--- | ||
|
||
[WASI 0.2 was recently | ||
stabilized](https://bytecodealliance.org/articles/WASI-0.2), and Rust has begun | ||
implementing first-class support for it in the form of a dedicated new target. | ||
In this post we'll discuss the introduction of the new target, what that means | ||
for the older targets, and the schedule by which we plan to roll out these | ||
changes. | ||
|
||
## Introducing `wasm32-wasip2` | ||
|
||
After nearly five years of work the [WASI 0.2 specification](https://wasi.dev) | ||
was recently stabilized. This work builds on [WebAssembly | ||
Components](https://component-model.bytecodealliance.org) (think: strongly-typed | ||
ABI for Wasm), providing standard interfaces for things like asynchronous IO, | ||
networking, and HTTP. This will finally make it possible to write asynchronous | ||
networked services on top of WASI, something which wasn't possible using WASI | ||
0.1. | ||
|
||
People interested in compiling Rust code to WASI 0.2 today are able to do so | ||
using the [cargo-component](https://github.com/bytecodealliance/cargo-component) | ||
tool. This tool is able to take WASI 0.1 binaries, and transform them to WASI 0.2 | ||
Components using a shim. It also provides native support for common cargo | ||
commands such as `cargo build`, `cargo test`, and `cargo run`. While it | ||
introduces some inefficiencies because of the additional translation layer, in | ||
practice this already works really well and people should be enough able to get | ||
started with WASI 0.2 development. | ||
|
||
We're however keen to begin making that translation layer obsolete. And for | ||
that reason we're happy to share that Rust has made its first steps towards | ||
that with the introduction of the [tier | ||
3](https://doc.rust-lang.org/rustc/platform-support.html#tier-3) `wasm32-wasip2` | ||
target landing in Rust 1.78. **This will initially miss a lot of expected** | ||
**features such as stdlib support, and we don't recommend people use this target** | ||
**quite yet.** But as we fill in those missing features over the coming months, we | ||
aim to eventually hit meet the criteria to become a tier 2 target, at which | ||
point the `wasm32-wasip2` target would be considered ready for general use. This | ||
work will happen through 2024, and we expect for this to land before the end of | ||
the calendar year. | ||
|
||
## Renaming `wasm32-wasi` to `wasm32-wasip1` | ||
|
||
The original name for what we now call WASI 0.1 was "WebAssembly System | ||
Interface, snapshot 1". Rust shipped support for this in 2019, and we did so | ||
knowing the target would likely undergo significant changes in the future. With | ||
the knowledge we have today though, we would not have chosen to introduce the | ||
"WASI, snapshot 1" target as `wasm32-wasi`. We should have instead chosen to add | ||
some suffix to the initial target triple so that the eventual stable WASI 1.0 | ||
target can just be called `wasm32-wasi`. | ||
|
||
In anticipation of both an eventual WASI 1.0 target, and to preserve consistency | ||
between target names, we'll begin rolling out a name change to the existing WASI | ||
0.1 target. Starting in Rust 1.78 (May 2nd, 2024) a new `wasm32-wasip1` target | ||
will become available. Starting Rust 1.81 we will begin warning existing users | ||
of `wasm32-wasi` to migrate to `wasm32-wasip1`. And finally in Rust 1.84 | ||
(January 9th, 2025) the `wasm32-wasi` target will no longer be shipped on the stable | ||
release channel. This will provide an 8 month transition period for projects to | ||
switch to the new target name when they update their Rust toolchains. | ||
|
||
The name `wasip1` can be read as either "WASI (zero) point one" or "WASI preview | ||
one". The official specification uses the "preview" moniker, however in most | ||
communication the form "WASI 0.1" is now preferred. This target triple was | ||
chosen because it not only maps to both terms, but also more closely resembles | ||
the target terminology used in [other programming | ||
languages](https://go.dev/blog/wasi). This is something the WASI Preview 2 | ||
specification [also makes note | ||
of](https://github.com/WebAssembly/WASI/tree/f45e72e5294e990c23d548eea32fd35c80525fd6/preview2#introduction). | ||
|
||
## Timeline | ||
|
||
This table provides the dates and cut-offs for the target rename from | ||
`wasm32-wasi` to `wasm32-wasip1`. The dates in this table do not apply to the | ||
newly-introduced `wasm32-wasi-preview1-threads` target; this will be renamed to | ||
`wasm32-wasip1-threads` in Rust 1.78 without going through a transition period. | ||
The tier 3 `wasm32-wasip2` target will also be made available in Rust 1.78. | ||
|
||
| date | Rust Stable | Rust Beta | Rust Nightly | Notes | | ||
| ---------- | ----------- | --------- | ------------ | ---------------------------------------- | | ||
| 2024-02-08 | 1.76 | 1.77 | 1.78 | `wasm32-wasip1` available on nightly | | ||
| 2024-03-21 | 1.77 | 1.78 | 1.79 | `wasm32-wasip1` available on beta | | ||
| 2024-05-02 | 1.78 | 1.79 | 1.80 | `wasm32-wasip1` available on stable | | ||
| 2024-06-13 | 1.79 | 1.80 | 1.81 | warn if `wasm32-wasi` is used on nightly | | ||
| 2024-07-25 | 1.80 | 1.81 | 1.82 | warn if `wasm32-wasi` is used on beta | | ||
| 2024-09-05 | 1.81 | 1.82 | 1.83 | warn if `wasm32-wasi` is used on stable | | ||
| 2024-10-17 | 1.82 | 1.83 | 1.84 | `wasm32-wasi` unavailable on nightly | | ||
| 2024-11-28 | 1.83 | 1.84 | 1.85 | `wasm32-wasi` unavailable on beta | | ||
| 2025-01-09 | 1.84 | 1.85 | 1.86 | `wasm32-wasi` unavailable on stable | | ||
|
||
## Conclusion | ||
|
||
In this post we've discussed the upcoming updates to Rust's WASI targets. Come | ||
Rust 1.78 the `wasm32-wasip1` (tier 2) and `wasm32-wasip2` (tier 3) targets will | ||
be added. In Rust 1.81 we will begin warning if `wasm32-wasi` is being used. And in Rust 1.84, the existing `wasm32-wasi` target will be removed. | ||
yoshuawuyts marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Users will have 8 months to switch to the new target name when they update their | ||
Rust toolchains. | ||
|
||
The `wasm32-wasip2` target marks the start of native support for WASI 0.2. In | ||
order to target it today from Rust, people are encouraged to use | ||
[cargo-component](https://github.com/bytecodealliance/cargo-component) tool | ||
instead. The plan is to eventually graduate `wasm32-wasip2` to a tier-2 target, | ||
at which point `cargo-component` will be upgraded to support it natively instead. | ||
|
||
With WASI 0.2 finally stable, it's an exciting time for WebAssembly development. | ||
We're happy for Rust to begin implementing native support for WASI 0.2, and | ||
we're excited for what this will enable people to build. |
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.
Uh oh!
There was an error while loading. Please reload this page.