diff options
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/tool-options.h | 30 | ||||
-rw-r--r-- | src/tools/wasm-as.cpp | 3 | ||||
-rw-r--r-- | src/tools/wasm-ctor-eval.cpp | 3 | ||||
-rw-r--r-- | src/tools/wasm-dis.cpp | 3 | ||||
-rw-r--r-- | src/tools/wasm-emscripten-finalize.cpp | 3 | ||||
-rw-r--r-- | src/tools/wasm-metadce.cpp | 3 | ||||
-rw-r--r-- | src/tools/wasm-opt.cpp | 4 | ||||
-rw-r--r-- | src/tools/wasm-split.cpp | 2 |
8 files changed, 11 insertions, 40 deletions
diff --git a/src/tools/tool-options.h b/src/tools/tool-options.h index 350b7babd..0c40721d3 100644 --- a/src/tools/tool-options.h +++ b/src/tools/tool-options.h @@ -41,7 +41,6 @@ struct ToolOptions : public Options { "Disable all non-MVP features", Arguments::Zero, [this](Options*, const std::string&) { - hasFeatureOptions = true; enabledFeatures.setMVP(); disabledFeatures.setAll(); }) @@ -50,20 +49,14 @@ struct ToolOptions : public Options { "Enable all features", Arguments::Zero, [this](Options*, const std::string&) { - hasFeatureOptions = true; enabledFeatures.setAll(); disabledFeatures.setMVP(); }) .add("--detect-features", "", - "Use features from the target features section, or MVP (default)", + "(deprecated - this flag does nothing)", Arguments::Zero, - [this](Options*, const std::string&) { - hasFeatureOptions = true; - detectFeatures = true; - enabledFeatures.setMVP(); - disabledFeatures.setMVP(); - }) + [](Options*, const std::string&) {}) .add("--quiet", "-q", "Emit less verbose output and hide trivial warnings.", @@ -134,7 +127,6 @@ struct ToolOptions : public Options { std::string("Enable ") + description, Arguments::Zero, [=](Options*, const std::string&) { - hasFeatureOptions = true; enabledFeatures.set(feature, true); disabledFeatures.set(feature, false); }) @@ -144,7 +136,6 @@ struct ToolOptions : public Options { std::string("Disable ") + description, Arguments::Zero, [=](Options*, const std::string&) { - hasFeatureOptions = true; enabledFeatures.set(feature, false); disabledFeatures.set(feature, true); }); @@ -152,24 +143,11 @@ struct ToolOptions : public Options { } void applyFeatures(Module& module) const { - if (hasFeatureOptions) { - if (!detectFeatures && module.hasFeaturesSection) { - FeatureSet optionsFeatures = FeatureSet::MVP; - optionsFeatures.enable(enabledFeatures); - optionsFeatures.disable(disabledFeatures); - if (!(module.features <= optionsFeatures)) { - Fatal() << "features section is not a subset of specified features. " - << "Use --detect-features to resolve."; - } - } - module.features.enable(enabledFeatures); - module.features.disable(disabledFeatures); - } + module.features.enable(enabledFeatures); + module.features.disable(disabledFeatures); } private: - bool hasFeatureOptions = false; - bool detectFeatures = false; FeatureSet enabledFeatures = FeatureSet::MVP; FeatureSet disabledFeatures = FeatureSet::MVP; }; diff --git a/src/tools/wasm-as.cpp b/src/tools/wasm-as.cpp index be18ed355..2b854a2a0 100644 --- a/src/tools/wasm-as.cpp +++ b/src/tools/wasm-as.cpp @@ -99,6 +99,7 @@ int main(int argc, const char* argv[]) { auto input(read_file<std::string>(options.extra["infile"], Flags::Text)); Module wasm; + options.applyFeatures(wasm); try { if (options.debug) { @@ -115,8 +116,6 @@ int main(int argc, const char* argv[]) { Fatal() << "error in parsing input"; } - options.applyFeatures(wasm); - if (options.extra["validate"] != "none") { if (options.debug) { std::cerr << "Validating..." << std::endl; diff --git a/src/tools/wasm-ctor-eval.cpp b/src/tools/wasm-ctor-eval.cpp index bd370a58a..04ef10f57 100644 --- a/src/tools/wasm-ctor-eval.cpp +++ b/src/tools/wasm-ctor-eval.cpp @@ -549,6 +549,7 @@ int main(int argc, const char* argv[]) { auto input(read_file<std::string>(options.extra["infile"], Flags::Text)); Module wasm; + options.applyFeatures(wasm); { if (options.debug) { @@ -563,8 +564,6 @@ int main(int argc, const char* argv[]) { } } - options.applyFeatures(wasm); - if (!WasmValidator().validate(wasm)) { std::cout << wasm << '\n'; Fatal() << "error in validating input"; diff --git a/src/tools/wasm-dis.cpp b/src/tools/wasm-dis.cpp index fc07b771d..cca87514a 100644 --- a/src/tools/wasm-dis.cpp +++ b/src/tools/wasm-dis.cpp @@ -60,6 +60,7 @@ int main(int argc, const char* argv[]) { std::cerr << "parsing binary..." << std::endl; } Module wasm; + options.applyFeatures(wasm); try { ModuleReader().readBinary(options.extra["infile"], wasm, sourceMapFilename); } catch (ParseException& p) { @@ -72,8 +73,6 @@ int main(int argc, const char* argv[]) { Fatal() << "error in parsing wasm source mapping"; } - options.applyFeatures(wasm); - // TODO: Validation. However, validating would mean that users are forced to // run with wasm-dis -all or such, to enable the features (unless the // features section is present, but that's rare in general). It would be diff --git a/src/tools/wasm-emscripten-finalize.cpp b/src/tools/wasm-emscripten-finalize.cpp index c69ec9bb5..4caa62b08 100644 --- a/src/tools/wasm-emscripten-finalize.cpp +++ b/src/tools/wasm-emscripten-finalize.cpp @@ -209,6 +209,7 @@ int main(int argc, const char* argv[]) { auto writeOutput = outfile.size() > 0 || !emitBinary; Module wasm; + options.applyFeatures(wasm); ModuleReader reader; // If we are not writing output then we definitely don't need to read debug // info, as it does not affect the metadata we will emit. (However, if we @@ -239,8 +240,6 @@ int main(int argc, const char* argv[]) { Fatal() << "error in parsing wasm source map"; } - options.applyFeatures(wasm); - BYN_TRACE_WITH_TYPE("emscripten-dump", "Module before:\n"); BYN_DEBUG_WITH_TYPE("emscripten-dump", std::cerr << &wasm); diff --git a/src/tools/wasm-metadce.cpp b/src/tools/wasm-metadce.cpp index 29ac01f90..026b6ad32 100644 --- a/src/tools/wasm-metadce.cpp +++ b/src/tools/wasm-metadce.cpp @@ -504,6 +504,7 @@ int main(int argc, const char* argv[]) { auto input(read_file<std::string>(options.extra["infile"], Flags::Text)); Module wasm; + options.applyFeatures(wasm); { if (options.debug) { @@ -519,8 +520,6 @@ int main(int argc, const char* argv[]) { } } - options.applyFeatures(wasm); - if (options.passOptions.validate) { if (!WasmValidator().validate(wasm)) { std::cout << wasm << '\n'; diff --git a/src/tools/wasm-opt.cpp b/src/tools/wasm-opt.cpp index 45d394162..5aa0c374a 100644 --- a/src/tools/wasm-opt.cpp +++ b/src/tools/wasm-opt.cpp @@ -217,6 +217,7 @@ int main(int argc, const char* argv[]) { options.parse(argc, argv); Module wasm; + options.applyFeatures(wasm); BYN_TRACE("reading...\n"); @@ -259,8 +260,6 @@ int main(int argc, const char* argv[]) { "request for silly amounts of memory)"; } - options.applyFeatures(wasm); - if (options.passOptions.validate) { if (!WasmValidator().validate(wasm)) { exitOnInvalidWasm("error validating input"); @@ -268,7 +267,6 @@ int main(int argc, const char* argv[]) { } } if (translateToFuzz) { - options.applyFeatures(wasm); TranslateToFuzzReader reader(wasm, options.extra["infile"]); if (fuzzPasses) { reader.pickPasses(options); diff --git a/src/tools/wasm-split.cpp b/src/tools/wasm-split.cpp index 261c62a68..6d4e8ed5c 100644 --- a/src/tools/wasm-split.cpp +++ b/src/tools/wasm-split.cpp @@ -396,6 +396,7 @@ void WasmSplitOptions::parse(int argc, const char* argv[]) { } void parseInput(Module& wasm, const WasmSplitOptions& options) { + options.applyFeatures(wasm); ModuleReader reader; reader.setProfile(options.profile); try { @@ -408,7 +409,6 @@ void parseInput(Module& wasm, const WasmSplitOptions& options) { Fatal() << "error building module, std::bad_alloc (possibly invalid " "request for silly amounts of memory)"; } - options.applyFeatures(wasm); if (options.passOptions.validate && !WasmValidator().validate(wasm)) { Fatal() << "error validating input"; |