@@ -8370,7 +8370,7 @@ def test_binaryen_warn_mem(self):
8370
8370
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'])
8371
8371
out = self.run_js('a.out.js', assert_returncode=NON_ZERO)
8372
8372
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)
8374
8374
self.assertNotContained('hello, world!', out)
8375
8375
# and with memory growth, all should be good
8376
8376
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):
10270
10270
10271
10271
def test_wasm_features(self):
10272
10272
# 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:
10275
10275
features = module.get_target_features()
10276
10276
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')
10278
10280
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)
10280
10286
10281
10287
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)
10283
10289
10284
- compile([])
10290
+ compile(['-c' ])
10285
10291
verify_features_sec('bulk-memory', False)
10286
10292
verify_features_sec('nontrapping-fptoint', False)
10287
10293
verify_features_sec('sign-ext', True)
10288
10294
verify_features_sec('mutable-globals', True)
10289
10295
verify_features_sec('multivalue', True)
10290
10296
verify_features_sec('reference-types', True)
10291
10297
10292
- compile(['-mnontrapping-fptoint'])
10298
+ compile(['-mnontrapping-fptoint', '-c' ])
10293
10299
verify_features_sec('nontrapping-fptoint', True)
10294
10300
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)
10301
10308
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)
10304
10312
10305
10313
def test_js_preprocess(self):
10306
10314
# 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):
12850
12858
self.assertExists('profile.data')
12851
12859
12852
12860
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']
12854
12862
if jspi:
12855
12863
wasm_split_run += ['--jspi', '--enable-reference-types']
12856
12864
self.run_process(wasm_split_run)
0 commit comments