Hi there, here is a newbie question if you don't mind
I built a simple wasm with exported function which was build with wasm32-wasi target, now I a modified hello example from wasmtime and it works fine.. until I start using vector in my exported function: I receive "wrong number of imports provided, 0 != 1"; the problem disappears when I build wasm with wasm32-unknown-unknown target; wasm compilation works fine in all these cases btw
wasm32-unknown-unknown is silent on panics, wasm32-wasi don't
Vec operations may panic
@Evgeny can you check wasm module and tell which wasi function it requires?
sure if you could tell me how to do that, btw here is a full source:
#[no_mangle]
pub extern "C" fn hello() -> i32 {
let a = vec![322];
1337
}
wasm2wat
cli normally tell
lazy to install -> https://wasdk.github.io/wasmcodeexplorer/
(import "wasi_snapshot_preview1" "fd_write" (func $wasi::lib_generated::wasi_snapshot_preview1::fd_write::h4660e0082b9356a7 (type 10)))
if I got right
yep, "fd_write" probably is used to write panic message to stderr
Can https://github.com/bytecodealliance/wasmtime/blob/9364eb1d98d4b82d30ce72ec1e46ee72a1ea6a0c/examples/wasi/main.rs help with setting this import ?
I'm not sure how to provide this fd_write
wasmtime supports wasi, so yes
the example above does just that
thank you for your help!
wasi.get_export(import.name())
will find "fd_write" if it is present
Last updated: Nov 22 2024 at 17:03 UTC