Stream: wasmtime

Topic: Failure to adapt reactor with component adapter


view this post on Zulip Bailey Hayes (Jun 13 2023 at 00:49):

Are folks able to adapt reactor wasi modules on wasmtime main?

I'm looking to create a reactor go component based on the module produced here: https://github.com/dev-wasm/dev-wasm-go/tree/main/http

I ran into the same issues that others have reported but I haven't seen a root cause and solution for it yet:

Caused by:
    0: module requires an import interface named `wasi_snapshot_preview1`

To eliminate any differences that are go specific, I've tried to breakdown the reactor workflow for rust. Initial sanity check with cargo component new foo --lib works. Then I went through breaking down the steps that cargo component runs through.

# Built a reactor adapter in wasmtime
# note wasm-encoder and wit-bindgen deps are updated to workspace, e.g. { path = "../wasm-tools/crates/wasm-encoder" }
# reactor is the default
cd wasmtime
cargo build -p wasi-preview1-component-adapter --target wasm32-unknown-unknown --release

# validate the adapter
release=target/wasm32-unknown-unknown/release/wasi_preview1_component_adapter.wasm
cargo run -p verify-component-adapter -- $release

export COMPONENT_ADAPTER=`pwd`$release

All good so far. I noticed there isn't a good e2e test for the adapter yet so I converted the cargo-component created lib to use bare wit-bindgen.

cargo component new smoke --lib
# hack backwards to wit-bindgen

Modified Cargo.toml to use local wit-bindgen
wit-bindgen = { path = "../../wit-bindgen/crates/guest-rust"}

Modified lib.rs to use wit-bindgen bindgings and removed cargo-component bindings wrapper.

wit_bindgen::generate!(in "./wit/world.wit");

struct Component;

export_example!(Component);

impl Example for Component {
    /// Say hello!
    fn hello_world() -> String {
        "Hello, World!".to_string()
    }
}
# build then adapt
cargo build --target wasm32-wasi --release
wasm-tools component new -o smoke.component.wasm --adapt "$COMPONENT_ADAPTER" target/wasm32-wasi/release/smoke.wasm

Same error :/

Environment:
I have all tools (cargo-component, wasm-tools, wit-bindgen, wasmtime) set on latest main with the exception of wasm-tools with the resources commit reverted for compatibility with wit-bindgen. All tests in each of the projects passes. I'm falling back to using local paths for all deps so that I can have trace printlns but the original error also occurs with released versions and wasmtime on main.

Simple devcontainer for Golang + WASM development. Contribute to dev-wasm/dev-wasm-go development by creating an account on GitHub.

view this post on Zulip Bailey Hayes (Jun 13 2023 at 00:57):

Simple mistake. Answer here: https://bytecodealliance.zulipchat.com/#narrow/stream/206238-general/topic/Unable.20to.20create.20wasm.20component.20with.20wasm-tools/near/358507133


Last updated: Dec 23 2024 at 13:07 UTC