Skip to content

Commit 284c935

Browse files
authored
Refactor -g param parsing (#2167)
Use one shared location in optimization-options as much as possible. This also allows tools like wasm2js to receive that flag.
1 parent cac94c5 commit 284c935

3 files changed

Lines changed: 9 additions & 15 deletions

File tree

src/tools/asm2wasm.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,6 @@ int main(int argc, const char* argv[]) {
140140
[&legalizeJavaScriptFFI](Options* o, const std::string&) {
141141
legalizeJavaScriptFFI = false;
142142
})
143-
.add("--debuginfo",
144-
"-g",
145-
"Emit names section in wasm binary (or full debuginfo in wast)",
146-
Options::Arguments::Zero,
147-
[&](Options* o, const std::string& arguments) {
148-
options.passOptions.debugInfo = true;
149-
})
150143
.add("--source-map",
151144
"-sm",
152145
"Emit source map (if using binary output) to the specified file",

src/tools/optimization-options.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ struct OptimizationOptions : public ToolOptions {
123123
[this](Options* o, const std::string& argument) {
124124
passOptions.shrinkLevel = atoi(argument.c_str());
125125
})
126+
.add("--debuginfo",
127+
"-g",
128+
"Emit names section in wasm binary (or full debuginfo in wast)",
129+
Options::Arguments::Zero,
130+
[&](Options* o, const std::string& arguments) {
131+
passOptions.debugInfo = true;
132+
})
126133
.add("--always-inline-max-function-size",
127134
"-aimfs",
128135
"Max size of functions that are always inlined (default " +

src/tools/wasm-opt.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ std::string runCommand(std::string command) {
6363
int main(int argc, const char* argv[]) {
6464
Name entry;
6565
bool emitBinary = true;
66-
bool debugInfo = false;
6766
bool converge = false;
6867
bool fuzzExecBefore = false;
6968
bool fuzzExecAfter = false;
@@ -95,11 +94,6 @@ int main(int argc, const char* argv[]) {
9594
"Emit text instead of binary for the output file",
9695
Options::Arguments::Zero,
9796
[&](Options* o, const std::string& argument) { emitBinary = false; })
98-
.add("--debuginfo",
99-
"-g",
100-
"Emit names section and debug info",
101-
Options::Arguments::Zero,
102-
[&](Options* o, const std::string& arguments) { debugInfo = true; })
10397
.add("--converge",
10498
"-c",
10599
"Run passes to convergence, continuing while binary size decreases",
@@ -295,7 +289,7 @@ int main(int argc, const char* argv[]) {
295289
ModuleWriter writer;
296290
writer.setDebug(options.debug);
297291
writer.setBinary(emitBinary);
298-
writer.setDebugInfo(debugInfo);
292+
writer.setDebugInfo(options.passOptions.debugInfo);
299293
writer.write(wasm, options.extra["output"]);
300294
firstOutput = runCommand(extraFuzzCommand);
301295
std::cout << "[extra-fuzz-command first output:]\n" << firstOutput << '\n';
@@ -377,7 +371,7 @@ int main(int argc, const char* argv[]) {
377371
ModuleWriter writer;
378372
writer.setDebug(options.debug);
379373
writer.setBinary(emitBinary);
380-
writer.setDebugInfo(debugInfo);
374+
writer.setDebugInfo(options.passOptions.debugInfo);
381375
if (outputSourceMapFilename.size()) {
382376
writer.setSourceMapFilename(outputSourceMapFilename);
383377
writer.setSourceMapUrl(outputSourceMapUrl);

0 commit comments

Comments
 (0)