diff options
-rw-r--r-- | src/tools/tool-options.h | 4 | ||||
-rw-r--r-- | test/unit/test_features.py | 9 |
2 files changed, 10 insertions, 3 deletions
diff --git a/src/tools/tool-options.h b/src/tools/tool-options.h index 70ce4efc0..bc768c1da 100644 --- a/src/tools/tool-options.h +++ b/src/tools/tool-options.h @@ -148,8 +148,8 @@ struct ToolOptions : public Options { FeatureSet optionsFeatures = FeatureSet::MVP; optionsFeatures.enable(enabledFeatures); optionsFeatures.disable(disabledFeatures); - if (module.features != optionsFeatures) { - Fatal() << "module features do not match specified features. " + if (!(module.features <= optionsFeatures)) { + Fatal() << "features section is not a subset of specified features. " << "Use --detect-features to resolve."; } } diff --git a/test/unit/test_features.py b/test/unit/test_features.py index 7eb814e39..9c3b20ed7 100644 --- a/test/unit/test_features.py +++ b/test/unit/test_features.py @@ -349,6 +349,13 @@ class TargetFeaturesSectionTest(utils.BinaryenTestCase): self.assertIn('anyref', disassembly) self.assertIn('eqref', disassembly) + def test_superset(self): + # It is ok to enable additional features past what is in the section. + shared.run_process( + shared.WASM_OPT + ['--print', '--detect-features', '-mvp', + '--enable-simd', '--enable-sign-ext', + self.input_path('signext_target_feature.wasm')]) + def test_incompatible_features(self): path = self.input_path('signext_target_feature.wasm') p = shared.run_process( @@ -357,7 +364,7 @@ class TargetFeaturesSectionTest(utils.BinaryenTestCase): check=False, capture_output=True ) self.assertNotEqual(p.returncode, 0) - self.assertIn('Fatal: module features do not match specified features. ' + + self.assertIn('Fatal: features section is not a subset of specified features. ' + 'Use --detect-features to resolve.', p.stderr) |