Wasm32-unknown-unknown panic_unwind support via native WASM exceptions

wasm32-unknown-unknown does not currently have unwind support, due to historical lack of support for unwinding. There is now an exception handling feature proposal that is deployed in most contemporary WASM engines (see roadmap ).

wasm32-unknown-emscripten does support this through emscripten, but at the cost of having to use emscripten. My primary environment I currently work in does not work well with emscripten, and as I understand it, the direction rustc is headed in, is not relying on emscripten.

I took a crack at implementing this myself, while having made a good bit of progress, cannot afford much more time on this personally. Would love to see it end up in the compiler though!


It could be added as optional feature when using cargo build -Zbuild-std and enabling this feature, but we can't modify the wasm32-unknown-unknown target to mandate support for wasm exception handling. I'm not sure how to actually throw an exception in LLVM ir for wasm though.

The intrinsic 'llvm.wasm.throw' and friends are what is needed in LLVM IR.


I am also investigating wasm exceptions for a few weeks now. I was able to make it work for [no_std] crates and created a pull request: Support for native WASM exceptions by mirkootter · Pull Request #111322 · rust-lang/rust · GitHub

This PR neither changes default behavior nor adds new command line params: It just makes those work which are already there, like -C panic and friends.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.