Skip to content

[tsgen] Fix memory64 with pthreads TS generation. #24630

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 1, 2025
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: 8 additions & 7 deletions embuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@
# Minimal subset of targets used by CI systems to build enough to be useful
MINIMAL_TASKS = [
'libcompiler_rt',
'libcompiler_rt-mt',
'libcompiler_rt-legacysjlj',
'libcompiler_rt-wasmsjlj',
'libcompiler_rt-ww',
'libc',
'libc-debug',
'libc-mt-debug',
'libc-ww-debug',
'libc_optz',
'libc_optz-debug',
Expand All @@ -48,6 +50,7 @@
'libc++abi-debug-legacyexcept',
'libc++abi-debug-wasmexcept',
'libc++abi-debug-noexcept',
'libc++abi-debug-mt-noexcept',
'libc++abi-debug-ww-noexcept',
'libc++',
'libc++-legacyexcept',
Expand All @@ -58,15 +61,18 @@
'libc++-debug-wasmexcept',
'libc++-debug-legacyexcept',
'libc++-debug-noexcept',
'libc++-debug-mt-noexcept',
'libc++-debug-ww-noexcept',
'libal',
'libdlmalloc',
'libdlmalloc-tracing',
'libdlmalloc-debug',
'libdlmalloc-mt-debug',
'libdlmalloc-ww',
'libdlmalloc-ww-debug',
'libembind',
'libembind-rtti',
'libembind-mt-rtti',
'libemmalloc',
'libemmalloc-debug',
'libemmalloc-memvalidate',
Expand All @@ -76,12 +82,14 @@
'libmimalloc-mt',
'libGL',
'libGL-getprocaddr',
'libGL-mt-getprocaddr',
'libGL-emu-getprocaddr',
'libGL-emu-webgl2-ofb-getprocaddr',
'libGL-webgl2-ofb-getprocaddr',
'libGL-ww-getprocaddr',
'libhtml5',
'libsockets',
'libsockets-mt',
'libsockets-ww',
'libstubs',
'libstubs-debug',
Expand All @@ -100,29 +108,22 @@
# Additional tasks on top of MINIMAL_TASKS that are necessary for PIC testing on
# CI (which has slightly more tests than other modes that want to use MINIMAL)
MINIMAL_PIC_TASKS = MINIMAL_TASKS + [
'libcompiler_rt-mt',
'libc-mt',
'libc-mt-debug',
'libc_optz-mt',
'libc_optz-mt-debug',
'libc++abi-mt',
'libc++abi-mt-noexcept',
'libc++abi-debug-mt',
'libc++abi-debug-mt-noexcept',
'libc++-mt',
'libc++-mt-noexcept',
'libc++-debug-mt',
'libc++-debug-mt-noexcept',
'libdlmalloc-mt',
'libdlmalloc-mt-debug',
'libGL-emu',
'libGL-emu-webgl2-getprocaddr',
'libGL-mt-getprocaddr',
'libGL-mt-emu',
'libGL-mt-emu-webgl2-getprocaddr',
'libGL-mt-emu-webgl2-ofb-getprocaddr',
'libsockets_proxy',
'libsockets-mt',
'crtbegin',
'libsanitizer_common_rt',
'libubsan_rt',
Expand Down
7 changes: 6 additions & 1 deletion test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -3644,11 +3644,16 @@ def test_embind_tsgen_bigint(self):
self.run_process(args)
self.assertFileContents(test_file('other/embind_tsgen_bigint.d.ts'), read_file('embind_tsgen_bigint.d.ts'))

@parameterized({
'': [[]],
'pthread': [['-pthread']],
})
@requires_wasm64
def test_embind_tsgen_memory64(self):
def test_embind_tsgen_memory64(self, args):
# Check that when memory64 is enabled longs & unsigned longs are mapped to bigint in the generated TS bindings
self.run_process([EMXX, test_file('other/embind_tsgen_memory64.cpp'),
'-lembind', '--emit-tsd', 'embind_tsgen_memory64.d.ts', '-sMEMORY64'] +
args +
self.get_cflags())
self.assertFileContents(test_file('other/embind_tsgen_memory64.d.ts'), read_file('embind_tsgen_memory64.d.ts'))

Expand Down
10 changes: 7 additions & 3 deletions tools/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -2036,6 +2036,12 @@ def run_embind_gen(options, wasm_target, js_syms, extra_settings):
if basename == 'libembind.js':
settings.JS_LIBRARIES[i] = os.path.join(dirname, 'libembind_gen.js')
settings.MIN_NODE_VERSION = 160000 if settings.MEMORY64 else 150000
# The final version of the memory64 proposal is not implemented until node
# v24, so we need to lower it away in order to execute the binary at build
# time.
# TODO Remove lowering when emsdk version of node is >= 24 and just require it.
if settings.MEMORY64:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be == 1 there and below.

settings.MEMORY64 = 2
# Source maps haven't been generated yet and aren't needed to run embind_gen.
settings.LOAD_SOURCE_MAP = 0
outfile_js = in_temp('tsgen.js')
Expand All @@ -2045,9 +2051,7 @@ def run_embind_gen(options, wasm_target, js_syms, extra_settings):
# Build the flags needed by Node.js to properly run the output file.
node_args = []
if settings.MEMORY64:
# The final version of the memory64 proposal is not yet implemented in any
# shipping version of node, so we need to lower it away in order to
# execute the binary at built time.
# See comment above about lowering memory64.
building.run_wasm_opt(outfile_wasm, outfile_wasm, ['--memory64-lowering', '--table64-lowering'])
if settings.WASM_EXCEPTIONS:
node_args += shared.node_exception_flags(config.NODE_JS)
Expand Down
Loading