wasi-sdk
wasi-sdk copied to clipboard
lto link error undefined symbol: setjmp
I try build with --target=wasm32-wasi -mllvm -wasm-enable-sjlj and -flto=full
get this error:
undefined symbol: setjmp
undefined symbol: longjmp
nm test.o |grep jmp
U longjmp
U setjmp
If I remove -flto=full, all work as expect:
nm test.o |grep jmp
U __c_longjmp
U __wasm_longjmp
U saveSetjmp
U testSetjmp
i guess you need -Wl,-llvm,-wasm-enable-sjlj.
my link step not call from clang, so I add -mllvm -wasm-enable-sjlj into wasm-ld. this will work like -Wl,-llvm,-wasm-enable-sjlj ?
I get this error when link:
wasm-ld: error: /wasi/share/wasi-sysroot/lib/wasm32-wasi/llvm-lto/18.1.2-wasi-sdk/libsetjmp.a(rt.o): attempt to add bitcode file after LTO (__wasm_longjmp)
Error: wasm-ld failed with status: 1
The options for a quick fix would be to either (1) remove -flto from you link command or (2) add -Wl,-u__wasm_longjmp (which would force that symbol to be included prior to LTO).
after add -Wl,-u__wasm_longjmp, the problem fixed.
any suggestion how to run the binary with -wasm-enable-sjl? I try wasm-interp and wasmer, not work.
my link step not call from clang, so I add
-mllvm -wasm-enable-sjljinto wasm-ld. this will work like-Wl,-llvm,-wasm-enable-sjlj?I get this error when link:
wasm-ld: error: /wasi/share/wasi-sysroot/lib/wasm32-wasi/llvm-lto/18.1.2-wasi-sdk/libsetjmp.a(rt.o): attempt to add bitcode file after LTO (__wasm_longjmp) Error: wasm-ld failed with status: 1
this looks like a bug. a fix: https://github.com/WebAssembly/wasi-libc/pull/529 for now, you can stop using lto as a workaround.
after add
-Wl,-u__wasm_longjmp, the problem fixed.any suggestion how to run the binary with
-wasm-enable-sjl? I trywasm-interpand wasmer, not work.
you can't run it.
-
the setjmp runtime provided by wasi-sdk is not compatible with llvm 18. you need to use llvm 19 (an unreleased version) to build a working app.
-
you need to use a runtime with exception-handling proposal. eg. toywasm, wamr classic interpreter.
thanks for explain.
Is there a link I can download llvm19 sdk ? (like nightly build results)
after llvm 19 release, can I run the wasm binary in browser ?
thanks for explain.
Is there a link I can download llvm19 sdk ? (like nightly build results)
after
llvm 19release, can I run the wasm binary in browser ?
if you are more interested in browsers, i guess it's better to try emscripten. (i'm not familiar with it.)
Yes, emscripten has supported setjmp/longjmp for many years out-of-the-box.