Stream: general

Topic: wasmtime run imports


view this post on Zulip Itay Shakury (Mar 06 2020 at 07:11):

Hello, I'm getting started with wasmtime, and want to experiment with a wasm module that I have that requires some imports. Is there a way to specify these via the wasmtime run cli?

view this post on Zulip Alex Crichton (Mar 06 2020 at 16:21):

@Itay Shakury currently the cli can only implement wasi imports, for other cases you'll need to dive into the api

view this post on Zulip Till Schneidereit (Mar 06 2020 at 16:23):

@Itay Shakury can you describe your use case a bit? We want to make sure that any future support for this addresses real-world use cases, so that'd be really helpful!

view this post on Zulip Itay Shakury (Mar 06 2020 at 19:09):

@Till Schneidereit I have a wasm module which have some imports: memory, functions that I wanted to test our quickly. I'm aware this is a conceptual challenge - how to implement the imports. I just thought I'd check if by any chance there's a solution which I haven't considered.

view this post on Zulip Yury Delendik (Mar 06 2020 at 19:15):

@Itay Shakury wasmtime cli supports wasi related imports at this moment. Is embedding wasmtime something you considered? e.g. https://github.com/bytecodealliance/wasmtime/blob/master/docs/embed-rust.md

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

view this post on Zulip Itay Shakury (Mar 06 2020 at 19:18):

@Yury Delendik currently I'm just playing around so I started with the cli as that was quickest. after realizing I need imports I looking at embedding (in C), however the wasmtime docs were very poor for this matter so I'm now POCing wasmer.io

Wasmer - The Universal WebAssembly Runtime

view this post on Zulip Yury Delendik (Mar 06 2020 at 19:27):

@Itay Shakury are you looking at embedding in C? wasmtime provides that via wasm-c-api -- it is not as convenient as rust's but shall provided functionality you need

view this post on Zulip Yury Delendik (Mar 06 2020 at 19:28):

examples for wasm-c-api can be found at https://github.com/WebAssembly/wasm-c-api/tree/master/example

Wasm C API prototype. Contribute to WebAssembly/wasm-c-api development by creating an account on GitHub.

view this post on Zulip Itay Shakury (Mar 06 2020 at 19:36):

thanks, I saw that but didn't know where to start, and the lack of explanations was concerning. the wasmer docs were more compelling so I started there. after I grasp wasmer I'll try to look at wasmtime again.

view this post on Zulip René Fonseca (Mar 07 2020 at 16:15):

@Itay Shakury it is possible to bind different WASM modules together with the current wasmtime API (similar to how Windows DLLs work). I just hooked it up for my wasmtime wrapper. So it is easy to hook up testing a WASM module using other WASM modules - but writing WAT manually is not nice for more complicated tests. When API is by-value only it is simple - only handling of different memory segments needs special attention.


Last updated: Nov 22 2024 at 16:03 UTC