Skip to content

Commit 99cf922

Browse files
authored
Don't emit the 'no output file specified' warning when using a pass that emits to stdout (#7696)
1 parent 22f87dc commit 99cf922

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/tools/wasm-opt.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,15 @@ For more on how to optimize effectively, see
436436

437437
if (options.extra.count("output") == 0) {
438438
if (!options.quiet) {
439-
std::cerr << "warning: no output file specified, not emitting output\n";
439+
bool printsToStdout = std::any_of(
440+
options.passes.begin(),
441+
options.passes.end(),
442+
[](const OptimizationOptions::PassInfo& info) {
443+
return info.name == "print" || info.name == "print-function-map";
444+
});
445+
if (!printsToStdout) {
446+
std::cerr << "warning: no output file specified, not emitting output\n";
447+
}
440448
}
441449
return 0;
442450
}

test/unit/test_warnings.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,11 @@ def test_warn_on_no_output(self):
1616
def test_quiet_suppresses_warnings(self):
1717
err = shared.run_process(shared.WASM_OPT + [self.input_path('asyncify-pure.wat'), '-q'], stderr=subprocess.PIPE).stderr
1818
self.assertNotIn('warning', err)
19+
20+
def test_no_warn_on_print(self):
21+
err = shared.run_process(shared.WASM_OPT + [self.input_path('asyncify-pure.wat'), '--print'], stderr=subprocess.PIPE).stderr
22+
self.assertNotIn('warning: no output file specified, not emitting output', err)
23+
24+
def test_no_warn_on_print_function_map(self):
25+
err = shared.run_process(shared.WASM_OPT + [self.input_path('asyncify-pure.wat'), '--print-function-map'], stderr=subprocess.PIPE).stderr
26+
self.assertNotIn('warning: no output file specified, not emitting output', err)

0 commit comments

Comments
 (0)