Stream: general

Topic: Unable to create wasm component with wasm-tools


view this post on Zulip Ari Seyhun (May 15 2023 at 09:47):

I'm trying to create a wasm component from a compiled Rust crate which uses wit-bindgen to export functions.
Though when attempting to create the component, I get the following error:

wasm-tools component new --adapt ./wasi_preview1_component_adapter.wasm -o ./counter.component.new ./target/wasm32-wasi/release/counter.wasm
Error: failed to encode a component from module

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

The wasi_preview1_component_adapter.wasm was compiled from <https://github.com/bytecodealliance/preview2-prototyping/tree/main/crates/wasi-preview1-component-adapter>, and everything is using wasmtime git dependencies (including wasm-tools).

Is this my fault, or is there some new changes in the main branches which are causing this?

Polyfill adapter for preview1-using wasm modules to call preview2 functions. - preview2-prototyping/crates/wasi-preview1-component-adapter at main · bytecodealliance/preview2-prototyping

view this post on Zulip Ari Seyhun (May 15 2023 at 09:58):

This PR seems to be relevant: <https://github.com/bytecodealliance/preview2-prototyping/pull/172>

In preparation for upstreaming (see bytecodealliance/wasmtime#6370) the adapter, I have placed it, and its dependencies, under crates/wasi-preview1-component-adapter. The goal is to make it straigh...

view this post on Zulip Daniel Macovei (May 15 2023 at 13:57):

In the past I've been able to resolve my issues by grabbing wasi_preview1_component_adapter.command.wasm from the releases page here https://github.com/bytecodealliance/preview2-prototyping/releases/tag/latest and renaming it to wasi_preview1_component_adapter.wasm

Commits 5be99d6: fix automatic release (Pat Hickey)

view this post on Zulip Alex Crichton (May 15 2023 at 16:14):

Your --adapt argument is inferring the name wasi_preview1_component_adapter as the module to adapt, when in fact it should be wasi_snapshot_preview1. You'll need to pass --adapt foo=bar.wasmif you don't want to change the filename where foo is wasi_snapshot_preview1


Last updated: Nov 22 2024 at 16:03 UTC