Skip to content

Commit 0480e37

Browse files
committed
Disable WASM_LEGACY_EXCEPTIONS by default
The Wasm committee and browser vendors would like legacy wasm exceptions to be phased out ASAP. To that end this change disables `WASM_LEGACY_EXCEPTIONS` by default for users of `-fwasm-exceptions`. User who need to target old browsers can obviously set `-sWASM_LEGACY_EXCEPTIONS` still. Running ./emcc -fwasm-exceptions with EMCC_DEBUG=1 shows the effect this has on min browser versions: ``` feature_matrix:DEBUG: Enabling MIN_CHROME_VERSION=137 to accommodate Wasm exceptions (-fwasm-exceptions without sWASM_LEGACY_EXCEPTIONS) feature_matrix:DEBUG: Enabling MIN_FIREFOX_VERSION=131 to accommodate Wasm exceptions (-fwasm-exceptions without WASM_LEGACY_EXCEPTIONS) feature_matrix:DEBUG: Enabling MIN_SAFARI_VERSION=180400 to accommodate Wasm exceptions (-fwasm-exceptions without WASM_LEGACY_EXCEPTIONS) feature_matrix:DEBUG: Enabling MIN_NODE_VERSION=241500 to accommodate Wasm exceptions (-fwasm-exceptions without WASM_LEGACY_EXCEPTIONS) ```
1 parent 79c7741 commit 0480e37

7 files changed

Lines changed: 18 additions & 14 deletions

File tree

ChangeLog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ See docs/process.md for more on how version tagging works.
2424
`WebAssembly.instantiateStreaming()` (via `Blob.stream()` and a `tee()`'d
2525
network body respectively), so enabling the flag no longer loses the
2626
download/compile overlap of the standard streaming path. (#27609)
27+
- `WASM_LEGACY_EXCEPTIONS` now defaults to `false`. When `-fwasm-exceptions` is
28+
used, Emscripten now emits instructions for the standardized WebAssembly
29+
exception handling proposal by default. Users targeting older engines can
30+
still opt in to the legacy exception handling proposal with
31+
`-sWASM_LEGACY_EXCEPTIONS`. (#27575)
2732

2833
6.0.8 - 08/20/26
2934
----------------

site/source/docs/tools_reference/settings_reference.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,7 @@ https://github.com/WebAssembly/exception-handling/blob/main/proposals/exception-
11751175

11761176
.. note:: Applicable during both linking and compilation
11771177

1178-
Default value: true
1178+
Default value: false
11791179

11801180
.. _asyncify:
11811181

src/settings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ var EXCEPTION_STACK_TRACES = false;
796796
// If false, emit instructions for the standardized exception handling proposal:
797797
// https://github.com/WebAssembly/exception-handling/blob/main/proposals/exception-handling/Exceptions.md
798798
// [compile+link]
799-
var WASM_LEGACY_EXCEPTIONS = true;
799+
var WASM_LEGACY_EXCEPTIONS = false;
800800

801801
// Whether to support async operations in the compiled code. This makes it
802802
// possible to call JS functions from synchronous-looking code in C/C++.

test/test_codesize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ def test_codesize_minimal_pthreads(self, args):
366366
# exceptions does not pull in demangling by default, which increases code size
367367
'mangle': (['-O2', '-fexceptions', '-sEXPORTED_FUNCTIONS=_main,_free,___cxa_demangle', '-Wno-deprecated'],),
368368
# Wasm EH's code size increase is smaller than that of Emscripten EH
369-
'except_wasm': (['-O2', '-fwasm-exceptions', '-sWASM_LEGACY_EXCEPTIONS=0'],),
369+
'except_wasm': (['-O2', '-fwasm-exceptions'],),
370370
'except_wasm_legacy': (['-O2', '-fwasm-exceptions', '-sWASM_LEGACY_EXCEPTIONS'],),
371371
# eval_ctors 1 can partially optimize, but runs into getenv() for locale
372372
# code. mode 2 ignores those and fully optimizes out the ctors

test/test_other.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8820,7 +8820,7 @@ def test_lto(self, args):
88208820
@parameterized({
88218821
'noexcept': (),
88228822
'except_emscripten': ('-sDISABLE_EXCEPTION_CATCHING=0',),
8823-
'except_wasm': ('-fwasm-exceptions', '-sWASM_LEGACY_EXCEPTIONS=0'),
8823+
'except_wasm': ('-fwasm-exceptions',),
88248824
'except_wasm_legacy': ('-fwasm-exceptions', '-sWASM_LEGACY_EXCEPTIONS'),
88258825
})
88268826
def test_lto_libcxx(self, *args):
@@ -12682,11 +12682,11 @@ def test_SUPPORT_LONGJMP_wasm(self):
1268212682
# automatically sets DISABLE_EXCEPTION_THROWING to 1, which is 0 by default,
1268312683
# because Emscripten EH and Wasm SjLj cannot be used at the same time.
1268412684
self.run_process([EMCC, test_file('core/test_longjmp.c'), '-c', '-sSUPPORT_LONGJMP=wasm', '-o', 'a.o'])
12685-
self.assertContained('try', self.get_wasm_text('a.o'))
12685+
self.assertContained('try_table', self.get_wasm_text('a.o'))
1268612686

12687-
# If -sWASM_LEGACY_EXCEPTIONS=0 is provided, it uses the standard Wasm EH.
12688-
self.run_process([EMCC, test_file('core/test_longjmp.c'), '-c', '-sSUPPORT_LONGJMP=wasm', '-sWASM_LEGACY_EXCEPTIONS=0', '-o', 'b.o'])
12689-
self.assertContained('try_table', self.get_wasm_text('b.o'))
12687+
# If -sWASM_LEGACY_EXCEPTIONS is provided, it uses the legacy Wasm EH.
12688+
self.run_process([EMCC, test_file('core/test_longjmp.c'), '-c', '-sSUPPORT_LONGJMP=wasm', '-sWASM_LEGACY_EXCEPTIONS', '-o', 'b.o'])
12689+
self.assertContained('try', self.get_wasm_text('b.o'))
1269012690

1269112691
@parameterized({
1269212692
'': ([],),
@@ -15303,7 +15303,7 @@ def test_SUPPORT_BIG_ENDIAN(self):
1530315303
'noexcept': ('-fno-exceptions',),
1530415304
'default': (),
1530515305
'except': ('-sDISABLE_EXCEPTION_CATCHING=0',),
15306-
'except_wasm': ('-fwasm-exceptions', '-sWASM_LEGACY_EXCEPTIONS=0'),
15306+
'except_wasm': ('-fwasm-exceptions',),
1530715307
'except_wasm_legacy': ('-fwasm-exceptions', '-sWASM_LEGACY_EXCEPTIONS'),
1530815308
})
1530915309
def test_std_promise_link(self, *args):

tools/feature_matrix.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,11 @@ def apply_min_browser_versions():
261261
enable_feature(Feature.WORKER_ES6_MODULES, 'EXPORT_ES6 with -sWASM_WORKERS')
262262
if settings.OFFSCREENCANVAS_SUPPORT:
263263
enable_feature(Feature.OFFSCREENCANVAS_SUPPORT, 'OFFSCREENCANVAS_SUPPORT')
264-
if settings.WASM_EXCEPTIONS or settings.SUPPORT_LONGJMP == 'wasm': # Wasm longjmp support will lean on Wasm (Legacy) EH
264+
if settings.WASM_EXCEPTIONS or settings.SUPPORT_LONGJMP == 'wasm':
265265
if settings.WASM_LEGACY_EXCEPTIONS:
266-
enable_feature(Feature.WASM_LEGACY_EXCEPTIONS, 'Wasm Legacy exceptions (-fwasm-exceptions with -sWASM_LEGACY_EXCEPTIONS=1)')
266+
enable_feature(Feature.WASM_LEGACY_EXCEPTIONS, 'Wasm Legacy exceptions (-fwasm-exceptions with WASM_LEGACY_EXCEPTIONS)')
267267
else:
268-
enable_feature(Feature.WASM_EXCEPTIONS, 'Wasm exceptions (-fwasm-exceptions with -sWASM_LEGACY_EXCEPTIONS=0)')
268+
enable_feature(Feature.WASM_EXCEPTIONS, 'Wasm exceptions (-fwasm-exceptions without WASM_LEGACY_EXCEPTIONS)')
269269
if settings.GROWABLE_ARRAYBUFFERS == 2:
270270
enable_feature(Feature.GROWABLE_ARRAYBUFFERS, 'GrowableSharedArrayBuffer')
271271

tools/system_libs.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ def get_cflags(self):
807807
case Exceptions.WASM_LEGACY:
808808
cflags += ['-fwasm-exceptions', '-sWASM_LEGACY_EXCEPTIONS']
809809
case Exceptions.WASM:
810-
cflags += ['-fwasm-exceptions', '-sWASM_LEGACY_EXCEPTIONS=0']
810+
cflags += ['-fwasm-exceptions']
811811

812812
return cflags
813813

@@ -865,7 +865,6 @@ def get_cflags(self):
865865
'-D__WASM_SJLJ__']
866866
case Exceptions.WASM:
867867
cflags += ['-sSUPPORT_LONGJMP=wasm',
868-
'-sWASM_LEGACY_EXCEPTIONS=0',
869868
'-sDISABLE_EXCEPTION_THROWING',
870869
'-D__WASM_SJLJ__']
871870
return cflags

0 commit comments

Comments
 (0)