Skip to content

Does em++ able to generate standalone wasm with C++ exception? #19150

Answered by kripken
harry900831 asked this question in Q&A
Discussion options

You must be logged in to vote

__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 enable ASSERTIONS 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 emits

throw...
catch!

That should work in a standalone wasm VM as well, but I'm not sure which of them support wasm exceptions atm.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@harry900831
Comment options

Answer selected by harry900831
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants