@@ -83,6 +83,51 @@ Hello, world!
83
83
84
84
[ Wasmtime ] : https://github.com/bytecodealliance/wasmtime
85
85
86
+ # WASIp2 vs WASIp1
87
+
88
+ In January 2024 the WASI subgroup published WASI 0.2.0, colloquially known as
89
+ "WASIp2". Around the same time the subgroup additionally decided to name the
90
+ previous iteration of WASI as "WASIp1", historically known as "WASI preview1".
91
+ This now-historical snapshot of WASI was defined with an entirely different set
92
+ of primitives and worked very differently. This crate now targets WASIp2 and no
93
+ longer targets WASIp1.
94
+
95
+ ## Support for WASIp1
96
+
97
+ The last version of the ` wasi ` crate to support WASIp1 was the
98
+ [ 0.11.0+wasi-snapshot-preview1
99
+ version] ( https://crates.io/crates/wasi/0.11.0+wasi-snapshot-preview1 ) . This
100
+ version of the crate supported all WASIp1 APIs. WASIp1 was historically defined
101
+ with ` *.witx ` files and used a bindings generator called ` witx-bindgen ` .
102
+
103
+ ## Should I use WASIp1 or WASIp2?
104
+
105
+ This is a bit of a nuanced question/answer but the short answer is to probably
106
+ use the 0.11.0 release of ` wasi ` for now if you're unsure.
107
+
108
+ The longer-form answer of this is that it depends on the Rust targets that you
109
+ want to support. Rust WebAssembly targets include:
110
+
111
+ * ` wasm32-unknown-unknown ` - do not use this crate because this target indicates
112
+ that WASI is not desired.
113
+ * ` wasm32-wasi ` or ` wasm32-wasip1 ` - this target has been present in Rust for
114
+ quite some time and is recently being renamed from ` wasm32-wasi ` to
115
+ ` wasm32-wasip1 ` . The two targets have the same definition, it's just the name
116
+ that's changing. For this target you probably want the 0.11.0 track of this
117
+ crate.
118
+ * ` wasm32-wasip2 ` - this target is a recent addition to rustc (as of the time of
119
+ this writing it's not merged yet into rustc). This is what the 0.12.0 version
120
+ of the crate is intended for.
121
+
122
+ Note that if you use ` wasm32-wasi ` or ` wasm32-wasip1 ` it's not necessarily
123
+ guaranteed you want 0.11.0 of this crate. If your users are producing components
124
+ then you probably want 0.12.0 instead. If you don't know what your users are
125
+ producing then you should probably stick with 0.11.0.
126
+
127
+ Long story short, it's a bit complicated. We're in a transition period from
128
+ WASIp1 to WASIp2 and things aren't going to be perfect every step of the way, so
129
+ understanding is appreciated!
130
+
86
131
# Development
87
132
88
133
The bulk of the ` wasi ` crate is generated by the [ ` wit-bindgen ` ] tool. The
0 commit comments