Skip to content

Support WASI Preview 2 聽#242

Closed
Closed

Description

@nuke-web3

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? 馃榿

Activity

  1. nuke-web3 commented on Feb 27, 2024

    @nuke-web3
    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 馃

  2. changed the title [-]Support Preview 2 for WASI[/-] [+]Support WASI Preview 2 [/+] on Feb 27, 2024
  3. jeffparsons commented on Feb 28, 2024

    @jeffparsons
    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.

  4. peterhuene commented on Feb 28, 2024

    @peterhuene
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions