kvcache opened issue #10215:
I'm attempting to compile guest functions using
wasm32-unknown-unknown
, but I'd like to use the Component model. Trying to parse a guest function as a Component does not work withoutwasm32-wasip2
.I don't want to use
wasm32-wasip2
because I need to define all of my host interfaces.Client:
wit_bindgen::generate!({ world: "function", }); struct Function; impl exports::momento::functions::function_invoke_post::Guest for Function { fn post(payload: Vec::<u8>,) -> Vec::<u8> { todo!() } } export!(Function);
Host fails when parsing wasm byte array:
let component = wasmtime::component::Component::new(&engine, wasm_bytes).map_err(|e| FunctionError::InvalidWasm(e))?;
When I compile with
wasm32-unknown-unknown
, it says"attempted to parse a wasm module with a component parser"
.When I compile with
wasm32-wasip2
, it fails on WASI interfaces I'm not adding to the linker.
pchickey commented on issue #10215:
When compiling with
wasm32-unknown-unknown
rustc emits a WebAssembly Module. You can convert that to a WebAssembly Component with thewasm-tools component new
command line tool, or using https://docs.rs/wit-component/latest/wit_component/struct.ComponentEncoder.html directly.
pchickey edited a comment on issue #10215:
When compiling with
wasm32-unknown-unknown
rustc emits a WebAssembly Module. You can convert that to a WebAssembly Component with thewasm-tools component new
command line tool, or using https://docs.rs/wit-component/latest/wit_component/struct.ComponentEncoder.html directly.The
wasm32-wasip2
target passes the module emitted by rustc towasm-component-ld
which wraps up the conversion performed above, plus some details to adapt wasip1 interfaces to wasip2, which you don't care about.
pchickey edited a comment on issue #10215:
When compiling with
wasm32-unknown-unknown
rustc emits a WebAssembly Module. You can convert that to a WebAssembly Component with thewasm-tools component new
command line tool, or using https://docs.rs/wit-component/latest/wit_component/struct.ComponentEncoder.html directly.The
wasm32-wasip2
target passes the Module emitted by rustc towasm-component-ld
which wraps up the Component conversion performed above, plus some details to adapt wasip1 interfaces to wasip2, which you don't care about.
kvcache closed issue #10215:
I'm attempting to compile guest functions using
wasm32-unknown-unknown
, but I'd like to use the Component model. Trying to parse a guest function as a Component does not work withoutwasm32-wasip2
.I don't want to use
wasm32-wasip2
because I need to define all of my host interfaces.Client:
wit_bindgen::generate!({ world: "function", }); struct Function; impl exports::momento::functions::function_invoke_post::Guest for Function { fn post(payload: Vec::<u8>,) -> Vec::<u8> { todo!() } } export!(Function);
Host fails when parsing wasm byte array:
let component = wasmtime::component::Component::new(&engine, wasm_bytes).map_err(|e| FunctionError::InvalidWasm(e))?;
When I compile with
wasm32-unknown-unknown
, it says"attempted to parse a wasm module with a component parser"
.When I compile with
wasm32-wasip2
, it fails on WASI interfaces I'm not adding to the linker.
kvcache commented on issue #10215:
@pchickey Thank you, this is what I needed! I now see an example does this too.
Last updated: Feb 28 2025 at 01:30 UTC