You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the Rust compiler supports a preview2 version of the WASI target,
support in cargo component for adapting a preview1 module will be removed.
WebAssembly/WASI#577 IIUC now WASI has launched support for preview 2 馃帀 - is there some plan/timeline for cargo component to update to use it? Anything some eager new contributors might be able to help with? 馃榿
I see rust-lang/rust#119616 is landing at this moment to have wasm32-wasi-preview2 as a target 馃槄 - enabling cargo contract to use it in nightly very soon I would think 馃
That PR has merged now, but IIRC it's still mostly just boilerplate, and there's more work before it can be meaningfully used as a way to target WASIp2. E.g. actually creating a Wasm Component from the resulting binary.
Thanks for the issue! cargo-component already supports WASI 0.2.0 (a.k.a. "preview2").
cargo-component supports it in a few ways:
If you use Rust's stdlib, the Rust toolchain will emit a preview1 compatible module; cargo-component automatically adapts the preview1 interface into a preview2 interface when creating the component.
You may use the wasi crate to directly interact with WASI preview2; this crate wraps generated bindings, giving a more consistent API.
You may target the WASI 0.2.0 WIT packages directly from your component and cargo-component will generate bindings for you to call WASI imports.
When the Rust toolchain supports WASI 0.2.0, it will simplify the first item above by no longer having to adapt the module from preview1.
Activity
nuke-web3 commentedon Feb 27, 2024
I see rust-lang/rust#119616 is landing at this moment to have
wasm32-wasi-preview2as a target 馃槄 - enabling cargo contract to use it in nightly very soon I would think 馃[-]Support Preview 2 for WASI[/-][+]Support WASI Preview 2 [/+]jeffparsons commentedon Feb 28, 2024
That PR has merged now, but IIRC it's still mostly just boilerplate, and there's more work before it can be meaningfully used as a way to target WASIp2. E.g. actually creating a Wasm Component from the resulting binary.
peterhuene commentedon Feb 28, 2024
Hi @nukemandan.
Thanks for the issue!
cargo-componentalready supports WASI 0.2.0 (a.k.a. "preview2").cargo-componentsupports it in a few ways:If you use Rust's stdlib, the Rust toolchain will emit a preview1 compatible module;
cargo-componentautomatically adapts the preview1 interface into a preview2 interface when creating the component.You may use the
wasicrate to directly interact with WASI preview2; this crate wraps generated bindings, giving a more consistent API.You may target the WASI 0.2.0 WIT packages directly from your component and
cargo-componentwill generate bindings for you to call WASI imports.When the Rust toolchain supports WASI 0.2.0, it will simplify the first item above by no longer having to adapt the module from preview1.