@@ -8370,7 +8370,7 @@ def test_binaryen_warn_mem(self):
83708370 self.run_process([EMCC, test_file('hello_world.c'), '-sINITIAL_MEMORY=' + str(16 * 1024 * 1024), '--pre-js', 'pre.js', '-sWASM_ASYNC_COMPILATION=0', '-sIMPORTED_MEMORY'])
83718371 out = self.run_js('a.out.js', assert_returncode=NON_ZERO)
83728372 self.assertContained('LinkError', out)
8373- self.assertContained("memory import 1 has a larger maximum size 800 than the module's declared maximum", out)
8373+ self.assertContained("memory import 2 has a larger maximum size 800 than the module's declared maximum", out)
83748374 self.assertNotContained('hello, world!', out)
83758375 # and with memory growth, all should be good
83768376 self.run_process([EMCC, test_file('hello_world.c'), '-sINITIAL_MEMORY=' + str(16 * 1024 * 1024), '--pre-js', 'pre.js', '-sALLOW_MEMORY_GROWTH', '-sWASM_ASYNC_COMPILATION=0', '-sIMPORTED_MEMORY'])
@@ -10270,37 +10270,45 @@ def test_wasm_features_section(self, args):
1027010270
1027110271 def test_wasm_features(self):
1027210272 # Test that wasm features are explicitly enabled or disabled based on target engine version
10273- def verify_features_sec(feature, expect_in):
10274- with webassembly.Module('hello_world.o') as module:
10273+ def verify_features_sec(feature, expect_in, linked=False ):
10274+ with webassembly.Module('a.out.wasm' if linked else ' hello_world.o') as module:
1027510275 features = module.get_target_features()
1027610276 if expect_in:
10277- self.assertTrue(feature in features and features[feature] == webassembly.TargetFeaturePrefix.USED)
10277+ self.assertTrue(feature in features and
10278+ features[feature] == webassembly.TargetFeaturePrefix.USED,
10279+ f'{feature} missing from wasm file')
1027810280 else:
10279- self.assertFalse(feature in features)
10281+ self.assertFalse(feature in features,
10282+ f'{feature} unexpectedly found in wasm file')
10283+
10284+ def verify_features_sec_linked(feature, expect_in):
10285+ return verify_features_sec(feature, expect_in, linked=True)
1028010286
1028110287 def compile(flags):
10282- self.run_process([EMCC, test_file('hello_world.c'), '-c' ] + flags)
10288+ self.run_process([EMCC, test_file('hello_world.c')] + flags)
1028310289
10284- compile([])
10290+ compile(['-c' ])
1028510291 verify_features_sec('bulk-memory', False)
1028610292 verify_features_sec('nontrapping-fptoint', False)
1028710293 verify_features_sec('sign-ext', True)
1028810294 verify_features_sec('mutable-globals', True)
1028910295 verify_features_sec('multivalue', True)
1029010296 verify_features_sec('reference-types', True)
1029110297
10292- compile(['-mnontrapping-fptoint'])
10298+ compile(['-mnontrapping-fptoint', '-c' ])
1029310299 verify_features_sec('nontrapping-fptoint', True)
1029410300
10295- compile(['-sMIN_SAFARI_VERSION=150000'])
10296- verify_features_sec('sign-ext', True)
10297- verify_features_sec('mutable-globals', True)
10298- verify_features_sec('multivalue', True)
10299- verify_features_sec('bulk-memory', True)
10300- verify_features_sec('nontrapping-fptoint', True)
10301+ # BIGINT causes binaryen to not run, and keeps the target_features section
10302+ compile(['-sMIN_SAFARI_VERSION=150000', '-sWASM_BIGINT'])
10303+ verify_features_sec_linked('sign-ext', True)
10304+ verify_features_sec_linked('mutable-globals', True)
10305+ verify_features_sec_linked('multivalue', True)
10306+ verify_features_sec_linked('bulk-memory', True)
10307+ verify_features_sec_linked('nontrapping-fptoint', False)
1030110308
10302- compile(['-sMIN_SAFARI_VERSION=150000', '-mno-bulk-memory'])
10303- verify_features_sec('bulk-memory', False)
10309+ compile(['-sMIN_SAFARI_VERSION=150000', '-mno-bulk-memory', '-sWASM_BIGINT'])
10310+ # FIXME? -mno-bulk-memory at link time does not override MIN_SAFARI_VERSION. it probably should?
10311+ verify_features_sec_linked('bulk-memory', True)
1030410312
1030510313 def test_js_preprocess(self):
1030610314 # Use stderr rather than stdout here because stdout is redirected to the output JS file itself.
@@ -12850,7 +12858,7 @@ def test_split_module(self, customLoader, jspi):
1285012858 self.assertExists('profile.data')
1285112859
1285212860 wasm_split = os.path.join(building.get_binaryen_bin(), 'wasm-split')
12853- wasm_split_run = [wasm_split, '-g', '--enable-mutable-globals', '--enable-bulk-memory', '-- export-prefix=%', 'test_split_module.wasm.orig', '-o1', 'primary.wasm', '-o2', 'secondary.wasm', '--profile=profile.data']
12861+ wasm_split_run = [wasm_split, '-g', '--enable-mutable-globals', '--export-prefix=%', 'test_split_module.wasm.orig', '-o1', 'primary.wasm', '-o2', 'secondary.wasm', '--profile=profile.data']
1285412862 if jspi:
1285512863 wasm_split_run += ['--jspi', '--enable-reference-types']
1285612864 self.run_process(wasm_split_run)
0 commit comments