Skip to content

Commit 3c1f975

Browse files
authored
Cleanup some WASM_BIGINT handling (emscripten-core#24796)
Test code need to run with wasm bigint enabled by default, since the setting is now the default. `gen_struct_info` doesn't need to add any flags since the compiler itself requires node 18 to run. Invert `also_with_wasm_bigint` decorator to reflect new default.
1 parent 2039bc7 commit 3c1f975

File tree

5 files changed

+32
-43
lines changed

5 files changed

+32
-43
lines changed

test/common.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -553,25 +553,21 @@ def metafunc(self, with_minimal_runtime, *args, **kwargs):
553553
return metafunc
554554

555555

556-
def also_with_wasm_bigint(f):
556+
def also_without_bigint(f):
557557
assert callable(f)
558558

559559
@wraps(f)
560-
def metafunc(self, with_bigint, *args, **kwargs):
560+
def metafunc(self, no_bigint, *args, **kwargs):
561561
if DEBUG:
562-
print('parameterize:bigint=%s' % with_bigint)
563-
if with_bigint:
564-
if self.is_wasm2js():
565-
self.skipTest('wasm2js does not support WASM_BIGINT')
562+
print('parameterize:no_bigint=%s' % no_bigint)
563+
if no_bigint:
566564
if self.get_setting('WASM_BIGINT') is not None:
567565
self.skipTest('redundant in bigint test config')
568-
self.set_setting('WASM_BIGINT')
569-
nodejs = self.require_node()
570-
self.node_args += shared.node_bigint_flags(nodejs)
566+
self.set_setting('WASM_BIGINT', 0)
571567
f(self, *args, **kwargs)
572568

573569
parameterize(metafunc, {'': (False,),
574-
'bigint': (True,)})
570+
'no_bigint': (True,)})
575571
return metafunc
576572

577573

@@ -641,16 +637,10 @@ def metafunc(self, standalone, *args, **kwargs):
641637
self.set_setting('STANDALONE_WASM')
642638
if not impure:
643639
self.set_setting('PURE_WASI')
644-
# we will not legalize the JS ffi interface, so we must use BigInt
645-
# support in order for JS to have a chance to run this without trapping
646-
# when it sees an i64 on the ffi.
647-
self.set_setting('WASM_BIGINT')
648640
self.cflags.append('-Wno-unused-command-line-argument')
649641
# if we are impure, disallow all wasm engines
650642
if impure:
651643
self.wasm_engines = []
652-
nodejs = self.require_node()
653-
self.node_args += shared.node_bigint_flags(nodejs)
654644
func(self, *args, **kwargs)
655645

656646
parameterize(metafunc, {'': (False,),
@@ -1224,6 +1214,7 @@ def setUp(self):
12241214
# Opt in to node v15 default behaviour:
12251215
# https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode
12261216
self.node_args.append('--unhandled-rejections=throw')
1217+
self.node_args += shared.node_bigint_flags(nodejs)
12271218

12281219
# If the version we are running tests in is lower than the version that
12291220
# emcc targets then we need to tell emcc to target that older version.
@@ -1236,6 +1227,9 @@ def setUp(self):
12361227
if node_version < emcc_min_node_version:
12371228
self.cflags += building.get_emcc_node_flags(node_version)
12381229
self.cflags.append('-Wno-transpile')
1230+
1231+
# This allows much of the test suite to be run on older versions of node that don't
1232+
# support wasm bigint integration
12391233
if node_version[0] < feature_matrix.min_browser_versions[feature_matrix.Feature.JS_BIGINT_INTEGRATION]['node'] / 10000:
12401234
self.cflags.append('-sWASM_BIGINT=0')
12411235

test/test_core.py

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import common
2626
from common import RunnerCore, path_from_root, requires_native_clang, test_file, create_file
2727
from common import skip_if, no_windows, no_mac, is_slow_test, parameterized, parameterize
28-
from common import env_modify, with_env_modify, disabled, flaky, node_pthreads, also_with_wasm_bigint
28+
from common import env_modify, with_env_modify, disabled, flaky, node_pthreads, also_without_bigint
2929
from common import read_file, read_binary, requires_v8, requires_node, requires_dev_dependency, requires_wasm2js, requires_node_canary
3030
from common import compiler_for, crossplatform, no_4gb, no_2gb, also_with_minimal_runtime, also_with_modularize
3131
from common import with_all_fs, also_with_nodefs, also_with_nodefs_both, also_with_noderawfs, also_with_wasmfs
@@ -4442,7 +4442,7 @@ def test_dylink_i64_b(self):
44424442
''', 'other says -1311768467750121224.\nmy fp says: 43.\nmy second fp says: 43.', force_c=True)
44434443

44444444
@with_dylink_reversed
4445-
@also_with_wasm_bigint
4445+
@also_without_bigint
44464446
def test_dylink_i64_c(self):
44474447
self.dylink_test(r'''
44484448
#include <stdio.h>
@@ -4494,17 +4494,13 @@ def test_dylink_i64_c(self):
44944494
EMSCRIPTEN_KEEPALIVE int64_t function_ret_64(int32_t i, int32_t j, int32_t k);
44954495
''', force_c=True)
44964496

4497+
@also_without_bigint
44974498
@parameterized({
4498-
'': [False],
4499-
'rtld_local': [True],
4500-
})
4501-
@parameterized({
4502-
'': [[]],
4503-
'nobigint': [['-sWASM_BIGINT=0']],
4499+
'': (False,),
4500+
'rtld_local': (True,),
45044501
})
45054502
@needs_dylink
4506-
def test_dylink_i64_invoke(self, rtld_local, args):
4507-
self.cflags += args
4503+
def test_dylink_i64_invoke(self, rtld_local):
45084504
if rtld_local:
45094505
self.set_setting('NO_AUTOLOAD_DYLIBS')
45104506
self.cflags.append('-DUSE_DLOPEN')
@@ -5668,7 +5664,7 @@ def test_readdir(self):
56685664
self.cflags += ['-DWASMFS_NODERAWFS']
56695665
self.do_run_in_out_file_test('dirent/test_readdir.c')
56705666

5671-
@also_with_wasm_bigint
5667+
@also_without_bigint
56725668
def test_readdir_empty(self):
56735669
self.do_run_in_out_file_test('dirent/test_readdir_empty.c')
56745670

@@ -5718,7 +5714,7 @@ def test_fcntl_open(self):
57185714
self.skipTest('noderawfs fails here under non-linux')
57195715
self.do_run_in_out_file_test('fcntl/test_fcntl_open.c')
57205716

5721-
@also_with_wasm_bigint
5717+
@also_without_bigint
57225718
def test_fcntl_misc(self):
57235719
if self.get_setting('WASMFS'):
57245720
self.cflags += ['-sFORCE_FILESYSTEM']
@@ -5768,7 +5764,7 @@ def test_utf8(self):
57685764
self.do_runf('core/test_utf8.c', 'OK.')
57695765

57705766
@with_both_text_decoder
5771-
@also_with_wasm_bigint
5767+
@also_without_bigint
57725768
def test_utf8_bench(self):
57735769
self.cflags += ['--embed-file', test_file('utf8_corpus.txt') + '@/utf8_corpus.txt']
57745770
self.do_runf('benchmark/benchmark_utf8.c', 'OK.')
@@ -6180,7 +6176,7 @@ def test_unistd_symlink_on_nodefs(self):
61806176
self.cflags += ['-lnodefs.js']
61816177
self.do_run_in_out_file_test('unistd/symlink_on_nodefs.c')
61826178

6183-
@also_with_wasm_bigint
6179+
@also_without_bigint
61846180
@also_with_nodefs
61856181
def test_unistd_io(self):
61866182
if self.get_setting('WASMFS'):
@@ -7108,7 +7104,7 @@ def test_dyncall_specific(self):
71087104
def test_dyncall_pointers(self, args):
71097105
self.do_core_test('test_dyncall_pointers.c', cflags=args)
71107106

7111-
@also_with_wasm_bigint
7107+
@also_without_bigint
71127108
@no_modularize_instance('uses Module object directly')
71137109
def test_getValue_setValue(self):
71147110
# these used to be exported, but no longer are by default
@@ -7541,7 +7537,7 @@ def test_embind_float_constants(self):
75417537
def test_embind_negative_constants(self):
75427538
self.do_run_in_out_file_test('embind/test_negative_constants.cpp', cflags=['-lembind'])
75437539

7544-
@also_with_wasm_bigint
7540+
@also_without_bigint
75457541
@no_esm_integration('embind is not compatible with WASM_ESM_INTEGRATION')
75467542
def test_embind_unsigned(self):
75477543
self.do_run_in_out_file_test('embind/test_unsigned.cpp', cflags=['-lembind'])
@@ -8065,7 +8061,7 @@ def test_modularize_closure_pre(self):
80658061

80668062
@no_wasm2js('symbol names look different wasm2js backtraces')
80678063
@no_modularize_instance('assumes .js output filename')
8068-
@also_with_wasm_bigint
8064+
@also_without_bigint
80698065
def test_emscripten_log(self):
80708066
self.cflags += ['-g', '-DRUN_FROM_JS_SHELL', '-Wno-deprecated-pragma']
80718067
if self.maybe_closure():
@@ -9671,7 +9667,7 @@ def test_externref_emjs(self, dynlink):
96719667
def test_syscall_intercept(self):
96729668
self.do_core_test('test_syscall_intercept.c')
96739669

9674-
@also_with_wasm_bigint
9670+
@also_without_bigint
96759671
def test_jslib_i64_params(self):
96769672
# Tests the defineI64Param and receiveI64ParamAsI53 helpers that are
96779673
# used to recieve i64 argument in syscalls.

test/test_other.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
from common import requires_wasm_eh, crossplatform, with_all_eh_sjlj, with_all_sjlj, requires_jspi
4040
from common import also_with_standalone_wasm, also_with_wasm2js, also_with_noderawfs
4141
from common import also_with_modularize, also_with_wasmfs, with_all_fs
42-
from common import also_with_minimal_runtime, also_with_wasm_bigint, also_with_wasm64, also_with_asan, flaky
42+
from common import also_with_minimal_runtime, also_without_bigint, also_with_wasm64, also_with_asan, flaky
4343
from common import EMTEST_BUILD_VERBOSE, PYTHON, WEBIDL_BINDER, EMCMAKE, EMCONFIGURE
4444
from common import requires_network, parameterize, copytree
4545
from tools import shared, building, utils, response_file, cache
@@ -6510,7 +6510,7 @@ def test_only_force_stdlibs_2(self):
65106510
def test_force_stdlibs(self):
65116511
self.do_runf('hello_world.c')
65126512

6513-
@also_with_standalone_wasm()
6513+
@also_with_standalone_wasm(impure=True)
65146514
def test_time(self):
65156515
self.do_other_test('test_time.c')
65166516

@@ -14900,7 +14900,7 @@ def test_no_cfi(self):
1490014900
err = self.expect_fail([EMCC, '-fsanitize=cfi', '-flto', test_file('hello_world.c')])
1490114901
self.assertContained('emcc: error: emscripten does not currently support -fsanitize=cfi', err)
1490214902

14903-
@also_with_wasm_bigint
14903+
@also_without_bigint
1490414904
def test_parseTools(self):
1490514905
# Suppress js compiler warnings because we deliberately use legacy parseTools functions
1490614906
self.cflags += ['-Wno-js-compiler', '--js-library', test_file('other/test_parseTools.js')]
@@ -15614,7 +15614,7 @@ def test_standalone_whole_archive(self):
1561415614
def test_proxy_to_worker(self, args):
1561515615
self.do_runf('hello_world.c', cflags=['--proxy-to-worker'] + args)
1561615616

15617-
@also_with_standalone_wasm()
15617+
@also_with_standalone_wasm(impure=True)
1561815618
def test_console_out(self):
1561915619
self.do_other_test('test_console_out.c', regex=True)
1562015620

tools/gen_struct_info.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
sys.path.insert(0, __rootdir__)
7070

7171
from tools import building
72-
from tools import config
7372
from tools import shared
7473
from tools import system_libs
7574
from tools import utils
@@ -258,8 +257,7 @@ def inspect_headers(headers, cflags):
258257

259258
# Run the compiled program.
260259
show('Calling generated program... ' + js_file_path)
261-
node_args = shared.node_bigint_flags(config.NODE_JS)
262-
info = shared.run_js_tool(js_file_path, node_args=node_args, stdout=shared.PIPE)
260+
info = shared.run_js_tool(js_file_path, stdout=shared.PIPE)
263261

264262
if not DEBUG:
265263
# Remove all temporary files.

tools/shared.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,9 @@ def check_node_version():
346346

347347
def node_bigint_flags(nodejs):
348348
node_version = get_node_version(nodejs)
349-
# wasm bigint was enabled by default in node v16.
350-
if node_version and node_version < (16, 0, 0):
349+
# The --experimental-wasm-bigint flag was added in v12, and then removed (enabled by default)
350+
# in v16.
351+
if node_version and node_version < (16, 0, 0) and node_version >= (12, 0, 0):
351352
return ['--experimental-wasm-bigint']
352353
else:
353354
return []

0 commit comments

Comments
 (0)