Skip to content
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

Support WASI Preview 2 #242

Closed
nuke-web3 opened this issue Feb 27, 2024 · 3 comments
Closed

Support WASI Preview 2 #242

nuke-web3 opened this issue Feb 27, 2024 · 3 comments

Comments

@nuke-web3
Copy link

In the README:

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? 😁

@nuke-web3
Copy link
Author

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 🤞

@nuke-web3 nuke-web3 changed the title Support Preview 2 for WASI Support WASI Preview 2 Feb 27, 2024
@jeffparsons
Copy link
Contributor

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
Copy link
Member

Hi @nukemandan.

Thanks for the issue! cargo-component already supports WASI 0.2.0 (a.k.a. "preview2").

cargo-component supports it in a few ways:

  1. 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.

  2. You may use the wasi crate to directly interact with WASI preview2; this crate wraps generated bindings, giving a more consistent API.

  3. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants