Does em++ able to generate standalone wasm with C++ exception? #19150
-
Hi all, I'm currently working on adding wasm exception handling proposal support for a runtime. According to my test, it seems that if we generate the wasm with following code and command: #include <stdio.h>
int main() {
try {
puts("throw...");
throw 1;
puts("(never reached)");
} catch(...) {
puts("catch!");
}
return 0;
} According to this page (last update on 2019), if I understand correctly, it states that emscripten still can't generate standalone wasm with C++ exceptions.
Moreover, If I generate the wasm with the command: I would like to ask whether there is any update for standalone wasm that support C++ exception handling. And if capable, how to generate one? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Aside from that, I'm not aware of any issues.
That should work in a standalone wasm VM as well, but I'm not sure which of them support wasm exceptions atm. |
Beta Was this translation helpful? Give feedback.
__throw_exception_with_stack_trace
is a debugging helper. That shouldn't be emitted in standalone mode, so we should add an if to remove that. But right now you are getting that since at-O0
we enableASSERTIONS
by default. Building with-O1
or above (or-O0 -sASSERTIONS=0
) will avoid that issue.Aside from that, I'm not aware of any issues.
emcc a.cpp -O1 --profiling -fwasm-exceptions -sSTANDALONE_WASM
on your cpp file emits a standalone wasm with no odd imports, and when I run it using the JS shim in node 16.5 with--experimental-wasm-eh
it emitsThat should work in a standalone wasm VM as well, but I'm not sure which of them support wasm exceptions atm.