Stream: wasmtime

Topic: link host function to module via "env"


view this post on Zulip Steve Manuel (Mar 26 2020 at 18:37):

hello! @zach and I are working on a host environment and have run into an issue now that we're attempting to execute wasm code compiled from other languages.

when executing a Rust module:

Caused by:
    Link error: env/list_sites: unknown import function: function not provided', src/bin/host-wasm.rs:7:16

We also observe similar behavior when executing wasm code compiled from C. It seems like we can't define the host functions (in Rust) on the "env" name. We are using the Module::new_with_name fn, but possibly incorrectly? ex:

let module = Module::new_with_name(&store, wasm.as_ref(), "env")?;

Any tips would be much appreciated!

view this post on Zulip Yury Delendik (Mar 26 2020 at 18:46):

The imports for the instance needs to be resolved as documented in https://github.com/bytecodealliance/wasmtime/blob/master/docs/embed-rust.md#importing-host-functionality , means exports names needs to be resolved. A week ago the Linker helper was add, check https://github.com/bytecodealliance/wasmtime/blob/master/crates/api/src/linker.rs#L218

Standalone JIT-style runtime for WebAssembly, using Cranelift - bytecodealliance/wasmtime
Standalone JIT-style runtime for WebAssembly, using Cranelift - bytecodealliance/wasmtime

view this post on Zulip Steve Manuel (Mar 26 2020 at 19:22):

@Yury Delendik - that definitely helped, now bumping into some other issues :) Appreciate your quick reply!!


Last updated: Oct 23 2024 at 20:03 UTC