summaryrefslogtreecommitdiff
path: root/src/tools/wasm-split/split-options.cpp
diff options
context:
space:
mode:
authorThomas Lively <7121787+tlively@users.noreply.github.com>2021-09-24 14:25:05 -0700
committerGitHub <noreply@github.com>2021-09-24 14:25:05 -0700
commitab3811dafb27edd81f919d0096630014184b3836 (patch)
tree632000d37a75a3c5913bce7b0c17c163b430acbf /src/tools/wasm-split/split-options.cpp
parenta6dbadb8d180aff3c481ad8fd3009a712c11b449 (diff)
downloadbinaryen-ab3811dafb27edd81f919d0096630014184b3836.tar.gz
binaryen-ab3811dafb27edd81f919d0096630014184b3836.tar.bz2
binaryen-ab3811dafb27edd81f919d0096630014184b3836.zip
[wasm-split] Disallow mixing --profile, --keep-funcs, and --split-funcs (#4187)
Previously the set of functions to keep was initially empty, then the profile added new functions to keep, then the --keep-funcs functions were added, then the --split-funcs functions were removed. This method of composing these different options was arbitrary and not necessarily intuitive, and it prevented reasonable workflows from working. For example, providing only a --split-funcs list would result in all functions being split out not matter which functions were listed. To make the behavior of these options, and --split-funcs in particular, more intuitive, disallow mixing them and when --split-funcs is used, split out only the listed functions.
Diffstat (limited to 'src/tools/wasm-split/split-options.cpp')
-rw-r--r--src/tools/wasm-split/split-options.cpp36
1 files changed, 16 insertions, 20 deletions
diff --git a/src/tools/wasm-split/split-options.cpp b/src/tools/wasm-split/split-options.cpp
index 8de08d5a1..163e987de 100644
--- a/src/tools/wasm-split/split-options.cpp
+++ b/src/tools/wasm-split/split-options.cpp
@@ -109,11 +109,10 @@ WasmSplitOptions::WasmSplitOptions()
[&](Options* o, const std::string& argument) { profileFile = argument; })
.add("--keep-funcs",
"",
- "Comma-separated list of functions to keep in the primary module, "
- "regardless of any profile. "
- "You can also pass a file with a list of functions separated by new "
- "lines. "
- "To do this, prepend @ before filename (--keep-funcs @myfile)",
+ "Comma-separated list of functions to keep in the primary module. The "
+ "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.",
{Mode::Split},
Options::Arguments::One,
[&](Options* o, const std::string& argument) {
@@ -121,12 +120,10 @@ WasmSplitOptions::WasmSplitOptions()
})
.add("--split-funcs",
"",
- "Comma-separated list of functions to split into the secondary "
- "module, regardless of any profile. If there is no profile, then "
- "this defaults to all functions defined in the module. "
- "You can also pass a file with a list of functions separated by new "
- "lines. "
- "To do this, prepend @ before filename (--split-funcs @myfile)",
+ "Comma-separated list of functions to split out to the secondary "
+ "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.",
{Mode::Split},
Options::Arguments::One,
[&](Options* o, const std::string& argument) {
@@ -342,15 +339,14 @@ bool WasmSplitOptions::validate() {
}
if (mode == Mode::Split) {
- std::vector<Name> impossible;
- std::set_intersection(keepFuncs.begin(),
- keepFuncs.end(),
- splitFuncs.begin(),
- splitFuncs.end(),
- std::inserter(impossible, impossible.end()));
- for (auto& func : impossible) {
- fail(std::string("Cannot both keep and split out function ") +
- func.c_str());
+ if (profileFile.size() && keepFuncs.size()) {
+ fail("Cannot use both --profile and --keep-funcs.");
+ }
+ if (profileFile.size() && splitFuncs.size()) {
+ fail("Cannot use both --profile and --split-funcs.");
+ }
+ if (keepFuncs.size() && splitFuncs.size()) {
+ fail("Cannot use both --keep-funcs and --split-funcs.");
}
}