Hello, I'm trying to build Skia for Wasi, but I'm encountering a build error related to setjmp.
According to https://github.com/WebAssembly/exception-handling/issues/179, it seems that most browsers like Chrome, Firefox, and Safari have completed the implementation of exception handling.
Even though it's in Phase 3, since most browsers have completed the implementation, wouldn't it be okay for wasi-libc to provide support for it?
According to https://github.com/WebAssembly/wasi-libc/pull/483, it seems that the implementation has been done, and just adding -mllvm
, -wasm-enable-sjlj
, -lsetjmp
should allow the build to succeed... But why am I getting errors like error: use of undeclared identifier 'setjmp'
?
Ah! It was added in wasi-sdk version 22. I've been using version 20 like a fool. Sorry about that, haha.
Namse has marked this topic as resolved.
you also need latest (unreleased) llvm.
@YAMAMOTO Takashi Can this feature be added in the next version of wasi-sdk?
when llvm 19 is released and wasi-sdk is updated to include it. probably around this summer i guess.
@YAMAMOTO Takashi If I need to directly implement saveSetjmp and testSetjmp in JavaScript for the current latest wasi-sdk environment to run in a browser, what code should I follow to make it work properly?
i'm not sure what you are trying to do.
if you are using wasi-sdk, you can use the implementation in wasi-libc.
emscripten has its own implementation.
I also don't really understand it well. I'm using the latest version of wasi-sdk 22, and it seems like there is an implementation of setjmp inside wasi-sdk... Nevertheless, even though I linked the setjmp library, the wasm binary I built wants me to import saveSetjmp. I must have done something wrong?
saveSetjmp is old name used by pre llvm 19, including the one included by wasi-sdk-22.
llvm 19 and later will use names like __wasm_setjmp etc, which is what provided by wasi-libc included by wasi-sdk-22.
if you want to use setjmp today, you can install llvm 19 by yourself and use it to build your app, using wasi-sdk-22 sysroot.
Thank you! I built Clang and other tools directly from the latest LLVM git repository, and as a result, WebAssembly no longer requires importing saveSetjmp or testSetjmp.
I thought the saveSetjmp code I implemented was causing the issue, but the problem persists. Strangely, when decoding woff2 fonts using brotli, the ThreadId changes from 2 to 9288807377403942. It works fine on the main thread, but there's always an issue with new threads.
I'll need to investigate further to find out what else might be causing the problem. Thank you!
what ThreadId are you talking about? wasi-threads TID?
anyway, i'm not aware of any threading-related problems with this setjmp/longjmp implementation. (well, unless the app is trying to longjmp to a jmp_buf set up by another thread, which is IIRC a undefined behavior in C/posix.)
if you find the cause, please let me know.
I found the solution.
The stack size of wasi target in rust is 4096 bytes, which was too small to run font decoding code..........
:cry:
Last updated: Nov 22 2024 at 16:03 UTC