diff options
author | Alon Zakai <azakai@google.com> | 2021-01-15 19:42:11 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-15 11:42:11 -0800 |
commit | c57dd1ff777b04650e4603a043644a2519019665 (patch) | |
tree | e5b5e6d70bb7f745c47961a2d25ba59abaf5bc64 /src | |
parent | e2dc4c338476aedff8d95c7549ab0f39d1aaf6d1 (diff) | |
download | binaryen-c57dd1ff777b04650e4603a043644a2519019665.tar.gz binaryen-c57dd1ff777b04650e4603a043644a2519019665.tar.bz2 binaryen-c57dd1ff777b04650e4603a043644a2519019665.zip |
wasm-reduce: default to -all, and make it customizable (#3492)
This goes back to the downsides of #2813, but that seems unavoidable
as without this, testcases without the features section but that use features
did not work.
This PR at least makes it easy to customize the flags send to the commands.
See also #3393 (comment)
Diffstat (limited to 'src')
-rw-r--r-- | src/tools/wasm-reduce.cpp | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/src/tools/wasm-reduce.cpp b/src/tools/wasm-reduce.cpp index a6bf238fc..0332b4712 100644 --- a/src/tools/wasm-reduce.cpp +++ b/src/tools/wasm-reduce.cpp @@ -71,8 +71,12 @@ std::string GetLastErrorStdStr() { #endif using namespace wasm; -// a timeout on every execution of the command -size_t timeout = 2; +// A timeout on every execution of the command. +static size_t timeout = 2; + +// A string of feature flags and other things to pass while reducing. The +// default of enabling all features should work in most cases. +static std::string extraFlags = "-all"; struct ProgramResult { int code; @@ -282,14 +286,12 @@ struct Reducer // compensated for), and without for (auto pass : passes) { std::string currCommand = Path::getBinaryenBinaryTool("wasm-opt") + " "; - currCommand += working + " --detect-features -o " + test + " " + pass; + currCommand += working + " -o " + test + " " + pass + " " + extraFlags; if (debugInfo) { currCommand += " -g "; } if (!binary) { - currCommand += " -S --all-features "; - } else { - currCommand += " --detect-features "; + currCommand += " -S "; } if (verbose) { std::cerr << "| trying pass command: " << currCommand << "\n"; @@ -1153,6 +1155,15 @@ int main(int argc, const char* argv[]) { timeout = atoi(argument.c_str()); std::cout << "|applying timeout: " << timeout << "\n"; }) + .add("--extra-flags", + "-ef", + "Extra commandline flags to pass to wasm-opt while reducing. " + "(default: --enable-all)", + Options::Arguments::One, + [&](Options* o, const std::string& argument) { + extraFlags = argument; + std::cout << "|applying extraFlags: " << extraFlags << "\n"; + }) .add_positional( "INFILE", Options::Arguments::One, @@ -1230,12 +1241,10 @@ int main(int argc, const char* argv[]) { "(read-written) binary\n"; { // read and write it - auto cmd = - Path::getBinaryenBinaryTool("wasm-opt") + " " + input + " -o " + test; + auto cmd = Path::getBinaryenBinaryTool("wasm-opt") + " " + input + " -o " + + test + " " + extraFlags; if (!binary) { - cmd += " -S --all-features"; - } else { - cmd += " --detect-features"; + cmd += " -S "; } ProgramResult readWrite(cmd); if (readWrite.failed()) { |