Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -14494,6 +14494,21 @@ def test_wasi_random_get(self):
def test_wasi_sched_yield(self):
self.run_wasi_test_suite_test('wasi_sched_yield')

def test_wasi_with_sjlj(self):
# When PURE_WASI is set and Wasm exception is not being used, we turn off
# SUPPORT_LONGJMP by default because it uses a JS-based simulation of
# longjmp.
self.set_setting('PURE_WASI')
err = self.expect_fail([EMCC, test_file('core/test_longjmp.c')] + self.get_emcc_args())
self.assertContained('error: longjmp support was disabled (SUPPORT_LONGJMP=0)', err)

# When using Wasm exception, SUPPORT_LONGJMP defaults to 'wasm', which does
# not use the JS-based support. This should succeed.
self.emcc_args.append('-fwasm-exceptions')
# -fwasm-exceptions exports __cpp_exception, so this is necessary
self.set_setting('DEFAULT_TO_CXX')
self.do_runf(test_file('core/test_longjmp.c'), emcc_args=self.get_emcc_args())

def test_memops_bulk_memory(self):
self.emcc_args += ['--profiling-funcs', '-fno-builtin']

Expand Down
6 changes: 5 additions & 1 deletion tools/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,11 @@ def phase_linker_setup(options, state, newargs):
if settings.PURE_WASI:
settings.STANDALONE_WASM = 1
settings.WASM_BIGINT = 1
settings.SUPPORT_LONGJMP = 0
# WASI does not support Emscripten (JS-based) exception catching, which the
# JS-based longjmp support also uses. Emscripten EH is by default disabled
# so we don't need to do anything here.
if not settings.WASM_EXCEPTIONS:
default_setting('SUPPORT_LONGJMP', 0)

if options.no_entry:
settings.EXPECT_MAIN = 0
Expand Down
Loading