diff --git a/ChangeLog.md b/ChangeLog.md index a1698a1783749..7536c7b957eef 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -24,6 +24,11 @@ See docs/process.md for more on how version tagging works. `WebAssembly.instantiateStreaming()` (via `Blob.stream()` and a `tee()`'d network body respectively), so enabling the flag no longer loses the download/compile overlap of the standard streaming path. (#27609) +- `WASM_LEGACY_EXCEPTIONS` now defaults to `false`. When `-fwasm-exceptions` is + used, Emscripten now emits instructions for the standardized WebAssembly + exception handling proposal by default. Users targeting older engines can + still opt in to the legacy exception handling proposal with + `-sWASM_LEGACY_EXCEPTIONS`. (#27575) 6.0.8 - 08/20/26 ---------------- diff --git a/site/source/docs/tools_reference/settings_reference.rst b/site/source/docs/tools_reference/settings_reference.rst index aaccc9b8823b2..e0c763e76c684 100644 --- a/site/source/docs/tools_reference/settings_reference.rst +++ b/site/source/docs/tools_reference/settings_reference.rst @@ -1175,7 +1175,7 @@ https://github.com/WebAssembly/exception-handling/blob/main/proposals/exception- .. note:: Applicable during both linking and compilation -Default value: true +Default value: false .. _asyncify: diff --git a/src/settings.js b/src/settings.js index 8101b4662c3d8..4f0a882da86ce 100644 --- a/src/settings.js +++ b/src/settings.js @@ -796,7 +796,7 @@ var EXCEPTION_STACK_TRACES = false; // If false, emit instructions for the standardized exception handling proposal: // https://github.com/WebAssembly/exception-handling/blob/main/proposals/exception-handling/Exceptions.md // [compile+link] -var WASM_LEGACY_EXCEPTIONS = true; +var WASM_LEGACY_EXCEPTIONS = false; // Whether to support async operations in the compiled code. This makes it // possible to call JS functions from synchronous-looking code in C/C++. diff --git a/test/test_codesize.py b/test/test_codesize.py index b89b585526755..2c80184ef91d4 100644 --- a/test/test_codesize.py +++ b/test/test_codesize.py @@ -366,7 +366,7 @@ def test_codesize_minimal_pthreads(self, args): # exceptions does not pull in demangling by default, which increases code size 'mangle': (['-O2', '-fexceptions', '-sEXPORTED_FUNCTIONS=_main,_free,___cxa_demangle', '-Wno-deprecated'],), # Wasm EH's code size increase is smaller than that of Emscripten EH - 'except_wasm': (['-O2', '-fwasm-exceptions', '-sWASM_LEGACY_EXCEPTIONS=0'],), + 'except_wasm': (['-O2', '-fwasm-exceptions'],), 'except_wasm_legacy': (['-O2', '-fwasm-exceptions', '-sWASM_LEGACY_EXCEPTIONS'],), # eval_ctors 1 can partially optimize, but runs into getenv() for locale # code. mode 2 ignores those and fully optimizes out the ctors diff --git a/test/test_other.py b/test/test_other.py index 50dff783b8f7c..5eb9fab732b10 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -8820,7 +8820,7 @@ def test_lto(self, args): @parameterized({ 'noexcept': (), 'except_emscripten': ('-sDISABLE_EXCEPTION_CATCHING=0',), - 'except_wasm': ('-fwasm-exceptions', '-sWASM_LEGACY_EXCEPTIONS=0'), + 'except_wasm': ('-fwasm-exceptions',), 'except_wasm_legacy': ('-fwasm-exceptions', '-sWASM_LEGACY_EXCEPTIONS'), }) def test_lto_libcxx(self, *args): @@ -12682,11 +12682,11 @@ def test_SUPPORT_LONGJMP_wasm(self): # automatically sets DISABLE_EXCEPTION_THROWING to 1, which is 0 by default, # because Emscripten EH and Wasm SjLj cannot be used at the same time. self.run_process([EMCC, test_file('core/test_longjmp.c'), '-c', '-sSUPPORT_LONGJMP=wasm', '-o', 'a.o']) - self.assertContained('try', self.get_wasm_text('a.o')) + self.assertContained('try_table', self.get_wasm_text('a.o')) - # If -sWASM_LEGACY_EXCEPTIONS=0 is provided, it uses the standard Wasm EH. - self.run_process([EMCC, test_file('core/test_longjmp.c'), '-c', '-sSUPPORT_LONGJMP=wasm', '-sWASM_LEGACY_EXCEPTIONS=0', '-o', 'b.o']) - self.assertContained('try_table', self.get_wasm_text('b.o')) + # If -sWASM_LEGACY_EXCEPTIONS is provided, it uses the legacy Wasm EH. + self.run_process([EMCC, test_file('core/test_longjmp.c'), '-c', '-sSUPPORT_LONGJMP=wasm', '-sWASM_LEGACY_EXCEPTIONS', '-o', 'b.o']) + self.assertContained('try', self.get_wasm_text('b.o')) @parameterized({ '': ([],), @@ -15303,7 +15303,7 @@ def test_SUPPORT_BIG_ENDIAN(self): 'noexcept': ('-fno-exceptions',), 'default': (), 'except': ('-sDISABLE_EXCEPTION_CATCHING=0',), - 'except_wasm': ('-fwasm-exceptions', '-sWASM_LEGACY_EXCEPTIONS=0'), + 'except_wasm': ('-fwasm-exceptions',), 'except_wasm_legacy': ('-fwasm-exceptions', '-sWASM_LEGACY_EXCEPTIONS'), }) def test_std_promise_link(self, *args): diff --git a/tools/feature_matrix.py b/tools/feature_matrix.py index 1fe4bf8d89e9b..28f7507ed67d8 100644 --- a/tools/feature_matrix.py +++ b/tools/feature_matrix.py @@ -261,11 +261,11 @@ def apply_min_browser_versions(): enable_feature(Feature.WORKER_ES6_MODULES, 'EXPORT_ES6 with -sWASM_WORKERS') if settings.OFFSCREENCANVAS_SUPPORT: enable_feature(Feature.OFFSCREENCANVAS_SUPPORT, 'OFFSCREENCANVAS_SUPPORT') - if settings.WASM_EXCEPTIONS or settings.SUPPORT_LONGJMP == 'wasm': # Wasm longjmp support will lean on Wasm (Legacy) EH + if settings.WASM_EXCEPTIONS or settings.SUPPORT_LONGJMP == 'wasm': if settings.WASM_LEGACY_EXCEPTIONS: - enable_feature(Feature.WASM_LEGACY_EXCEPTIONS, 'Wasm Legacy exceptions (-fwasm-exceptions with -sWASM_LEGACY_EXCEPTIONS=1)') + enable_feature(Feature.WASM_LEGACY_EXCEPTIONS, 'Wasm Legacy exceptions (-fwasm-exceptions with WASM_LEGACY_EXCEPTIONS)') else: - enable_feature(Feature.WASM_EXCEPTIONS, 'Wasm exceptions (-fwasm-exceptions with -sWASM_LEGACY_EXCEPTIONS=0)') + enable_feature(Feature.WASM_EXCEPTIONS, 'Wasm exceptions (-fwasm-exceptions without WASM_LEGACY_EXCEPTIONS)') if settings.GROWABLE_ARRAYBUFFERS == 2: enable_feature(Feature.GROWABLE_ARRAYBUFFERS, 'GrowableSharedArrayBuffer') @@ -276,3 +276,5 @@ def auto_enable_features(): # compiler rather then adding them all ad-hoc as internal settings if caniuse(Feature.GROWABLE_ARRAYBUFFERS): default_setting('GROWABLE_ARRAYBUFFERS', 2) + if not caniuse(Feature.WASM_LEGACY_EXCEPTIONS): + default_setting('WASM_LEGACY_EXCEPTIONS', 0) diff --git a/tools/link.py b/tools/link.py index 63ac7476b7952..bc3ab03351de6 100644 --- a/tools/link.py +++ b/tools/link.py @@ -1567,7 +1567,7 @@ def limit_incoming_module_api(): settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE += ['$_wasmWorkerInitializeRuntime'] # Set min browser versions based on certain settings such as WASM_BIGINT, - # PTHREADS, AUDIO_WORKLET + # PTHREADS, AUDIO_WORKLET, WASM_EXCEPTIONS. # Such setting must be set before this point feature_matrix.apply_min_browser_versions() diff --git a/tools/system_libs.py b/tools/system_libs.py index 9ccda61b7ed8d..211d3e8c775a6 100644 --- a/tools/system_libs.py +++ b/tools/system_libs.py @@ -807,7 +807,7 @@ def get_cflags(self): case Exceptions.WASM_LEGACY: cflags += ['-fwasm-exceptions', '-sWASM_LEGACY_EXCEPTIONS'] case Exceptions.WASM: - cflags += ['-fwasm-exceptions', '-sWASM_LEGACY_EXCEPTIONS=0'] + cflags += ['-fwasm-exceptions'] return cflags @@ -865,7 +865,6 @@ def get_cflags(self): '-D__WASM_SJLJ__'] case Exceptions.WASM: cflags += ['-sSUPPORT_LONGJMP=wasm', - '-sWASM_LEGACY_EXCEPTIONS=0', '-sDISABLE_EXCEPTION_THROWING', '-D__WASM_SJLJ__'] return cflags