Avoid further trycatch and throw when exceptions are disabled#1403
Avoid further trycatch and throw when exceptions are disabled#1403ahayzen-kdab wants to merge 2 commits intodtolnay:masterfrom
Conversation
For WASM targets the `cc` crate changed to always set `-fno-exceptions`, before only `-fignore-exceptions` was being set elsewhere, so now programs fail to build when using `cxx` if any `throw` or `try ... catch` are used. > error: cannot use 'try' with exceptions disabled Instead for trycatch just call `func()`.
For WASM targets the `cc` crate changed to always set `-fno-exceptions`, before only `-fignore-exceptions` was being set elsewhere, so now programs fail to build when using `cxx` if any `throw` or `try ... catch` are used. > error: cannot use 'throw' with exceptions disabled Instead of throwing just abort.
|
A further problem is that CXX itself fails in it's build script to build the crate unless RUST_CXX_NO_EXCEPTIONS is set, this only works if i set |
|
Hmm looks like that didn't quite work i'll go back to just using an env var for now, unless anyone has suggestions. |
8c43685 to
7a0f3f2
Compare
|
Also found an alternate route through this downstream by ensuring we don't use/generate anything such as Result that would generate exception code when building for WASM. So this pull request becomes more a question of, when Which makes me wonder that these changes are not relevant. therefore i'll mark as draft and wait for feedback. |
For WASM targets the
cccrate changed to always set-fno-exceptions,before only
-fignore-exceptionswas being set elsewhere, so now programsfail to build when using
cxxif anythrowortry ... catchare used.Instead for trycatch just call
func(), if the inner code has thrown it will instead abort.Instead of throwing just print the error and abort, any previous code that was trying to catch can't exist anyway.
Any suggestions on better routes are welcome :-)