Skip to content

Commit e179b57

Browse files
authored
Don't run binaryen postprocessing for Emscripten EH/SjLj (#12399)
Now that we are renaming invoke wrappers and `emscripten_longjmp_jmpbuf` in the wasm backend, using Emscripten EH or SjLj does not need Binaryen's postprocessing. This makes Emscripten not enable Binaryen postprocessing using wasm-emscripten-finalize when we are using them, and deletes all special handling for `emscripten_longjmp_jmpbuf`, given that Emscripten will not see it. Addresses: WebAssembly/binaryen#3043 WebAssembly/binaryen#3081 Companions: https://reviews.llvm.org/D88697 WebAssembly/binaryen#3191
1 parent a7f4f96 commit e179b57

File tree

6 files changed

+4
-24
lines changed

6 files changed

+4
-24
lines changed

emscripten.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -484,10 +484,6 @@ def finalize_wasm(infile, memfile, DEBUG):
484484
# if we don't need to modify the wasm, don't tell finalize to emit a wasm file
485485
modify_wasm = False
486486

487-
# C++ exceptions and longjmp require invoke processing,
488-
# https://github.com/WebAssembly/binaryen/issues/3081
489-
if shared.Settings.SUPPORT_LONGJMP or shared.Settings.DISABLE_EXCEPTION_CATCHING != 1:
490-
modify_wasm = True
491487
if shared.Settings.WASM2JS:
492488
# wasm2js requires full legalization (and will do extra wasm binary
493489
# later processing later anyhow)

src/deps_info.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@
124124
"longjmp": ["setThrew", "realloc", "testSetjmp", "saveSetjmp"],
125125
"siglongjmp": ["setThrew", "realloc", "testSetjmp", "saveSetjmp"],
126126
"emscripten_longjmp": ["setThrew", "realloc", "testSetjmp", "saveSetjmp"],
127-
"emscripten_longjmp_jmpbuf": ["setThrew", "realloc", "testSetjmp", "saveSetjmp"],
128127
"emscripten_websocket_new": ["malloc", "free"],
129128
"emscripten_websocket_set_onmessage_callback_on_thread": ["malloc", "free"],
130129
"emscripten_websocket_set_onclose_callback_on_thread": ["malloc", "free"],

src/library.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1794,7 +1794,6 @@ LibraryManager.library = {
17941794
// they each have a different signature - it is only at the wasm level that
17951795
// they become identical).
17961796
emscripten_longjmp: 'longjmp',
1797-
emscripten_longjmp_jmpbuf: 'longjmp',
17981797

17991798
// ==========================================================================
18001799
// sys/wait.h

tests/test_other.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9000,9 +9000,8 @@ def ok(args, filename='hello_world.cpp', expected='hello, world!'):
90009000
self.run_process([EMCC, path_from_root('tests', filename)] + args)
90019001
self.assertContained(expected, self.run_js('a.out.js'))
90029002

9003-
# -O0 with BigInt support (to avoid the need for legalization) and without
9004-
# longjmp
9005-
required_flags = ['-sWASM_BIGINT', '-sSUPPORT_LONGJMP=0']
9003+
# -O0 with BigInt support (to avoid the need for legalization)
9004+
required_flags = ['-sWASM_BIGINT']
90069005
ok(required_flags)
90079006
# Same with DWARF
90089007
ok(required_flags + ['-g'])
@@ -9021,16 +9020,11 @@ def fail(args, details):
90219020

90229021
# plain -O0
90239022
legalization_message = 'to disable int64 legalization (which requires changes after link) use -s WASM_BIGINT'
9024-
longjmp_message = 'to disable longjmp support (which requires changes after link) use -s SUPPORT_LONGJMP=0'
90259023
fail([], legalization_message)
9026-
fail(['-sWASM_BIGINT'], longjmp_message)
9027-
fail(['-sSUPPORT_LONGJMP=0'], legalization_message)
90289024
# optimized builds even without legalization
90299025
optimization_message = '-O2+ optimizations always require changes, build with -O0 or -O1 instead'
90309026
fail(required_flags + ['-O2'], optimization_message)
90319027
fail(required_flags + ['-O3'], optimization_message)
9032-
# exceptions fails until invokes are fixed
9033-
fail(required_flags + ['-fexceptions'], 'C++ exceptions always require changes')
90349028

90359029
def test_output_to_nowhere(self):
90369030
self.run_process([EMCC, path_from_root('tests', 'hello_world.cpp'), '-o', os.devnull, '-c'])

tools/building.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,16 +1574,12 @@ def run_binaryen_command(tool, infile, outfile=None, args=[], debug=False, stdou
15741574
# emit some extra helpful text for common issues
15751575
extra = ''
15761576
# a plain -O0 build *almost* doesn't need post-link changes, except for
1577-
# legalization and longjmp. show a clear error for those (as the flags
1578-
# the user passed in are not enough to see what went wrong)
1577+
# legalization. show a clear error for those (as the flags the user passed
1578+
# in are not enough to see what went wrong)
15791579
if shared.Settings.LEGALIZE_JS_FFI:
15801580
extra += '\nnote: to disable int64 legalization (which requires changes after link) use -s WASM_BIGINT'
1581-
if shared.Settings.SUPPORT_LONGJMP:
1582-
extra += '\nnote: to disable longjmp support (which requires changes after link) use -s SUPPORT_LONGJMP=0'
15831581
if shared.Settings.OPT_LEVEL > 0:
15841582
extra += '\nnote: -O2+ optimizations always require changes, build with -O0 or -O1 instead'
1585-
if shared.Settings.DISABLE_EXCEPTION_CATCHING != 1:
1586-
extra += '\nnote: C++ exceptions always require changes'
15871583
exit_with_error('changes to the wasm are required after link, but disallowed by ERROR_ON_WASM_CHANGES_AFTER_LINK: ' + str(cmd) + extra)
15881584
if debug:
15891585
cmd += ['-g'] # preserve the debug info

tools/wasm2c/base.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,6 @@ IMPORT_IMPL(void, Z_envZ_emscripten_longjmpZ_vii, (u32 buf, u32 value), {
131131
longjmp(setjmp_stack[next_setjmp - 1], 1);
132132
});
133133

134-
IMPORT_IMPL(void, Z_envZ_emscripten_longjmp_jmpbufZ_vii, (u32 buf, u32 value), {
135-
return Z_envZ_emscripten_longjmpZ_vii(buf, value);
136-
});
137-
138134
IMPORT_IMPL(void, Z_envZ_emscripten_notify_memory_growthZ_vi, (u32 size), {});
139135

140136
static u32 tempRet0 = 0;

0 commit comments

Comments
 (0)