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

Describe workflow for testing preview2 components #7292

Merged
merged 2 commits into from
Oct 25, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/contributing-implementing-wasm-proposals.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,12 @@ default in Wasmtime, and can be used as a review checklist.

[phases]: https://github.com/WebAssembly/meetings/blob/master/process/phases.md
[WABT]: https://github.com/WebAssembly/wabt/

## Adding component functionality to WASI
The [cap-std](https://github.com/bytecodealliance/cap-std) repository contains crates which implement the capability-based version of the Rust standard library and extensions to that functionality. Once the functionality has been added to the relevant crates of that repository, they can be added into wasmtime by including them in the preview2 directory of the [wasi crate](https://github.com/bytecodealliance/wasmtime/tree/main/crates/wasi).
Currently, WebAssembly modules which rely on preview2 ABI cannot be directly executed by the wasmtime command. The following steps allow for testing such changes.
1. Build wasmtime with the changes `cargo build --release`
2. Create a simple Webassembly module to test the new component functionality by compiling your test code to the `wasm32-wasi` build target.
3. Build the [wasi-preview1-component-adapter](https://github.com/bytecodealliance/wasmtime/tree/main/crates/wasi-preview1-component-adapter) as a command adapter. `cargo build -p wasi-preview1-component-adapter --target wasm32-wasi --release --features command --no-default-features`
4. Use [wasm-tools](https://github.com/bytecodealliance/wasm-tools) to convert the test module to a component. `wasm-tools component new --adapt wasi_snapshot_preview1=wasi_snapshot_preview1.command.wasm -o component.wasm path/to/test/module`
5. Run the test component created in the previous step with the locally built wasmtime. `wasmtime -W component-model=y -S preview2=y component.wasm`