@@ -10265,6 +10265,30 @@ def test_wasm_features_section(self, args):
10265
10265
self.run_process([EMCC, test_file('hello_world.c'), '-O2'] + args)
10266
10266
self.verify_custom_sec_existence('a.out.wasm', 'target_features', False)
10267
10267
10268
+ def test_wasm_features(self):
10269
+ # Test that wasm features are explicitly enabled or disabled based on target engine version
10270
+ def verify_features_sec(feature, expect_in):
10271
+ with webassembly.Module('hello_world.o') as module:
10272
+ features = module.get_target_features()
10273
+ if expect_in:
10274
+ self.assertTrue(feature in features and features[feature] == webassembly.TargetFeaturePrefix.USED)
10275
+ else:
10276
+ self.assertFalse(feature in features)
10277
+
10278
+ def compile(flag):
10279
+ self.run_process([EMCC, test_file('hello_world.c'), '-c', flag])
10280
+
10281
+ compile('')
10282
+ verify_features_sec('bulk-memory', False)
10283
+ verify_features_sec('nontrapping-fptoint', False)
10284
+ verify_features_sec('sign-ext', True)
10285
+ verify_features_sec('mutable-globals', True)
10286
+ verify_features_sec('multivalue', True)
10287
+
10288
+ compile('-sMIN_SAFARI_VERSION=150000')
10289
+ verify_features_sec('bulk-memory', True)
10290
+ verify_features_sec('nontrapping-fptoint', True)
10291
+
10268
10292
def test_js_preprocess(self):
10269
10293
# Use stderr rather than stdout here because stdout is redirected to the output JS file itself.
10270
10294
create_file('lib.js', '''
0 commit comments