diff --git a/test/other/metadce/test_metadce_cxx_except_wasm_exnref.exports b/test/other/metadce/test_metadce_cxx_except_wasm_exnref.exports new file mode 100644 index 000000000000..5555bb2a116c --- /dev/null +++ b/test/other/metadce/test_metadce_cxx_except_wasm_exnref.exports @@ -0,0 +1,11 @@ +__indirect_function_table +__trap +__wasm_call_ctors +_emscripten_stack_alloc +dynCall_iiiiiijj +dynCall_iiiiij +dynCall_iiiiijj +dynCall_jiji +dynCall_viijii +main +memory diff --git a/test/other/metadce/test_metadce_cxx_except_wasm_exnref.gzsize b/test/other/metadce/test_metadce_cxx_except_wasm_exnref.gzsize new file mode 100644 index 000000000000..1f3999c7b639 --- /dev/null +++ b/test/other/metadce/test_metadce_cxx_except_wasm_exnref.gzsize @@ -0,0 +1 @@ +9807 diff --git a/test/other/metadce/test_metadce_cxx_except_wasm_exnref.imports b/test/other/metadce/test_metadce_cxx_except_wasm_exnref.imports new file mode 100644 index 000000000000..ba18e729d24c --- /dev/null +++ b/test/other/metadce/test_metadce_cxx_except_wasm_exnref.imports @@ -0,0 +1,10 @@ +env._abort_js +env._emscripten_memcpy_js +env.emscripten_resize_heap +env.strftime_l +wasi_snapshot_preview1.environ_get +wasi_snapshot_preview1.environ_sizes_get +wasi_snapshot_preview1.fd_close +wasi_snapshot_preview1.fd_read +wasi_snapshot_preview1.fd_seek +wasi_snapshot_preview1.fd_write diff --git a/test/other/metadce/test_metadce_cxx_except_wasm_exnref.jssize b/test/other/metadce/test_metadce_cxx_except_wasm_exnref.jssize new file mode 100644 index 000000000000..6f878e2e252d --- /dev/null +++ b/test/other/metadce/test_metadce_cxx_except_wasm_exnref.jssize @@ -0,0 +1 @@ +24140 diff --git a/test/other/metadce/test_metadce_cxx_except_wasm_exnref.sent b/test/other/metadce/test_metadce_cxx_except_wasm_exnref.sent new file mode 100644 index 000000000000..4b9481ab81c9 --- /dev/null +++ b/test/other/metadce/test_metadce_cxx_except_wasm_exnref.sent @@ -0,0 +1,10 @@ +_abort_js +_emscripten_memcpy_js +emscripten_resize_heap +environ_get +environ_sizes_get +fd_close +fd_read +fd_seek +fd_write +strftime_l diff --git a/test/other/metadce/test_metadce_cxx_except_wasm_exnref.size b/test/other/metadce/test_metadce_cxx_except_wasm_exnref.size new file mode 100644 index 000000000000..b03162ae9dc1 --- /dev/null +++ b/test/other/metadce/test_metadce_cxx_except_wasm_exnref.size @@ -0,0 +1 @@ +141975 diff --git a/test/test_core.py b/test/test_core.py index 3adac48e2f33..f4f6b1bb3a2b 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -28,7 +28,7 @@ from common import env_modify, with_env_modify, disabled, flaky, node_pthreads, also_with_wasm_bigint from common import read_file, read_binary, requires_v8, requires_node, requires_wasm2js, requires_node_canary from common import compiler_for, crossplatform, no_4gb, no_2gb, also_with_minimal_runtime -from common import with_all_eh_sjlj, with_all_sjlj, also_with_standalone_wasm, can_do_standalone, no_wasm64 +from common import with_all_eh_sjlj, with_all_sjlj, also_with_standalone_wasm, can_do_standalone, no_wasm64, requires_wasm_exnref from common import NON_ZERO, WEBIDL_BINDER, EMBUILDER, PYTHON import clang_native @@ -896,6 +896,7 @@ def test_longjmp_zero(self): self.skipTest('https://github.com/emscripten-core/emscripten/issues/21533') self.do_core_test('test_longjmp_zero.c') + @requires_wasm_exnref def test_longjmp_with_and_without_exceptions(self): # Emscripten SjLj with and without Emscripten EH support self.set_setting('SUPPORT_LONGJMP', 'emscripten') @@ -908,13 +909,15 @@ def test_longjmp_with_and_without_exceptions(self): self.set_setting('SUPPORT_LONGJMP', 'wasm') if self.is_wasm2js(): self.skipTest('wasm2js does not support wasm EH/SjLj') - self.require_wasm_eh() # FIXME Temporarily disabled. Enable this later when the bug is fixed. if '-fsanitize=address' in self.emcc_args: self.skipTest('Wasm EH does not work with asan yet') self.emcc_args.append('-fwasm-exceptions') for arg in ['-fwasm-exceptions', '-fno-exceptions']: self.do_core_test('test_longjmp.c', emcc_args=[arg]) + # Wasm SjLj with and with new EH (exnref) support + self.set_setting('WASM_EXNREF') + self.do_core_test('test_longjmp.c', emcc_args=['-fwasm-exceptions']) @with_all_sjlj def test_longjmp2(self): @@ -1031,6 +1034,7 @@ def test_exceptions(self): self.maybe_closure() self.do_run_in_out_file_test('core/test_exceptions.cpp', out_suffix='_caught') + @requires_wasm_exnref def test_exceptions_with_and_without_longjmp(self): self.set_setting('EXCEPTION_DEBUG') self.maybe_closure() @@ -1043,7 +1047,6 @@ def test_exceptions_with_and_without_longjmp(self): self.clear_setting('DISABLE_EXCEPTION_CATCHING') if self.is_wasm2js(): self.skipTest('wasm2js does not support wasm EH/SjLj') - self.require_wasm_eh() # FIXME Temporarily disabled. Enable this later when the bug is fixed. if '-fsanitize=address' in self.emcc_args: self.skipTest('Wasm EH does not work with asan yet') @@ -1051,6 +1054,11 @@ def test_exceptions_with_and_without_longjmp(self): for support_longjmp in [0, 'wasm']: self.set_setting('SUPPORT_LONGJMP', support_longjmp) self.do_run_in_out_file_test('core/test_exceptions.cpp', out_suffix='_caught') + # Wasm new EH (exnref) with and without Wasm SjLj support + self.set_setting('WASM_EXNREF') + for support_longjmp in [0, 'wasm']: + self.set_setting('SUPPORT_LONGJMP', support_longjmp) + self.do_run_in_out_file_test('core/test_exceptions.cpp', out_suffix='_caught') def test_exceptions_off(self): self.set_setting('DISABLE_EXCEPTION_CATCHING') diff --git a/test/test_other.py b/test/test_other.py index 7b64653a054d..70a96a727080 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -34,7 +34,7 @@ from common import env_modify, no_mac, no_windows, only_windows, requires_native_clang, with_env_modify from common import create_file, parameterized, NON_ZERO, node_pthreads, TEST_ROOT, test_file from common import compiler_for, EMBUILDER, requires_v8, requires_node, requires_wasm64, requires_node_canary -from common import requires_wasm_eh, crossplatform, with_all_eh_sjlj, with_all_sjlj +from common import requires_wasm_exnref, crossplatform, with_all_eh_sjlj, with_all_sjlj from common import also_with_standalone_wasm, also_with_env_modify, also_with_wasm2js from common import also_with_minimal_runtime, also_with_wasm_bigint, also_with_wasm64, flaky from common import EMTEST_BUILD_VERBOSE, PYTHON, WEBIDL_BINDER @@ -3295,13 +3295,19 @@ def test_embind_tsgen_memory64(self): self.get_emcc_args()) self.assertFileContents(test_file('other/embind_tsgen_memory64.d.ts'), read_file('embind_tsgen_memory64.d.ts')) - def test_embind_tsgen_exceptions(self): + @parameterized({ + '': [0], + 'wasm_exnref': [1] + }) + def test_embind_tsgen_exceptions(self, wasm_exnref): + self.set_setting('WASM_EXNREF', wasm_exnref) # Check that when Wasm exceptions and assertions are enabled bindings still generate. self.run_process([EMXX, test_file('other/embind_tsgen.cpp'), '-lembind', '-fwasm-exceptions', '-sASSERTIONS', # Use the deprecated `--embind-emit-tsd` to ensure it # still works until removed. - '--embind-emit-tsd', 'embind_tsgen.d.ts', '-Wno-deprecated']) + '--embind-emit-tsd', 'embind_tsgen.d.ts', '-Wno-deprecated'] + + self.get_emcc_args()) self.assertFileContents(test_file('other/embind_tsgen.d.ts'), read_file('embind_tsgen.d.ts')) def test_embind_jsgen_method_pointer_stability(self): @@ -8529,6 +8535,7 @@ def test_metadce_minimal_pthreads(self): '-sDEMANGLE_SUPPORT', '-Wno-deprecated'], [], ['waka']), # noqa # Wasm EH's code size increase is smaller than that of Emscripten EH 'except_wasm': (['-O2', '-fwasm-exceptions'], [], ['waka']), # noqa + 'except_wasm_exnref': (['-O2', '-fwasm-exceptions', '-sWASM_EXNREF'], [], ['waka']), # noqa # eval_ctors 1 can partially optimize, but runs into getenv() for locale # code. mode 2 ignores those and fully optimizes out the ctors 'ctors1': (['-O2', '-sEVAL_CTORS'], [], ['waka']), # noqa @@ -8828,7 +8835,8 @@ def test_lto(self, args): @parameterized({ 'noexcept': [], 'except': ['-sDISABLE_EXCEPTION_CATCHING=0'], - 'except_wasm': ['-fwasm-exceptions'] + 'except_wasm': ['-fwasm-exceptions'], + 'except_wasm_exnref': ['-fwasm-exceptions', '-sWASM_EXNREF'] }) def test_lto_libcxx(self, *args): self.run_process([EMXX, test_file('hello_libcxx.cpp'), '-flto'] + list(args)) @@ -8847,11 +8855,14 @@ def test_lto_flags(self): # We have LTO tests covered in 'wasmltoN' targets in test_core.py, but they # don't run as a part of Emscripten CI, so we add a separate LTO test here. - @requires_wasm_eh + @requires_wasm_exnref def test_lto_wasm_exceptions(self): self.set_setting('EXCEPTION_DEBUG') self.emcc_args += ['-fwasm-exceptions', '-flto'] self.do_run_in_out_file_test('core/test_exceptions.cpp', out_suffix='_caught') + # New Wasm EH with exnref + self.set_setting('WASM_EXNREF') + self.do_run_in_out_file_test('core/test_exceptions.cpp', out_suffix='_caught') @parameterized({ '': ([],), @@ -12267,13 +12278,16 @@ def test_standalone_export_main(self): # We should consider making this a warning since the `_main` export is redundant. self.run_process([EMCC, '-sEXPORTED_FUNCTIONS=_main', '-sSTANDALONE_WASM', test_file('core/test_hello_world.c')]) - @requires_wasm_eh + @requires_wasm_exnref def test_standalone_wasm_exceptions(self): self.set_setting('STANDALONE_WASM') self.set_setting('WASM_BIGINT') self.wasm_engines = [] self.emcc_args += ['-fwasm-exceptions'] self.do_run_in_out_file_test('core/test_exceptions.cpp', out_suffix='_caught') + # New Wasm EH with exnref + self.set_setting('WASM_EXNREF') + self.do_run_in_out_file_test('core/test_exceptions.cpp', out_suffix='_caught') def test_missing_malloc_export(self): # we used to include malloc by default. show a clear error in builds with