diff options
author | Alon Zakai <azakai@google.com> | 2019-11-15 16:53:35 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-15 16:53:35 -0800 |
commit | 28dfa0e0238bc0bdb3958e3884e45189ec34e47a (patch) | |
tree | 62fec5280a5cb4560aab0e478e2682d4d6a00032 /src | |
parent | 89530ffd9a1b2d0b07bd9f0b91a96665afca3262 (diff) | |
download | binaryen-28dfa0e0238bc0bdb3958e3884e45189ec34e47a.tar.gz binaryen-28dfa0e0238bc0bdb3958e3884e45189ec34e47a.tar.bz2 binaryen-28dfa0e0238bc0bdb3958e3884e45189ec34e47a.zip |
Warning improvements (#2438)
If wasm-opt is run with no passes, warn, as we've gotten reports that people
assume a tool called "wasm-opt" should optimize automatically (but we follow
llvm's opt convention of not doing so).
Add a --quiet (-q) flag that suppresses this minor warning, and the other minor
warning where there is no output file.
Diffstat (limited to 'src')
-rw-r--r-- | src/tools/tool-options.h | 11 | ||||
-rw-r--r-- | src/tools/wasm-opt.cpp | 10 |
2 files changed, 17 insertions, 4 deletions
diff --git a/src/tools/tool-options.h b/src/tools/tool-options.h index 33a631975..46720d203 100644 --- a/src/tools/tool-options.h +++ b/src/tools/tool-options.h @@ -22,7 +22,7 @@ #include "support/command-line.h" // -// Shared optimization options for commandline tools +// Shared options for commandline tools // namespace wasm { @@ -30,6 +30,8 @@ namespace wasm { struct ToolOptions : public Options { PassOptions passOptions; + bool quiet = false; + ToolOptions(const std::string& command, const std::string& description) : Options(command, description) { (*this) @@ -60,7 +62,12 @@ struct ToolOptions : public Options { detectFeatures = true; enabledFeatures.makeMVP(); disabledFeatures.makeMVP(); - }); + }) + .add("--quiet", + "-q", + "Emit less verbose output and hide trivial warnings.", + Arguments::Zero, + [this](Options*, const std::string&) { quiet = true; }); (*this) .addFeature(FeatureSet::SignExt, "sign extension operations") .addFeature(FeatureSet::Atomics, "atomic operations") diff --git a/src/tools/wasm-opt.cpp b/src/tools/wasm-opt.cpp index 33e9a0396..b2d1f2c14 100644 --- a/src/tools/wasm-opt.cpp +++ b/src/tools/wasm-opt.cpp @@ -318,7 +318,11 @@ int main(int argc, const char* argv[]) { curr = &other; } - if (options.runningPasses()) { + if (!options.runningPasses()) { + if (!options.quiet) { + std::cerr << "warning: no passes specified, not doing any work\n"; + } + } else { if (options.debug) { std::cerr << "running passes...\n"; } @@ -363,7 +367,9 @@ int main(int argc, const char* argv[]) { } if (options.extra.count("output") == 0) { - std::cerr << "no output file specified, not emitting output\n"; + if (!options.quiet) { + std::cerr << "warning: no output file specified, not emitting output\n"; + } return 0; } |