Skip to content

Commit 31a6f1e

Browse files
authored
[tsgen] Fix memory64 with pthreads TS generation. (#24630)
We already lower memory64 away when running TS generation, but we were not generating a lowered version of the JS which caused us to try and use a BigInt when creating the memory. Fixes #24623
1 parent 757b8cb commit 31a6f1e

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

embuilder.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@
3232
# Minimal subset of targets used by CI systems to build enough to be useful
3333
MINIMAL_TASKS = [
3434
'libcompiler_rt',
35+
'libcompiler_rt-mt',
3536
'libcompiler_rt-legacysjlj',
3637
'libcompiler_rt-wasmsjlj',
3738
'libcompiler_rt-ww',
3839
'libc',
3940
'libc-debug',
41+
'libc-mt-debug',
4042
'libc-ww-debug',
4143
'libc_optz',
4244
'libc_optz-debug',
@@ -48,6 +50,7 @@
4850
'libc++abi-debug-legacyexcept',
4951
'libc++abi-debug-wasmexcept',
5052
'libc++abi-debug-noexcept',
53+
'libc++abi-debug-mt-noexcept',
5154
'libc++abi-debug-ww-noexcept',
5255
'libc++',
5356
'libc++-legacyexcept',
@@ -58,15 +61,18 @@
5861
'libc++-debug-wasmexcept',
5962
'libc++-debug-legacyexcept',
6063
'libc++-debug-noexcept',
64+
'libc++-debug-mt-noexcept',
6165
'libc++-debug-ww-noexcept',
6266
'libal',
6367
'libdlmalloc',
6468
'libdlmalloc-tracing',
6569
'libdlmalloc-debug',
70+
'libdlmalloc-mt-debug',
6671
'libdlmalloc-ww',
6772
'libdlmalloc-ww-debug',
6873
'libembind',
6974
'libembind-rtti',
75+
'libembind-mt-rtti',
7076
'libemmalloc',
7177
'libemmalloc-debug',
7278
'libemmalloc-memvalidate',
@@ -76,12 +82,14 @@
7682
'libmimalloc-mt',
7783
'libGL',
7884
'libGL-getprocaddr',
85+
'libGL-mt-getprocaddr',
7986
'libGL-emu-getprocaddr',
8087
'libGL-emu-webgl2-ofb-getprocaddr',
8188
'libGL-webgl2-ofb-getprocaddr',
8289
'libGL-ww-getprocaddr',
8390
'libhtml5',
8491
'libsockets',
92+
'libsockets-mt',
8593
'libsockets-ww',
8694
'libstubs',
8795
'libstubs-debug',
@@ -100,29 +108,22 @@
100108
# Additional tasks on top of MINIMAL_TASKS that are necessary for PIC testing on
101109
# CI (which has slightly more tests than other modes that want to use MINIMAL)
102110
MINIMAL_PIC_TASKS = MINIMAL_TASKS + [
103-
'libcompiler_rt-mt',
104111
'libc-mt',
105-
'libc-mt-debug',
106112
'libc_optz-mt',
107113
'libc_optz-mt-debug',
108114
'libc++abi-mt',
109115
'libc++abi-mt-noexcept',
110116
'libc++abi-debug-mt',
111-
'libc++abi-debug-mt-noexcept',
112117
'libc++-mt',
113118
'libc++-mt-noexcept',
114119
'libc++-debug-mt',
115-
'libc++-debug-mt-noexcept',
116120
'libdlmalloc-mt',
117-
'libdlmalloc-mt-debug',
118121
'libGL-emu',
119122
'libGL-emu-webgl2-getprocaddr',
120-
'libGL-mt-getprocaddr',
121123
'libGL-mt-emu',
122124
'libGL-mt-emu-webgl2-getprocaddr',
123125
'libGL-mt-emu-webgl2-ofb-getprocaddr',
124126
'libsockets_proxy',
125-
'libsockets-mt',
126127
'crtbegin',
127128
'libsanitizer_common_rt',
128129
'libubsan_rt',

test/test_other.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3644,11 +3644,16 @@ def test_embind_tsgen_bigint(self):
36443644
self.run_process(args)
36453645
self.assertFileContents(test_file('other/embind_tsgen_bigint.d.ts'), read_file('embind_tsgen_bigint.d.ts'))
36463646

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

tools/link.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2036,6 +2036,12 @@ def run_embind_gen(options, wasm_target, js_syms, extra_settings):
20362036
if basename == 'libembind.js':
20372037
settings.JS_LIBRARIES[i] = os.path.join(dirname, 'libembind_gen.js')
20382038
settings.MIN_NODE_VERSION = 160000 if settings.MEMORY64 else 150000
2039+
# The final version of the memory64 proposal is not implemented until node
2040+
# v24, so we need to lower it away in order to execute the binary at build
2041+
# time.
2042+
# TODO Remove lowering when emsdk version of node is >= 24 and just require it.
2043+
if settings.MEMORY64:
2044+
settings.MEMORY64 = 2
20392045
# Source maps haven't been generated yet and aren't needed to run embind_gen.
20402046
settings.LOAD_SOURCE_MAP = 0
20412047
outfile_js = in_temp('tsgen.js')
@@ -2045,9 +2051,7 @@ def run_embind_gen(options, wasm_target, js_syms, extra_settings):
20452051
# Build the flags needed by Node.js to properly run the output file.
20462052
node_args = []
20472053
if settings.MEMORY64:
2048-
# The final version of the memory64 proposal is not yet implemented in any
2049-
# shipping version of node, so we need to lower it away in order to
2050-
# execute the binary at built time.
2054+
# See comment above about lowering memory64.
20512055
building.run_wasm_opt(outfile_wasm, outfile_wasm, ['--memory64-lowering', '--table64-lowering'])
20522056
if settings.WASM_EXCEPTIONS:
20532057
node_args += shared.node_exception_flags(config.NODE_JS)

0 commit comments

Comments
 (0)