WebAssembly / wabt

The WebAssembly Binary Toolkit
Apache License 2.0
6.9k stars 702 forks source link

wasm-interp --enable-exceptions error invalid import "env.saveSetjmp" #2455

Open calvin2021y opened 3 months ago

calvin2021y commented 3 months ago

wasm-interp --enable-exceptions test

error initializing module: invalid import "env.saveSetjmp"
SoniEx2 commented 3 months ago

it looks like you're trying to run an emscripten module. wabt is only a wasm engine, not a full wasm runtime, and definitely not an emscripten runtime. however, if you can get a pure-wasi module instead, you can try compiling wabt with wasi support.

calvin2021y commented 3 months ago

I use WASI sdk with --target=wasm32-wasi -mllvm -wasm-enable-sjlj, not emscripten.

SoniEx2 commented 3 months ago

oh, in that case, you may be missing wasi-libc?

calvin2021y commented 3 months ago

do you mean link step or runtime step?

I static link with wasi-libc libc.a

SoniEx2 commented 3 months ago

it's trying to import stuff that's not provided by wasi. check wasm-objdump.

calvin2021y commented 3 months ago

It use setjmp provide by wasi.

is wasm-interp support setjmp?

SoniEx2 commented 3 months ago

wasi doesn't provide setjmp

sbc100 commented 3 months ago

saveSetjmp is the name of a function that LLVM used to call prior to https://github.com/llvm/llvm-project/pull/84137.

Starting with LLVM 19 you should see __wasm_setjmp and __wasm_setjmp_test instead.

Support for these symbols was added to wasi-libc in https://github.com/WebAssembly/wasi-libc/pull/483 which is part of wasi-sdk-22, but it looks like there is no version of wasi-sdk yet that includes LLVM 19, so there is not yet an official version of wasi-sdk that supports sjlj. I think this is because LLVM 19 has not yet actually been released.

Anyway, none of this has anything to do with wabt.. so I think this issue can be closed.