diff --git a/test/test_core.py b/test/test_core.py index 7fd563448bb99..d76f59bd8f249 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -4876,7 +4876,11 @@ def test_dylink_raii_exceptions(self): @with_all_eh_sjlj @with_dylink_reversed - def test_dylink_exceptions_try_catch(self): + @parameterized({ + '': ([],), + 'dyncalls': (['-sDYNCALLS'],), + }) + def test_dylink_exceptions_try_catch(self, args): self.dylink_test(main=r''' #include extern void side(); @@ -4898,7 +4902,7 @@ def test_dylink_exceptions_try_catch(self): printf("side: caught %.1f\n", f); } } - ''', expected=['main: caught 3\nside: caught 5.3\n']) + ''', expected=['main: caught 3\nside: caught 5.3\n'], cflags=args) @with_all_eh_sjlj @with_dylink_reversed diff --git a/tools/js_manipulation.py b/tools/js_manipulation.py index fafc45372af93..8e1392c71e5f6 100644 --- a/tools/js_manipulation.py +++ b/tools/js_manipulation.py @@ -107,18 +107,19 @@ def isidentifier(name): def make_dynCall(sig, args): - # wasm2c and asyncify are not yet compatible with direct wasm table calls if settings.MEMORY64: args = list(args) args[0] = f'Number({args[0]})' + # wasm2c and asyncify are not yet compatible with direct wasm table calls so use + # the legacy DYNCALLS mechanism. if settings.DYNCALLS or not is_legal_sig(sig): args = ','.join(args) - if not settings.MAIN_MODULE and not settings.SIDE_MODULE: - # Optimize dynCall accesses in the case when not building with dynamic - # linking enabled. - return 'dynCall_%s(%s)' % (sig, args) - else: - return 'Module["dynCall_%s"](%s)' % (sig, args) + if settings.MAIN_MODULE or settings.SIDE_MODULE: + # In dynamic linking mode not all of the dynCall_xxx function are defined + # in the main module so might not be available as global symbols. + # See `registerDynCallSymbols` in `libdylink.js`. + return "dynCalls['%s'](%s)" % (sig, args) + return 'dynCall_%s(%s)' % (sig, args) else: call_args = ",".join(args[1:]) return f'getWasmTableEntry({args[0]})({call_args})'