Skip to content

Commit 8b820ed

Browse files
authored
if no output is specified to wasm-opt, warn that we are emitting nothing (#1908)
A user that just does ``` wasm-opt input.wasm -O ``` may assume that the input file should have been optimized. But without `-o` we don't emit any output. Often you may not want any output, like if you just want to run a pass like `--metrics`. But for most users wasm-opt is probably going to be used as an optimizer of files. So this PR suggests we emit a warning in that case. For comparison, `llvm-opt` would print to the console, but it avoids printing a binary there so it issues a warning. Instead of this warning, perhaps we should do the same? That would also not be confusing. Closes #1907
1 parent 90d0ee4 commit 8b820ed

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/tools/wasm-opt.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,9 @@ int main(int argc, const char* argv[]) {
274274
results.check(*curr);
275275
}
276276

277-
if (options.extra.count("output") > 0) {
277+
if (options.extra.count("output") == 0) {
278+
std::cerr << "(no output file specified, not emitting output)\n";
279+
} else {
278280
if (options.debug) std::cerr << "writing..." << std::endl;
279281
ModuleWriter writer;
280282
writer.setDebug(options.debug);

0 commit comments

Comments
 (0)