summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2022-01-05 11:42:13 -0800
committerGitHub <noreply@github.com>2022-01-05 11:42:13 -0800
commit16c9b3042d925270d1536429a239261b5a7df9b8 (patch)
tree4c27cdfa36afbb6e66f69b7dab4292aa76926ea9 /src
parent79f76987ca899241a3f45d61e9b7964bcffb31a1 (diff)
downloadbinaryen-16c9b3042d925270d1536429a239261b5a7df9b8.tar.gz
binaryen-16c9b3042d925270d1536429a239261b5a7df9b8.tar.bz2
binaryen-16c9b3042d925270d1536429a239261b5a7df9b8.zip
Add categories to --help text (#4421)
The general shape of the --help output is now: ======================== wasm-foo Does the foo operation ======================== wasm-foo opts: -------------- --foo-bar .. Tool opts: ---------- .. The options are now in categories, with the more specific ones - most likely to be wanted by the user - first. I think this makes the list a lot less confusing. In particular, in wasm-opt all the opt passes are now in their own category. Also add a script to make it easy to update the help tests.
Diffstat (limited to 'src')
-rw-r--r--src/support/command-line.cpp54
-rw-r--r--src/support/command-line.h5
-rw-r--r--src/tools/optimization-options.h26
-rw-r--r--src/tools/tool-options.h13
-rw-r--r--src/tools/wasm-as.cpp9
-rw-r--r--src/tools/wasm-ctor-eval.cpp6
-rw-r--r--src/tools/wasm-dis.cpp5
-rw-r--r--src/tools/wasm-emscripten-finalize.cpp22
-rw-r--r--src/tools/wasm-fuzz-types.cpp6
-rw-r--r--src/tools/wasm-metadce.cpp7
-rw-r--r--src/tools/wasm-opt.cpp19
-rw-r--r--src/tools/wasm-reduce.cpp14
-rw-r--r--src/tools/wasm-shell.cpp4
-rw-r--r--src/tools/wasm-split/split-options.cpp28
-rw-r--r--src/tools/wasm-split/split-options.h2
-rw-r--r--src/tools/wasm2js.cpp9
16 files changed, 216 insertions, 13 deletions
diff --git a/src/support/command-line.cpp b/src/support/command-line.cpp
index c84474259..0147f9044 100644
--- a/src/support/command-line.cpp
+++ b/src/support/command-line.cpp
@@ -53,26 +53,38 @@ void printWrap(std::ostream& os, int leftPad, const std::string& content) {
Options::Options(const std::string& command, const std::string& description)
: debug(false), positional(Arguments::Zero) {
+ std::string GeneralOption = "General options";
+
add("--version",
"",
"Output version information and exit",
+ GeneralOption,
Arguments::Zero,
[command](Options*, const std::string&) {
- std::cout << command << " version " << PROJECT_VERSION << "\n";
+ std::cout << command << " version " << PROJECT_VERSION << '\n';
exit(0);
});
add("--help",
"-h",
"Show this help message and exit",
+ GeneralOption,
Arguments::Zero,
[this, command, description](Options* o, const std::string&) {
+ for (size_t i = 0; i < SCREEN_WIDTH; i++) {
+ std::cout << '=';
+ }
+ std::cout << '\n';
std::cout << command;
if (positional != Arguments::Zero) {
std::cout << ' ' << positionalName;
}
std::cout << "\n\n";
printWrap(std::cout, 0, description);
- std::cout << "\n\nOptions:\n";
+ std::cout << '\n';
+ for (size_t i = 0; i < SCREEN_WIDTH; i++) {
+ std::cout << '=';
+ }
+ std::cout << '\n';
size_t optionWidth = 0;
for (const auto& o : options) {
if (o.hidden) {
@@ -81,17 +93,27 @@ Options::Options(const std::string& command, const std::string& description)
optionWidth =
std::max(optionWidth, o.longName.size() + o.shortName.size());
}
- for (const auto& o : options) {
- if (o.hidden) {
- continue;
+ for (int i = int(categories.size()) - 1; i >= 0; i--) {
+ auto& category = categories[i];
+ std::cout << "\n\n" << category << ":\n";
+ for (size_t i = 0; i < category.size() + 1; i++) {
+ std::cout << '-';
}
std::cout << '\n';
- bool long_n_short = o.longName.size() != 0 && o.shortName.size() != 0;
- size_t pad = 1 + optionWidth - o.longName.size() - o.shortName.size();
- std::cout << " " << o.longName << (long_n_short ? ',' : ' ')
- << o.shortName << std::string(pad, ' ');
- printWrap(std::cout, optionWidth + 4, o.description);
- std::cout << '\n';
+ for (const auto& o : options) {
+ if (o.hidden || o.category != category) {
+ continue;
+ }
+ std::cout << '\n';
+ bool long_n_short =
+ o.longName.size() != 0 && o.shortName.size() != 0;
+ size_t pad =
+ 1 + optionWidth - o.longName.size() - o.shortName.size();
+ std::cout << " " << o.longName << (long_n_short ? ',' : ' ')
+ << o.shortName << std::string(pad, ' ');
+ printWrap(std::cout, optionWidth + 4, o.description);
+ std::cout << '\n';
+ }
}
std::cout << '\n';
exit(EXIT_SUCCESS);
@@ -99,6 +121,7 @@ Options::Options(const std::string& command, const std::string& description)
add("--debug",
"-d",
"Print debug information to stderr",
+ GeneralOption,
Arguments::Optional,
[&](Options* o, const std::string& arguments) {
debug = true;
@@ -111,11 +134,18 @@ Options::~Options() {}
Options& Options::add(const std::string& longName,
const std::string& shortName,
const std::string& description,
+ const std::string& category,
Arguments arguments,
const Action& action,
bool hidden) {
options.push_back(
- {longName, shortName, description, arguments, action, hidden, 0});
+ {longName, shortName, description, category, arguments, action, hidden, 0});
+
+ if (std::find(categories.begin(), categories.end(), category) ==
+ categories.end()) {
+ categories.push_back(category);
+ }
+
return *this;
}
diff --git a/src/support/command-line.h b/src/support/command-line.h
index 19b2546d9..354bbb586 100644
--- a/src/support/command-line.h
+++ b/src/support/command-line.h
@@ -56,6 +56,7 @@ public:
Options& add(const std::string& longName,
const std::string& shortName,
const std::string& description,
+ const std::string& category,
Arguments arguments,
const Action& action,
bool hidden = false);
@@ -69,6 +70,7 @@ private:
std::string longName;
std::string shortName;
std::string description;
+ std::string category;
Arguments arguments;
Action action;
bool hidden;
@@ -78,6 +80,9 @@ private:
Arguments positional;
std::string positionalName;
Action positionalAction;
+
+ // The category names, in the order in which help will be printed.
+ std::vector<std::string> categories;
};
} // namespace wasm
diff --git a/src/tools/optimization-options.h b/src/tools/optimization-options.h
index f1872bf3d..ca555d5e9 100644
--- a/src/tools/optimization-options.h
+++ b/src/tools/optimization-options.h
@@ -30,6 +30,9 @@ struct OptimizationOptions : public ToolOptions {
std::vector<std::string> passes;
+ constexpr static const char* OptimizationOptionsCategory =
+ "Optimization options";
+
OptimizationOptions(const std::string& command,
const std::string& description)
: ToolOptions(command, description) {
@@ -37,6 +40,7 @@ struct OptimizationOptions : public ToolOptions {
.add("",
"-O",
"execute default optimization passes",
+ OptimizationOptionsCategory,
Options::Arguments::Zero,
[this](Options*, const std::string&) {
passOptions.setDefaultOptimizationOptions();
@@ -45,6 +49,7 @@ struct OptimizationOptions : public ToolOptions {
.add("",
"-O0",
"execute no optimization passes",
+ OptimizationOptionsCategory,
Options::Arguments::Zero,
[this](Options*, const std::string&) {
passOptions.optimizeLevel = 0;
@@ -54,6 +59,7 @@ struct OptimizationOptions : public ToolOptions {
"-O1",
"execute -O1 optimization passes (quick&useful opts, useful for "
"iteration builds)",
+ OptimizationOptionsCategory,
Options::Arguments::Zero,
[this](Options*, const std::string&) {
passOptions.optimizeLevel = 1;
@@ -64,6 +70,7 @@ struct OptimizationOptions : public ToolOptions {
"",
"-O2",
"execute -O2 optimization passes (most opts, generally gets most perf)",
+ OptimizationOptionsCategory,
Options::Arguments::Zero,
[this](Options*, const std::string&) {
passOptions.optimizeLevel = 2;
@@ -74,6 +81,7 @@ struct OptimizationOptions : public ToolOptions {
"-O3",
"execute -O3 optimization passes (spends potentially a lot of time "
"optimizing)",
+ OptimizationOptionsCategory,
Options::Arguments::Zero,
[this](Options*, const std::string&) {
passOptions.optimizeLevel = 3;
@@ -85,6 +93,7 @@ struct OptimizationOptions : public ToolOptions {
"execute -O4 optimization passes (also flatten the IR, which can "
"take a lot more time and memory, but is useful on more nested / "
"complex / less-optimized input)",
+ OptimizationOptionsCategory,
Options::Arguments::Zero,
[this](Options*, const std::string&) {
passOptions.optimizeLevel = 4;
@@ -94,6 +103,7 @@ struct OptimizationOptions : public ToolOptions {
.add("",
"-Os",
"execute default optimization passes, focusing on code size",
+ OptimizationOptionsCategory,
Options::Arguments::Zero,
[this](Options*, const std::string&) {
passOptions.optimizeLevel = 2;
@@ -103,6 +113,7 @@ struct OptimizationOptions : public ToolOptions {
.add("",
"-Oz",
"execute default optimization passes, super-focusing on code size",
+ OptimizationOptionsCategory,
Options::Arguments::Zero,
[this](Options*, const std::string&) {
passOptions.optimizeLevel = 2;
@@ -112,6 +123,7 @@ struct OptimizationOptions : public ToolOptions {
.add("--optimize-level",
"-ol",
"How much to focus on optimizing code",
+ OptimizationOptionsCategory,
Options::Arguments::One,
[this](Options* o, const std::string& argument) {
passOptions.optimizeLevel = atoi(argument.c_str());
@@ -119,6 +131,7 @@ struct OptimizationOptions : public ToolOptions {
.add("--shrink-level",
"-s",
"How much to focus on shrinking code size",
+ OptimizationOptionsCategory,
Options::Arguments::One,
[this](Options* o, const std::string& argument) {
passOptions.shrinkLevel = atoi(argument.c_str());
@@ -126,6 +139,7 @@ struct OptimizationOptions : public ToolOptions {
.add("--debuginfo",
"-g",
"Emit names section in wasm binary (or full debuginfo in wast)",
+ OptimizationOptionsCategory,
Options::Arguments::Zero,
[&](Options* o, const std::string& arguments) {
passOptions.debugInfo = true;
@@ -136,6 +150,7 @@ struct OptimizationOptions : public ToolOptions {
std::to_string(InliningOptions().alwaysInlineMaxSize) +
", which "
"is safe for use with -Os builds)",
+ OptimizationOptionsCategory,
Options::Arguments::One,
[this](Options* o, const std::string& argument) {
passOptions.inlining.alwaysInlineMaxSize =
@@ -147,6 +162,7 @@ struct OptimizationOptions : public ToolOptions {
"or function calls) when optimizing aggressively for speed (-O3). "
"Default: " +
std::to_string(InliningOptions().flexibleInlineMaxSize),
+ OptimizationOptionsCategory,
Options::Arguments::One,
[this](Options* o, const std::string& argument) {
passOptions.inlining.flexibleInlineMaxSize =
@@ -156,6 +172,7 @@ struct OptimizationOptions : public ToolOptions {
"-ocimfs",
"Max size of functions that are inlined when there is only one "
"caller (default -1, which means all such functions are inlined)",
+ OptimizationOptionsCategory,
Options::Arguments::One,
[this](Options* o, const std::string& argument) {
static_assert(InliningOptions().oneCallerInlineMaxSize ==
@@ -167,6 +184,7 @@ struct OptimizationOptions : public ToolOptions {
.add("--inline-functions-with-loops",
"-ifwl",
"Allow inlining functions with loops",
+ OptimizationOptionsCategory,
Options::Arguments::Zero,
[this](Options* o, const std::string&) {
passOptions.inlining.allowFunctionsWithLoops = true;
@@ -176,6 +194,7 @@ struct OptimizationOptions : public ToolOptions {
"Number of ifs allowed in partial inlining (zero means partial "
"inlining is disabled) (default: " +
std::to_string(InliningOptions().partialInliningIfs) + ')',
+ OptimizationOptionsCategory,
Options::Arguments::One,
[this](Options* o, const std::string& argument) {
passOptions.inlining.partialInliningIfs =
@@ -185,6 +204,7 @@ struct OptimizationOptions : public ToolOptions {
"-iit",
"Optimize under the helpful assumption that no surprising traps "
"occur (from load, div/mod, etc.)",
+ OptimizationOptionsCategory,
Options::Arguments::Zero,
[this](Options*, const std::string&) {
passOptions.ignoreImplicitTraps = true;
@@ -193,6 +213,7 @@ struct OptimizationOptions : public ToolOptions {
"-tnh",
"Optimize under the helpful assumption that no trap is reached at "
"runtime (from load, div/mod, etc.)",
+ OptimizationOptionsCategory,
Options::Arguments::Zero,
[this](Options*, const std::string&) {
passOptions.trapsNeverHappen = true;
@@ -201,6 +222,7 @@ struct OptimizationOptions : public ToolOptions {
"-lmu",
"Optimize under the helpful assumption that the low 1K of memory is "
"not used by the application",
+ OptimizationOptionsCategory,
Options::Arguments::Zero,
[this](Options*, const std::string&) {
passOptions.lowMemoryUnused = true;
@@ -209,21 +231,25 @@ struct OptimizationOptions : public ToolOptions {
"--fast-math",
"-ffm",
"Optimize floats without handling corner cases of NaNs and rounding",
+ OptimizationOptionsCategory,
Options::Arguments::Zero,
[this](Options*, const std::string&) { passOptions.fastMath = true; })
.add("--zero-filled-memory",
"-uim",
"Assume that an imported memory will be zero-initialized",
+ OptimizationOptionsCategory,
Options::Arguments::Zero,
[this](Options*, const std::string&) {
passOptions.zeroFilledMemory = true;
});
+
// add passes in registry
for (const auto& p : PassRegistry::get()->getRegisteredNames()) {
(*this).add(
std::string("--") + p,
"",
PassRegistry::get()->getPassDescription(p),
+ "Optimization passes",
// Allow an optional parameter to a pass. If provided, it is
// the same as if using --pass-arg, that is,
//
diff --git a/src/tools/tool-options.h b/src/tools/tool-options.h
index a73d72d09..f45569648 100644
--- a/src/tools/tool-options.h
+++ b/src/tools/tool-options.h
@@ -33,12 +33,15 @@ struct ToolOptions : public Options {
bool quiet = false;
IRProfile profile = IRProfile::Normal;
+ constexpr static const char* ToolOptionsCategory = "Tool options";
+
ToolOptions(const std::string& command, const std::string& description)
: Options(command, description) {
(*this)
.add("--mvp-features",
"-mvp",
"Disable all non-MVP features",
+ ToolOptionsCategory,
Arguments::Zero,
[this](Options*, const std::string&) {
enabledFeatures.setMVP();
@@ -47,6 +50,7 @@ struct ToolOptions : public Options {
.add("--all-features",
"-all",
"Enable all features",
+ ToolOptionsCategory,
Arguments::Zero,
[this](Options*, const std::string&) {
enabledFeatures.setAll();
@@ -55,17 +59,20 @@ struct ToolOptions : public Options {
.add("--detect-features",
"",
"(deprecated - this flag does nothing)",
+ ToolOptionsCategory,
Arguments::Zero,
[](Options*, const std::string&) {})
.add("--quiet",
"-q",
"Emit less verbose output and hide trivial warnings.",
+ ToolOptionsCategory,
Arguments::Zero,
[this](Options*, const std::string&) { quiet = true; })
.add(
"--experimental-poppy",
"",
"Parse wast files as Poppy IR for testing purposes.",
+ ToolOptionsCategory,
Arguments::Zero,
[this](Options*, const std::string&) { profile = IRProfile::Poppy; });
(*this)
@@ -89,6 +96,7 @@ struct ToolOptions : public Options {
.add("--no-validation",
"-n",
"Disables validation, assumes inputs are correct",
+ ToolOptionsCategory,
Options::Arguments::Zero,
[this](Options* o, const std::string& argument) {
passOptions.validate = false;
@@ -97,6 +105,7 @@ struct ToolOptions : public Options {
"-pa",
"An argument passed along to optimization passes being run. Must be "
"in the form KEY@VALUE",
+ ToolOptionsCategory,
Options::Arguments::N,
[this](Options*, const std::string& argument) {
std::string key, value;
@@ -113,6 +122,7 @@ struct ToolOptions : public Options {
.add("--nominal",
"",
"Force all GC type definitions to be parsed as nominal.",
+ ToolOptionsCategory,
Options::Arguments::Zero,
[](Options* o, const std::string& argument) {
setTypeSystem(TypeSystem::Nominal);
@@ -121,6 +131,7 @@ struct ToolOptions : public Options {
"",
"Force all GC type definitions to be parsed as structural "
"(i.e. equirecursive). This is the default.",
+ ToolOptionsCategory,
Options::Arguments::Zero,
[](Options* o, const std::string& argument) {
setTypeSystem(TypeSystem::Equirecursive);
@@ -133,6 +144,7 @@ struct ToolOptions : public Options {
.add(std::string("--enable-") + FeatureSet::toString(feature),
"",
std::string("Enable ") + description,
+ ToolOptionsCategory,
Arguments::Zero,
[=](Options*, const std::string&) {
enabledFeatures.set(feature, true);
@@ -142,6 +154,7 @@ struct ToolOptions : public Options {
.add(std::string("--disable-") + FeatureSet::toString(feature),
"",
std::string("Disable ") + description,
+ ToolOptionsCategory,
Arguments::Zero,
[=](Options*, const std::string&) {
enabledFeatures.set(feature, false);
diff --git a/src/tools/wasm-as.cpp b/src/tools/wasm-as.cpp
index 2b854a2a0..382692273 100644
--- a/src/tools/wasm-as.cpp
+++ b/src/tools/wasm-as.cpp
@@ -35,6 +35,9 @@ int main(int argc, const char* argv[]) {
std::string symbolMap;
std::string sourceMapFilename;
std::string sourceMapUrl;
+
+ const std::string WasmAsOption = "wasm-as options";
+
ToolOptions options("wasm-as",
"Assemble a .wat (WebAssembly text format) into a .wasm "
"(WebAssembly binary format)");
@@ -43,6 +46,7 @@ int main(int argc, const char* argv[]) {
.add("--output",
"-o",
"Output file (stdout if not specified)",
+ WasmAsOption,
Options::Arguments::One,
[](Options* o, const std::string& argument) {
o->extra["output"] = argument;
@@ -51,6 +55,7 @@ int main(int argc, const char* argv[]) {
.add("--validate",
"-v",
"Control validation of the output module",
+ WasmAsOption,
Options::Arguments::One,
[](Options* o, const std::string& argument) {
if (argument != "web" && argument != "none" && argument != "wasm") {
@@ -62,11 +67,13 @@ int main(int argc, const char* argv[]) {
.add("--debuginfo",
"-g",
"Emit names section and debug info",
+ WasmAsOption,
Options::Arguments::Zero,
[&](Options* o, const std::string& arguments) { debugInfo = true; })
.add("--source-map",
"-sm",
"Emit source map to the specified file",
+ WasmAsOption,
Options::Arguments::One,
[&sourceMapFilename](Options* o, const std::string& argument) {
sourceMapFilename = argument;
@@ -74,6 +81,7 @@ int main(int argc, const char* argv[]) {
.add("--source-map-url",
"-su",
"Use specified string as source map URL",
+ WasmAsOption,
Options::Arguments::One,
[&sourceMapUrl](Options* o, const std::string& argument) {
sourceMapUrl = argument;
@@ -81,6 +89,7 @@ int main(int argc, const char* argv[]) {
.add("--symbolmap",
"-s",
"Emit a symbol map (indexes => names)",
+ WasmAsOption,
Options::Arguments::One,
[&](Options* o, const std::string& argument) { symbolMap = argument; })
.add_positional("INFILE",
diff --git a/src/tools/wasm-ctor-eval.cpp b/src/tools/wasm-ctor-eval.cpp
index 701968dcd..a44ea3ceb 100644
--- a/src/tools/wasm-ctor-eval.cpp
+++ b/src/tools/wasm-ctor-eval.cpp
@@ -526,12 +526,15 @@ int main(int argc, const char* argv[]) {
bool debugInfo = false;
std::string ctorsString;
+ const std::string WasmCtorEvalOption = "wasm-ctor-eval options";
+
ToolOptions options("wasm-ctor-eval",
"Execute C++ global constructors ahead of time");
options
.add("--output",
"-o",
"Output file (stdout if not specified)",
+ WasmCtorEvalOption,
Options::Arguments::One,
[](Options* o, const std::string& argument) {
o->extra["output"] = argument;
@@ -540,17 +543,20 @@ int main(int argc, const char* argv[]) {
.add("--emit-text",
"-S",
"Emit text instead of binary for the output file",
+ WasmCtorEvalOption,
Options::Arguments::Zero,
[&](Options* o, const std::string& argument) { emitBinary = false; })
.add("--debuginfo",
"-g",
"Emit names section and debug info",
+ WasmCtorEvalOption,
Options::Arguments::Zero,
[&](Options* o, const std::string& arguments) { debugInfo = true; })
.add(
"--ctors",
"-c",
"Comma-separated list of global constructor functions to evaluate",
+ WasmCtorEvalOption,
Options::Arguments::One,
[&](Options* o, const std::string& argument) { ctorsString = argument; })
.add_positional("INFILE",
diff --git a/src/tools/wasm-dis.cpp b/src/tools/wasm-dis.cpp
index cca87514a..b4003b2c8 100644
--- a/src/tools/wasm-dis.cpp
+++ b/src/tools/wasm-dis.cpp
@@ -29,6 +29,9 @@ using namespace wasm;
int main(int argc, const char* argv[]) {
std::string sourceMapFilename;
+
+ const std::string WasmDisOption = "wasm-dis options";
+
ToolOptions options("wasm-dis",
"Un-assemble a .wasm (WebAssembly binary format) into a "
".wat (WebAssembly text format)");
@@ -36,6 +39,7 @@ int main(int argc, const char* argv[]) {
.add("--output",
"-o",
"Output file (stdout if not specified)",
+ WasmDisOption,
Options::Arguments::One,
[](Options* o, const std::string& argument) {
o->extra["output"] = argument;
@@ -45,6 +49,7 @@ int main(int argc, const char* argv[]) {
"--source-map",
"-sm",
"Consume source map from the specified file to add location information",
+ WasmDisOption,
Options::Arguments::One,
[&sourceMapFilename](Options* o, const std::string& argument) {
sourceMapFilename = argument;
diff --git a/src/tools/wasm-emscripten-finalize.cpp b/src/tools/wasm-emscripten-finalize.cpp
index 4caa62b08..392cf14a4 100644
--- a/src/tools/wasm-emscripten-finalize.cpp
+++ b/src/tools/wasm-emscripten-finalize.cpp
@@ -60,12 +60,16 @@ int main(int argc, const char* argv[]) {
bool noDynCalls = false;
bool onlyI64DynCalls = false;
+ const std::string WasmEmscriptenFinalizeOption =
+ "wasm-emscripten-finalize options";
+
ToolOptions options("wasm-emscripten-finalize",
"Performs Emscripten-specific transforms on .wasm files");
options
.add("--output",
"-o",
"Output file",
+ WasmEmscriptenFinalizeOption,
Options::Arguments::One,
[&outfile](Options*, const std::string& argument) {
outfile = argument;
@@ -74,22 +78,26 @@ int main(int argc, const char* argv[]) {
.add("--debuginfo",
"-g",
"Emit names section in wasm binary (or full debuginfo in wast)",
+ WasmEmscriptenFinalizeOption,
Options::Arguments::Zero,
[&debugInfo](Options*, const std::string&) { debugInfo = true; })
.add("--dwarf",
"",
"Update DWARF debug info",
+ WasmEmscriptenFinalizeOption,
Options::Arguments::Zero,
[&DWARF](Options*, const std::string&) { DWARF = true; })
.add("--emit-text",
"-S",
"Emit text instead of binary for the output file. "
"In this mode if no output file is specified, we write to stdout.",
+ WasmEmscriptenFinalizeOption,
Options::Arguments::Zero,
[&emitBinary](Options*, const std::string&) { emitBinary = false; })
.add("--global-base",
"",
"The address at which static globals were placed",
+ WasmEmscriptenFinalizeOption,
Options::Arguments::One,
[&globalBase](Options*, const std::string& argument) {
globalBase = std::stoull(argument);
@@ -99,11 +107,13 @@ int main(int argc, const char* argv[]) {
.add("--initial-stack-pointer",
"",
"ignored - will be removed in a future release",
+ WasmEmscriptenFinalizeOption,
Options::Arguments::One,
[](Options*, const std::string& argument) {})
.add("--side-module",
"",
"Input is an emscripten side module",
+ WasmEmscriptenFinalizeOption,
Options::Arguments::Zero,
[&sideModule](Options* o, const std::string& argument) {
sideModule = true;
@@ -111,11 +121,13 @@ int main(int argc, const char* argv[]) {
.add("--new-pic-abi",
"",
"Use new/llvm PIC abi",
+ WasmEmscriptenFinalizeOption,
Options::Arguments::Zero,
[&](Options* o, const std::string& argument) {})
.add("--input-source-map",
"-ism",
"Consume source map from the specified file",
+ WasmEmscriptenFinalizeOption,
Options::Arguments::One,
[&inputSourceMapFilename](Options* o, const std::string& argument) {
inputSourceMapFilename = argument;
@@ -124,6 +136,7 @@ int main(int argc, const char* argv[]) {
"-nj",
"Do not fully legalize (i64->i32, "
"f32->f64) the imports and exports for interfacing with JS",
+ WasmEmscriptenFinalizeOption,
Options::Arguments::Zero,
[&legalizeJavaScriptFFI](Options* o, const std::string&) {
legalizeJavaScriptFFI = false;
@@ -133,11 +146,13 @@ int main(int argc, const char* argv[]) {
"Assume JS will use wasm/JS BigInt integration, so wasm i64s will "
"turn into JS BigInts, and there is no need for any legalization at "
"all (not even minimal legalization of dynCalls)",
+ WasmEmscriptenFinalizeOption,
Options::Arguments::Zero,
[&bigInt](Options* o, const std::string&) { bigInt = true; })
.add("--output-source-map",
"-osm",
"Emit source map to the specified file",
+ WasmEmscriptenFinalizeOption,
Options::Arguments::One,
[&outputSourceMapFilename](Options* o, const std::string& argument) {
outputSourceMapFilename = argument;
@@ -145,6 +160,7 @@ int main(int argc, const char* argv[]) {
.add("--output-source-map-url",
"-osu",
"Emit specified string as source map URL",
+ WasmEmscriptenFinalizeOption,
Options::Arguments::One,
[&outputSourceMapUrl](Options* o, const std::string& argument) {
outputSourceMapUrl = argument;
@@ -152,6 +168,7 @@ int main(int argc, const char* argv[]) {
.add("--separate-data-segments",
"",
"Separate data segments to a file",
+ WasmEmscriptenFinalizeOption,
Options::Arguments::One,
[&dataSegmentFile](Options* o, const std::string& argument) {
dataSegmentFile = argument;
@@ -159,6 +176,7 @@ int main(int argc, const char* argv[]) {
.add("--check-stack-overflow",
"",
"Check for stack overflows every time the stack is extended",
+ WasmEmscriptenFinalizeOption,
Options::Arguments::Zero,
[&checkStackOverflow](Options* o, const std::string&) {
checkStackOverflow = true;
@@ -167,6 +185,7 @@ int main(int argc, const char* argv[]) {
"",
"Emit a wasm file that does not depend on JS, as much as possible,"
" using wasi and other standard conventions etc. where possible",
+ WasmEmscriptenFinalizeOption,
Options::Arguments::Zero,
[&standaloneWasm](Options* o, const std::string&) {
standaloneWasm = true;
@@ -176,6 +195,7 @@ int main(int argc, const char* argv[]) {
"Modify the wasm as little as possible. This is useful during "
"development as we reduce the number of changes to the wasm, as it "
"lets emscripten control how much modifications to do.",
+ WasmEmscriptenFinalizeOption,
Options::Arguments::Zero,
[&minimizeWasmChanges](Options* o, const std::string&) {
minimizeWasmChanges = true;
@@ -183,11 +203,13 @@ int main(int argc, const char* argv[]) {
.add("--no-dyncalls",
"",
"",
+ WasmEmscriptenFinalizeOption,
Options::Arguments::Zero,
[&noDynCalls](Options* o, const std::string&) { noDynCalls = true; })
.add("--dyncalls-i64",
"",
"",
+ WasmEmscriptenFinalizeOption,
Options::Arguments::Zero,
[&onlyI64DynCalls](Options* o, const std::string&) {
onlyI64DynCalls = true;
diff --git a/src/tools/wasm-fuzz-types.cpp b/src/tools/wasm-fuzz-types.cpp
index 1abeef404..d0baec748 100644
--- a/src/tools/wasm-fuzz-types.cpp
+++ b/src/tools/wasm-fuzz-types.cpp
@@ -140,6 +140,8 @@ struct Fuzzer {
int main(int argc, const char* argv[]) {
using namespace wasm;
+ const std::string WasmFuzzTypesOption = "wasm-fuzz-types options";
+
Options options("wasm-fuzz-types",
"Fuzz type construction, canonicalization, and operations");
@@ -147,6 +149,7 @@ int main(int argc, const char* argv[]) {
options.add("--seed",
"",
"Run a single workload generated by the given seed",
+ WasmFuzzTypesOption,
Options::Arguments::One,
[&](Options*, const std::string& arg) {
seed = uint64_t(std::stoull(arg));
@@ -156,6 +159,7 @@ int main(int argc, const char* argv[]) {
options.add("--verbose",
"-v",
"Print extra information",
+ WasmFuzzTypesOption,
Options::Arguments::Zero,
[&](Options*, const std::string& arg) { verbose = true; });
@@ -164,11 +168,13 @@ int main(int argc, const char* argv[]) {
"--nominal",
"",
"Use the nominal type system (default)",
+ WasmFuzzTypesOption,
Options::Arguments::Zero,
[&](Options*, const std::string& arg) { system = TypeSystem::Nominal; });
options.add("--structural",
"",
"Use the equirecursive type system",
+ WasmFuzzTypesOption,
Options::Arguments::Zero,
[&](Options*, const std::string& arg) {
system = TypeSystem::Equirecursive;
diff --git a/src/tools/wasm-metadce.cpp b/src/tools/wasm-metadce.cpp
index 3a468e071..4b12446f4 100644
--- a/src/tools/wasm-metadce.cpp
+++ b/src/tools/wasm-metadce.cpp
@@ -425,6 +425,8 @@ int main(int argc, const char* argv[]) {
std::string graphFile;
bool dump = false;
+ const std::string WasmMetaDCEOption = "wasm-opt options";
+
ToolOptions options(
"wasm-metadce",
"This tool performs dead code elimination (DCE) on a larger space "
@@ -474,6 +476,7 @@ int main(int argc, const char* argv[]) {
.add("--output",
"-o",
"Output file (stdout if not specified)",
+ WasmMetaDCEOption,
Options::Arguments::One,
[](Options* o, const std::string& argument) {
o->extra["output"] = argument;
@@ -482,21 +485,25 @@ int main(int argc, const char* argv[]) {
.add("--emit-text",
"-S",
"Emit text instead of binary for the output file",
+ WasmMetaDCEOption,
Options::Arguments::Zero,
[&](Options* o, const std::string& argument) { emitBinary = false; })
.add("--debuginfo",
"-g",
"Emit names section and debug info",
+ WasmMetaDCEOption,
Options::Arguments::Zero,
[&](Options* o, const std::string& arguments) { debugInfo = true; })
.add("--graph-file",
"-f",
"Filename of the graph description file",
+ WasmMetaDCEOption,
Options::Arguments::One,
[&](Options* o, const std::string& argument) { graphFile = argument; })
.add("--dump",
"-d",
"Dump the combined graph file (useful for debugging)",
+ WasmMetaDCEOption,
Options::Arguments::Zero,
[&](Options* o, const std::string& arguments) { dump = true; })
.add_positional("INFILE",
diff --git a/src/tools/wasm-opt.cpp b/src/tools/wasm-opt.cpp
index 2ccf11fa0..c026be21b 100644
--- a/src/tools/wasm-opt.cpp
+++ b/src/tools/wasm-opt.cpp
@@ -91,11 +91,14 @@ int main(int argc, const char* argv[]) {
std::string outputSourceMapFilename;
std::string outputSourceMapUrl;
+ const std::string WasmOptOption = "wasm-opt options";
+
OptimizationOptions options("wasm-opt", "Read, write, and optimize files");
options
.add("--output",
"-o",
"Output file (stdout if not specified)",
+ WasmOptOption,
Options::Arguments::One,
[](Options* o, const std::string& argument) {
o->extra["output"] = argument;
@@ -104,23 +107,27 @@ int main(int argc, const char* argv[]) {
.add("--emit-text",
"-S",
"Emit text instead of binary for the output file",
+ WasmOptOption,
Options::Arguments::Zero,
[&](Options* o, const std::string& argument) { emitBinary = false; })
.add("--converge",
"-c",
"Run passes to convergence, continuing while binary size decreases",
+ WasmOptOption,
Options::Arguments::Zero,
[&](Options* o, const std::string& arguments) { converge = true; })
.add(
"--fuzz-exec-before",
"-feh",
"Execute functions before optimization, helping fuzzing find bugs",
+ WasmOptOption,
Options::Arguments::Zero,
[&](Options* o, const std::string& arguments) { fuzzExecBefore = true; })
.add("--fuzz-exec",
"-fe",
"Execute functions before and after optimization, helping fuzzing "
"find bugs",
+ WasmOptOption,
Options::Arguments::Zero,
[&](Options* o, const std::string& arguments) {
fuzzExecBefore = fuzzExecAfter = true;
@@ -130,6 +137,7 @@ int main(int argc, const char* argv[]) {
"An extra command to run on the output before and after optimizing. "
"The output is compared between the two, and an error occurs if they "
"are not equal",
+ WasmOptOption,
Options::Arguments::One,
[&](Options* o, const std::string& arguments) {
extraFuzzCommand = arguments;
@@ -139,11 +147,13 @@ int main(int argc, const char* argv[]) {
"-ttf",
"Translate the input into a valid wasm module *somehow*, useful for "
"fuzzing",
+ WasmOptOption,
Options::Arguments::Zero,
[&](Options* o, const std::string& arguments) { translateToFuzz = true; })
.add("--initial-fuzz",
"-if",
"Initial wasm content in translate-to-fuzz (-ttf) mode",
+ WasmOptOption,
Options::Arguments::One,
[&initialFuzz](Options* o, const std::string& argument) {
initialFuzz = argument;
@@ -152,22 +162,26 @@ int main(int argc, const char* argv[]) {
"-fp",
"Pick a random set of passes to run, useful for fuzzing. this depends "
"on translate-to-fuzz (it picks the passes from the input)",
+ WasmOptOption,
Options::Arguments::Zero,
[&](Options* o, const std::string& arguments) { fuzzPasses = true; })
.add("--no-fuzz-memory",
"",
"don't emit memory ops when fuzzing",
+ WasmOptOption,
Options::Arguments::Zero,
[&](Options* o, const std::string& arguments) { fuzzMemory = false; })
.add("--no-fuzz-oob",
"",
"don't emit out-of-bounds loads/stores/indirect calls when fuzzing",
+ WasmOptOption,
Options::Arguments::Zero,
[&](Options* o, const std::string& arguments) { fuzzOOB = false; })
.add("--emit-js-wrapper",
"-ejw",
"Emit a JavaScript wrapper file that can run the wasm with some test "
"values, useful for fuzzing",
+ WasmOptOption,
Options::Arguments::One,
[&](Options* o, const std::string& arguments) {
emitJSWrapper = arguments;
@@ -176,6 +190,7 @@ int main(int argc, const char* argv[]) {
"-esw",
"Emit a wasm spec interpreter wrapper file that can run the wasm with "
"some test values, useful for fuzzing",
+ WasmOptOption,
Options::Arguments::One,
[&](Options* o, const std::string& arguments) {
emitSpecWrapper = arguments;
@@ -184,6 +199,7 @@ int main(int argc, const char* argv[]) {
"-esw",
"Emit a C wrapper file that can run the wasm after it is compiled "
"with wasm2c, useful for fuzzing",
+ WasmOptOption,
Options::Arguments::One,
[&](Options* o, const std::string& arguments) {
emitWasm2CWrapper = arguments;
@@ -191,6 +207,7 @@ int main(int argc, const char* argv[]) {
.add("--input-source-map",
"-ism",
"Consume source map from the specified file",
+ WasmOptOption,
Options::Arguments::One,
[&inputSourceMapFilename](Options* o, const std::string& argument) {
inputSourceMapFilename = argument;
@@ -198,6 +215,7 @@ int main(int argc, const char* argv[]) {
.add("--output-source-map",
"-osm",
"Emit source map to the specified file",
+ WasmOptOption,
Options::Arguments::One,
[&outputSourceMapFilename](Options* o, const std::string& argument) {
outputSourceMapFilename = argument;
@@ -205,6 +223,7 @@ int main(int argc, const char* argv[]) {
.add("--output-source-map-url",
"-osu",
"Emit specified string as source map URL",
+ WasmOptOption,
Options::Arguments::One,
[&outputSourceMapUrl](Options* o, const std::string& argument) {
outputSourceMapUrl = argument;
diff --git a/src/tools/wasm-reduce.cpp b/src/tools/wasm-reduce.cpp
index eff46bbcf..a6c195a63 100644
--- a/src/tools/wasm-reduce.cpp
+++ b/src/tools/wasm-reduce.cpp
@@ -1173,6 +1173,9 @@ int main(int argc, const char* argv[]) {
std::string binDir = Path::getDirName(argv[0]);
bool binary = true, deNan = false, verbose = false, debugInfo = false,
force = false;
+
+ const std::string WasmReduceOption = "wasm-reduce options";
+
ToolOptions options("wasm-reduce",
"Reduce a wasm file to a smaller one that has the same "
"behavior on a given command");
@@ -1183,12 +1186,14 @@ int main(int argc, const char* argv[]) {
"the command's output identical. "
"We look at the command's return code and stdout here (TODO: stderr), "
"and we reduce while keeping those unchanged.",
+ WasmReduceOption,
Options::Arguments::One,
[&](Options* o, const std::string& argument) { command = argument; })
.add("--test",
"-t",
"Test file (this will be written to to test, the given command should "
"read it when we call it)",
+ WasmReduceOption,
Options::Arguments::One,
[&](Options* o, const std::string& argument) { test = argument; })
.add("--working",
@@ -1196,11 +1201,13 @@ int main(int argc, const char* argv[]) {
"Working file (this will contain the current good state while doing "
"temporary computations, "
"and will contain the final best result at the end)",
+ WasmReduceOption,
Options::Arguments::One,
[&](Options* o, const std::string& argument) { working = argument; })
.add("--binaries",
"-b",
"binaryen binaries location (bin/ directory)",
+ WasmReduceOption,
Options::Arguments::One,
[&](Options* o, const std::string& argument) {
// Add separator just in case
@@ -1210,33 +1217,39 @@ int main(int argc, const char* argv[]) {
"-S",
"Emit intermediate files as text, instead of binary (also make sure "
"the test and working files have a .wat or .wast suffix)",
+ WasmReduceOption,
Options::Arguments::Zero,
[&](Options* o, const std::string& argument) { binary = false; })
.add("--denan",
"",
"Avoid nans when reducing",
+ WasmReduceOption,
Options::Arguments::Zero,
[&](Options* o, const std::string& argument) { deNan = true; })
.add("--verbose",
"-v",
"Verbose output mode",
+ WasmReduceOption,
Options::Arguments::Zero,
[&](Options* o, const std::string& argument) { verbose = true; })
.add("--debugInfo",
"-g",
"Keep debug info in binaries",
+ WasmReduceOption,
Options::Arguments::Zero,
[&](Options* o, const std::string& argument) { debugInfo = true; })
.add("--force",
"-f",
"Force the reduction attempt, ignoring problems that imply it is "
"unlikely to succeed",
+ WasmReduceOption,
Options::Arguments::Zero,
[&](Options* o, const std::string& argument) { force = true; })
.add("--timeout",
"-to",
"A timeout to apply to each execution of the command, in seconds "
"(default: 2)",
+ WasmReduceOption,
Options::Arguments::One,
[&](Options* o, const std::string& argument) {
timeout = atoi(argument.c_str());
@@ -1246,6 +1259,7 @@ int main(int argc, const char* argv[]) {
"-ef",
"Extra commandline flags to pass to wasm-opt while reducing. "
"(default: --enable-all)",
+ WasmReduceOption,
Options::Arguments::One,
[&](Options* o, const std::string& argument) {
extraFlags = argument;
diff --git a/src/tools/wasm-shell.cpp b/src/tools/wasm-shell.cpp
index 9b8e7ff28..6a780dd9e 100644
--- a/src/tools/wasm-shell.cpp
+++ b/src/tools/wasm-shell.cpp
@@ -47,17 +47,21 @@ struct ShellOptions : public Options {
Name entry;
std::set<size_t> skipped;
+ const std::string WasmShellOption = "wasm-shell options";
+
ShellOptions(const std::string& command, const std::string& description)
: Options(command, description) {
(*this)
.add("--entry",
"-e",
"Call the entry point after parsing the module",
+ WasmShellOption,
Options::Arguments::One,
[this](Options*, const std::string& argument) { entry = argument; })
.add("--skip",
"-s",
"Skip input on certain lines (comma-separated-list)",
+ WasmShellOption,
Options::Arguments::One,
[this](Options*, const std::string& argument) {
size_t i = 0;
diff --git a/src/tools/wasm-split/split-options.cpp b/src/tools/wasm-split/split-options.cpp
index 163e987de..bd6d6f09a 100644
--- a/src/tools/wasm-split/split-options.cpp
+++ b/src/tools/wasm-split/split-options.cpp
@@ -80,10 +80,13 @@ WasmSplitOptions::WasmSplitOptions()
"can inform future splitting, or manage such profiles. Options "
"that are only accepted in particular modes are marked with "
"the accepted \"[<modes>]\" in their descriptions.") {
+ const std::string WasmSplitOption = "wasm-split options";
+
(*this)
.add("--split",
"",
"Split an input module into two output modules. The default mode.",
+ WasmSplitOption,
Options::Arguments::Zero,
[&](Options* o, const std::string& arugment) { mode = Mode::Split; })
.add(
@@ -91,11 +94,13 @@ WasmSplitOptions::WasmSplitOptions()
"",
"Instrument an input module to allow it to generate a profile that can"
" be used to guide splitting.",
+ WasmSplitOption,
Options::Arguments::Zero,
[&](Options* o, const std::string& argument) { mode = Mode::Instrument; })
.add("--merge-profiles",
"",
"Merge multiple profiles for the same module into a single profile.",
+ WasmSplitOption,
Options::Arguments::Zero,
[&](Options* o, const std::string& argument) {
mode = Mode::MergeProfiles;
@@ -104,6 +109,7 @@ WasmSplitOptions::WasmSplitOptions()
"--profile",
"",
"The profile to use to guide splitting.",
+ WasmSplitOption,
{Mode::Split},
Options::Arguments::One,
[&](Options* o, const std::string& argument) { profileFile = argument; })
@@ -113,6 +119,7 @@ WasmSplitOptions::WasmSplitOptions()
"rest will be split out. Cannot be used with --profile or "
"--split-funcs. You can also pass a file with one function per line "
"by passing @filename.",
+ WasmSplitOption,
{Mode::Split},
Options::Arguments::One,
[&](Options* o, const std::string& argument) {
@@ -124,6 +131,7 @@ WasmSplitOptions::WasmSplitOptions()
"module. The rest will be kept. Cannot be used with --profile or "
"--keep-funcs. You can also pass a file with one function per line "
"by passing @filename.",
+ WasmSplitOption,
{Mode::Split},
Options::Arguments::One,
[&](Options* o, const std::string& argument) {
@@ -132,6 +140,7 @@ WasmSplitOptions::WasmSplitOptions()
.add("--primary-output",
"-o1",
"Output file for the primary module.",
+ WasmSplitOption,
{Mode::Split},
Options::Arguments::One,
[&](Options* o, const std::string& argument) {
@@ -140,6 +149,7 @@ WasmSplitOptions::WasmSplitOptions()
.add("--secondary-output",
"-o2",
"Output file for the secondary module.",
+ WasmSplitOption,
{Mode::Split},
Options::Arguments::One,
[&](Options* o, const std::string& argument) {
@@ -148,6 +158,7 @@ WasmSplitOptions::WasmSplitOptions()
.add("--symbolmap",
"",
"Write a symbol map file for each of the output modules.",
+ WasmSplitOption,
{Mode::Split},
Options::Arguments::Zero,
[&](Options* o, const std::string& argument) { symbolMap = true; })
@@ -155,6 +166,7 @@ WasmSplitOptions::WasmSplitOptions()
"--placeholdermap",
"",
"Write a file mapping placeholder indices to the function names.",
+ WasmSplitOption,
{Mode::Split},
Options::Arguments::Zero,
[&](Options* o, const std::string& argument) { placeholderMap = true; })
@@ -162,6 +174,7 @@ WasmSplitOptions::WasmSplitOptions()
"",
"The namespace from which to import objects from the primary "
"module into the secondary module.",
+ WasmSplitOption,
{Mode::Split},
Options::Arguments::One,
[&](Options* o, const std::string& argument) {
@@ -171,6 +184,7 @@ WasmSplitOptions::WasmSplitOptions()
"",
"The namespace from which to import placeholder functions into "
"the primary module.",
+ WasmSplitOption,
{Mode::Split},
Options::Arguments::One,
[&](Options* o, const std::string& argument) {
@@ -181,6 +195,7 @@ WasmSplitOptions::WasmSplitOptions()
"",
"An identifying prefix to prepend to new export names created "
"by module splitting.",
+ WasmSplitOption,
{Mode::Split},
Options::Arguments::One,
[&](Options* o, const std::string& argument) { exportPrefix = argument; })
@@ -188,6 +203,7 @@ WasmSplitOptions::WasmSplitOptions()
"",
"The export name of the function the embedder calls to write the "
"profile into memory. Defaults to `__write_profile`.",
+ WasmSplitOption,
{Mode::Instrument},
Options::Arguments::One,
[&](Options* o, const std::string& argument) {
@@ -201,6 +217,7 @@ WasmSplitOptions::WasmSplitOptions()
"it can be shared between multiple threads. Users are responsible for "
"ensuring that the module does not use the initial memory region for "
"anything else.",
+ WasmSplitOption,
{Mode::Instrument},
Options::Arguments::Zero,
[&](Options* o, const std::string& argument) {
@@ -213,6 +230,7 @@ WasmSplitOptions::WasmSplitOptions()
"Can help differentiate the modules in stack traces. This option will be "
"removed once simpler ways of naming modules are widely available. See "
"https://bugs.chromium.org/p/v8/issues/detail?id=11808.",
+ WasmSplitOption,
{Mode::Split, Mode::Instrument},
Options::Arguments::Zero,
[&](Options* o, const std::string& arguments) { emitModuleNames = true; })
@@ -222,6 +240,7 @@ WasmSplitOptions::WasmSplitOptions()
"table size when using Emscripten's SPLIT_MODULE mode with dynamic "
"linking. TODO: Figure out a more elegant solution for that use "
"case and remove this.",
+ WasmSplitOption,
{Mode::Split, Mode::Instrument},
Options::Arguments::One,
[&](Options* o, const std::string& argument) {
@@ -230,12 +249,14 @@ WasmSplitOptions::WasmSplitOptions()
.add("--emit-text",
"-S",
"Emit text instead of binary for the output file or files.",
+ WasmSplitOption,
{Mode::Split, Mode::Instrument},
Options::Arguments::Zero,
[&](Options* o, const std::string& argument) { emitBinary = false; })
.add("--debuginfo",
"-g",
"Emit names section in wasm binary (or full debuginfo in wast)",
+ WasmSplitOption,
{Mode::Split, Mode::Instrument},
Options::Arguments::Zero,
[&](Options* o, const std::string& arguments) {
@@ -244,6 +265,7 @@ WasmSplitOptions::WasmSplitOptions()
.add("--output",
"-o",
"Output file.",
+ WasmSplitOption,
{Mode::Instrument, Mode::MergeProfiles},
Options::Arguments::One,
[&](Options* o, const std::string& argument) { output = argument; })
@@ -251,6 +273,7 @@ WasmSplitOptions::WasmSplitOptions()
"-v",
"Verbose output mode. Prints the functions that will be kept "
"and split out when splitting a module.",
+ WasmSplitOption,
Options::Arguments::Zero,
[&](Options* o, const std::string& argument) {
verbose = true;
@@ -266,6 +289,7 @@ WasmSplitOptions::WasmSplitOptions()
WasmSplitOptions& WasmSplitOptions::add(const std::string& longName,
const std::string& shortName,
const std::string& description,
+ const std::string& category,
std::vector<Mode>&& modes,
Arguments arguments,
const Action& action) {
@@ -286,6 +310,7 @@ WasmSplitOptions& WasmSplitOptions::add(const std::string& longName,
longName,
shortName,
desc.str(),
+ category,
arguments,
[&, action, longName](Options* o, const std::string& argument) {
usedOptions.push_back(longName);
@@ -297,13 +322,14 @@ WasmSplitOptions& WasmSplitOptions::add(const std::string& longName,
WasmSplitOptions& WasmSplitOptions::add(const std::string& longName,
const std::string& shortName,
const std::string& description,
+ const std::string& category,
Arguments arguments,
const Action& action) {
// Add an option valid in all modes.
for (unsigned i = 0; i < NumModes; ++i) {
validOptions[i].insert(longName);
}
- return add(longName, shortName, description, {}, arguments, action);
+ return add(longName, shortName, description, category, {}, arguments, action);
}
bool WasmSplitOptions::validate() {
diff --git a/src/tools/wasm-split/split-options.h b/src/tools/wasm-split/split-options.h
index faa6ee30f..d52f215cd 100644
--- a/src/tools/wasm-split/split-options.h
+++ b/src/tools/wasm-split/split-options.h
@@ -75,12 +75,14 @@ struct WasmSplitOptions : ToolOptions {
WasmSplitOptions& add(const std::string& longName,
const std::string& shortName,
const std::string& description,
+ const std::string& category,
std::vector<Mode>&& modes,
Arguments arguments,
const Action& action);
WasmSplitOptions& add(const std::string& longName,
const std::string& shortName,
const std::string& description,
+ const std::string& category,
Arguments arguments,
const Action& action);
bool validate();
diff --git a/src/tools/wasm2js.cpp b/src/tools/wasm2js.cpp
index 4736dee08..061cd386f 100644
--- a/src/tools/wasm2js.cpp
+++ b/src/tools/wasm2js.cpp
@@ -884,12 +884,16 @@ void AssertionEmitter::emit() {
int main(int argc, const char* argv[]) {
Wasm2JSBuilder::Flags flags;
+
+ const std::string Wasm2JSOption = "wasm2js options";
+
OptimizationOptions options("wasm2js",
"Transform .wasm/.wat files to asm.js");
options
.add("--output",
"-o",
"Output file (stdout if not specified)",
+ Wasm2JSOption,
Options::Arguments::One,
[](Options* o, const std::string& argument) {
o->extra["output"] = argument;
@@ -898,6 +902,7 @@ int main(int argc, const char* argv[]) {
.add("--allow-asserts",
"",
"Allow compilation of .wast testing asserts",
+ Wasm2JSOption,
Options::Arguments::Zero,
[&](Options* o, const std::string& argument) {
flags.allowAsserts = true;
@@ -907,6 +912,7 @@ int main(int argc, const char* argv[]) {
"--pedantic",
"",
"Emulate WebAssembly trapping behavior",
+ Wasm2JSOption,
Options::Arguments::Zero,
[&](Options* o, const std::string& argument) { flags.pedantic = true; })
.add(
@@ -914,6 +920,7 @@ int main(int argc, const char* argv[]) {
"",
"Emulate the glue in emscripten-compatible form (and not ES6 module "
"form)",
+ Wasm2JSOption,
Options::Arguments::Zero,
[&](Options* o, const std::string& argument) { flags.emscripten = true; })
.add(
@@ -924,6 +931,7 @@ int main(int argc, const char* argv[]) {
"out of bounds or integer divide by zero; with this flag, we try to be "
"deterministic at least in what happens, which might or might not be "
"to trap like wasm, but at least should not vary)",
+ Wasm2JSOption,
Options::Arguments::Zero,
[&](Options* o, const std::string& argument) {
flags.deterministic = true;
@@ -932,6 +940,7 @@ int main(int argc, const char* argv[]) {
"--symbols-file",
"",
"Emit a symbols file that maps function indexes to their original names",
+ Wasm2JSOption,
Options::Arguments::One,
[&](Options* o, const std::string& argument) {
flags.symbolsFile = argument;