Skip to content

Commit 62e2265

Browse files
authored
[EH] Add more explanation to EXPORT_EXCEPTION_HANDLING_HELPERS deprecation (#26517)
Like WebAssembly/binaryen#8507, there can be people who use this methods at `-O1` or above. This adds more explanation of the workaround in ChangeeLog, site docs, and the deprecation message. You don't strictly need `decrementExceptionRefcount` to use `getExceptionMessage`, but you need it if you care about asan, because exceptions thrown in Wasm and caught in JS don't get freed unless you explicitly decrement the refcount.
1 parent 312eed6 commit 62e2265

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

ChangeLog.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ See docs/process.md for more on how version tagging works.
2222
----------------------
2323
- `EXPORT_EXCEPTION_HANDLING_HELPERS` is deprecated and setting it will not do
2424
anything. `getExceptionMessage` is exported anyway when `ASSERTIONS` or
25-
`EXCEPTION_STACK_TRACES` is set, which are set by default at `-O0`. (#26499)
25+
`EXCEPTION_STACK_TRACES` is set, which are set by default at `-O0`. At `-O1`
26+
or above, you can export it separately by
27+
`-sEXPORTED_RUNTIME_METHODS=getExceptionMessage,decrementExceptionRefcount`.
28+
(#26499)
2629
- The deprecated `EMSCRIPTEN` macro is now defined in `emscripten.h` rather than
2730
on the command line (`__EMSCRIPTEN__`, which is built into LLVM, should be
2831
used instead). (#26417)

site/source/docs/porting/exceptions.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ exception thrown``, this code will print ``MyException,My exception thrown``.
146146

147147
``getExceptionMessage`` is available when exceptions are used and either
148148
``-sASSERTIONS`` or ``-sEXCEPTION_STACK_TRACES`` is set, which are by default
149-
true at ``-O0``.
149+
true at ``-O0``. At ``-O1`` or above, you can export it separately by
150+
``-sEXPORTED_RUNTIME_METHODS=getExceptionMessage,decrementExceptionRefcount``.
150151

151152
If the stack pointer has been moved due to stack allocations within the Wasm
152153
function before an exception is thrown, you can use ``stackSave()`` and

site/source/docs/tools_reference/settings_reference.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3419,7 +3419,7 @@ these settings please open a bug (or reply to one of the existing bugs).
34193419
- ``LEGALIZE_JS_FFI``: to disable JS type legalization use `-sWASM_BIGINT` or `-sSTANDALONE_WASM`
34203420
- ``ASYNCIFY_EXPORTS``: please use JSPI_EXPORTS instead
34213421
- ``LINKABLE``: under consideration for removal (https://github.com/emscripten-core/emscripten/issues/25262)
3422-
- ``EXPORT_EXCEPTION_HANDLING_HELPERS``: getExceptionMessage is automatically exported when ASSERTIONS or EXCEPTION_STACK_TRACES is 1 and throw is used
3422+
- ``EXPORT_EXCEPTION_HANDLING_HELPERS``: getExceptionMessage is exported anyway when ASSERTIONS or EXCEPTION_STACK_TRACES is set, which are set by default at -O0. At -O1 or above, you can export it separately by -sEXPORTED_RUNTIME_METHODS=getExceptionMessage,decrementExceptionRefcount.
34233423

34243424
.. _legacy-settings:
34253425

tools/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
'LEGALIZE_JS_FFI': 'to disable JS type legalization use `-sWASM_BIGINT` or `-sSTANDALONE_WASM`',
115115
'ASYNCIFY_EXPORTS': 'please use JSPI_EXPORTS instead',
116116
'LINKABLE': 'under consideration for removal (https://github.com/emscripten-core/emscripten/issues/25262)',
117-
'EXPORT_EXCEPTION_HANDLING_HELPERS': 'getExceptionMessage is automatically exported when ASSERTIONS or EXCEPTION_STACK_TRACES is 1 and throw is used',
117+
'EXPORT_EXCEPTION_HANDLING_HELPERS': 'getExceptionMessage is exported anyway when ASSERTIONS or EXCEPTION_STACK_TRACES is set, which are set by default at -O0. At -O1 or above, you can export it separately by -sEXPORTED_RUNTIME_METHODS=getExceptionMessage,decrementExceptionRefcount.',
118118
}
119119

120120
# Settings that don't need to be externalized when serializing to json because they

0 commit comments

Comments
 (0)