Allow exceptions on wasm platforms#1714
Conversation
WASM now supports exceptions. Remove the hardcoded `-fno-exceptions` option. Resolves rust-lang#1680
|
Is it universal? I was under the impression that only some wasm targets and some toolchain supports it |
|
It is supported by emscripten (target wasm32-unknown-emscripten) by default; it is supported by wasi (all the wasm32-wasip* targets) since WebAssembly/wasi-sdk#606 (merged 3 weeks ago, to become available in the upcoming release); I have no experience with wasm32-unknown-unknown and wasm32v1-none. But, in any case, it should probably be up to the developer, rather than hardcoded in the library. |
|
In that case, can you please only allow exception on these specific target? Blank removal would break compilation of existing projects. |
|
Yes, we could do that, but that would not be much better:
As an alternative, we could keep the old behavior by default (i.e., if wasm, add |
|
In the latter case, though, I'm not sure what kind of interface we want to export. We could just have an option (env var + Alternatively, we could generalize this a bit and have an option to control exception support in general (which defaults to So, should we just introduce an option to control the disabling of exceptions? Should we make it only effective on wasm? |
|
I'm not sure about this as I'm not that familiar with current status of exception in wasm, cc @alexcrichton can you please give us some advice on this? |
|
Reading over this and some history here, I think that the best way forward is this PR as-is, which is to delete the unconditional This'll definitely fix the use case for Emscripten targets where exceptions should work just fine. The reason I don't think this will cause widespread breakage for WASI targets is that Actually supporting exceptions on WASI is more involved than just updating wasi-sdk even with WebAssembly/wasi-sdk#606, and that doesn't mean that WASI all-of-a-sudden supports exceptions. In theory the buckets folks could be in (for WASI targets) are:
If the Overall, in my opinion, the |
NobodyXu
left a comment
There was a problem hiding this comment.
Thank you @kolayne @alexcrichton in that case I'd merge this PR, and it'd be scheduled to release next Friday (as it misses today's release), if you need a new release now I can do it
cc @alexcrichton this sounds like we should add a generic conversion, if |
|
I was initially thinking that'd be a possibility, yeah, but then I realized as I was typing that even if Rust has exceptions disabled it's possible to safely enable exceptions in C++ so long as exceptions never cross the boundary (which would be up to the user at that point). So even force-disabling when Rust has exceptions disables I think can technically run afoul of otherwise-valid situations. Given that I think it's best for Something more "obviously correct" might emerge in the future, though, but for now I think it's best to just delete this code. |
|
Thank you @alexcrichton ! |
Content
WASM now supports exceptions.
Remove the hardcoded
-fno-exceptionsoption.Resolves #1680
Discussion
Should we remain compatible with programs that rely on the old behavior of the library? Should we keep the old behavior as default, and add a function that will allow the user to select between, e.g.,
-fno-exceptions,-fwasm-exceptions, and-fexceptions?