Skip to content

Commit 05db1ba

Browse files
brendandahlstephenduong1004kripken
authored
[tsgen] Remove asyncify function exports assertions. (#25899)
When using `tsgen` with `-sASYNCIFY=1` and assertions enabled, an assertion failure occurs: `Assertion failed: missing Wasm export: asyncify_start_unwind`. This is due to #25541. This PR disables assertions for the `_asyncify_<x>` exports when running `tsgen` to resolve the issue. Continuation of #25780 --------- Co-authored-by: stephenduong1004 <[email protected]> Co-authored-by: Alon Zakai <[email protected]>
1 parent 23242cb commit 05db1ba

File tree

2 files changed

+37
-40
lines changed

2 files changed

+37
-40
lines changed

test/test_other.py

Lines changed: 33 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3554,49 +3554,42 @@ def test_embind_tsgen_end_to_end(self, opts, tsc_opts):
35543554

35553555
@is_slow_test
35563556
@requires_dev_dependency('typescript')
3557-
def test_embind_tsgen_ignore(self):
3557+
# These extra arguments are not related to TS binding generation but we want to
3558+
# verify that they do not interfere with it.
3559+
@parameterized({
3560+
'1': [['-sALLOW_MEMORY_GROWTH=1',
3561+
'-Wno-pthreads-mem-growth',
3562+
'-sMAXIMUM_MEMORY=4GB',
3563+
'--pre-js', 'fail.js',
3564+
'--post-js', 'fail.js',
3565+
'--extern-pre-js', 'fail.js',
3566+
'--extern-post-js', 'fail.js',
3567+
'-sENVIRONMENT=worker',
3568+
'--use-preload-cache',
3569+
'--preload-file', 'fail.js',
3570+
'-O3',
3571+
'-msimd128',
3572+
'-pthread',
3573+
'-sPROXY_TO_PTHREAD',
3574+
'-sPTHREAD_POOL_SIZE=1',
3575+
'-sSINGLE_FILE',
3576+
'-lembind', # Test duplicated link option.
3577+
], 'embind_tsgen_ignore_1.d.ts'],
3578+
'2': [['--embed-file', 'fail.js',
3579+
'-sMINIMAL_RUNTIME=2',
3580+
'-sEXPORT_ES6=1',
3581+
'-sASSERTIONS=0',
3582+
'-sSTRICT=1',
3583+
], 'embind_tsgen_ignore_2.d.ts'],
3584+
'3': [['-sWASM=0'], 'embind_tsgen_ignore_3.d.ts'],
3585+
'4': [['-fsanitize=undefined', '-gsource-map'], 'embind_tsgen_ignore_3.d.ts'],
3586+
'5': [['-sASYNCIFY'], 'embind_tsgen_ignore_3.d.ts'],
3587+
})
3588+
def test_embind_tsgen_ignore(self, extra_args, expected_ts_file):
35583589
create_file('fail.js', 'assert(false);')
35593590
self.cflags += ['-lembind', '--emit-tsd', 'embind_tsgen.d.ts']
3560-
# These extra arguments are not related to TS binding generation but we want to
3561-
# verify that they do not interfere with it.
3562-
extra_args = ['-sALLOW_MEMORY_GROWTH=1',
3563-
'-Wno-pthreads-mem-growth',
3564-
'-sMAXIMUM_MEMORY=4GB',
3565-
'--pre-js', 'fail.js',
3566-
'--post-js', 'fail.js',
3567-
'--extern-pre-js', 'fail.js',
3568-
'--extern-post-js', 'fail.js',
3569-
'-sENVIRONMENT=worker',
3570-
'--use-preload-cache',
3571-
'--preload-file', 'fail.js',
3572-
'-O3',
3573-
'-msimd128',
3574-
'-pthread',
3575-
'-sPROXY_TO_PTHREAD',
3576-
'-sPTHREAD_POOL_SIZE=1',
3577-
'-sSINGLE_FILE',
3578-
'-lembind', # Test duplicated link option.
3579-
]
35803591
self.emcc('other/embind_tsgen.cpp', extra_args)
3581-
self.assertFileContents(test_file('other/embind_tsgen_ignore_1.d.ts'), read_file('embind_tsgen.d.ts'))
3582-
# Test these args separately since they conflict with arguments in the first test.
3583-
extra_args = ['-sMODULARIZE',
3584-
'--embed-file', 'fail.js',
3585-
'-sMINIMAL_RUNTIME=2',
3586-
'-sEXPORT_ES6=1',
3587-
'-sASSERTIONS=0',
3588-
'-sSTRICT=1']
3589-
self.emcc('other/embind_tsgen.cpp', extra_args)
3590-
self.assertFileContents(test_file('other/embind_tsgen_ignore_2.d.ts'), read_file('embind_tsgen.d.ts'))
3591-
# Also test this separately since it conflicts with other settings.
3592-
extra_args = ['-sWASM=0']
3593-
self.emcc('other/embind_tsgen.cpp', extra_args)
3594-
self.assertFileContents(test_file('other/embind_tsgen_ignore_3.d.ts'), read_file('embind_tsgen.d.ts'))
3595-
3596-
extra_args = ['-fsanitize=undefined',
3597-
'-gsource-map']
3598-
self.emcc('other/embind_tsgen.cpp', extra_args)
3599-
self.assertFileContents(test_file('other/embind_tsgen_ignore_3.d.ts'), read_file('embind_tsgen.d.ts'))
3592+
self.assertFileContents(test_file(f'other/{expected_ts_file}'), read_file('embind_tsgen.d.ts'))
36003593

36013594
def test_embind_tsgen_worker_env(self):
36023595
self.cflags += ['-lembind', '--emit-tsd', 'embind_tsgen.d.ts']

tools/emscripten.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,10 @@ def create_receiving(function_exports, other_exports, library_symbols, aliases):
962962
receiving.append('\nfunction assignWasmExports(wasmExports) {')
963963
if settings.ASSERTIONS:
964964
for sym in exports:
965+
if settings.EMBIND_GEN_MODE and sym.startswith('asyncify_'):
966+
# EMBIND_GEN_MODE is run before binaryen so the asyncify exports that
967+
# are created by binaryen will be missing.
968+
continue
965969
receiving.append(f" assert(typeof wasmExports['{sym}'] != 'undefined', 'missing Wasm export: {sym}');")
966970
for sym, info in exports.items():
967971
is_function = type(info) == webassembly.FuncType

0 commit comments

Comments
 (0)