diff --git a/src/tools/tool-options.h b/src/tools/tool-options.h index 2106fc66a49..e859d41be3a 100644 --- a/src/tools/tool-options.h +++ b/src/tools/tool-options.h @@ -32,6 +32,7 @@ struct ToolOptions : public Options { bool quiet = false; bool preserveTypeOrder = false; + bool emitModuleNames = false; IRProfile profile = IRProfile::Normal; constexpr static const char* ToolOptionsCategory = "Tool options"; @@ -69,13 +70,19 @@ struct ToolOptions : public Options { 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; }); + .add("--experimental-poppy", + "", + "Parse wast files as Poppy IR for testing purposes.", + ToolOptionsCategory, + Arguments::Zero, + [this](Options*, const std::string&) { profile = IRProfile::Poppy; }) + .add("--emit-module-names", + "", + "Emit module names, even if not emitting the rest of the names " + "section.", + ToolOptionsCategory, + Arguments::Zero, + [this](Options*, const std::string&) { emitModuleNames = true; }); (*this) .addFeature(FeatureSet::SignExt, "sign extension operations") .addFeature(FeatureSet::Atomics, "atomic operations") diff --git a/src/tools/wasm-opt.cpp b/src/tools/wasm-opt.cpp index 9bdfa4b06f7..306ca5adaa9 100644 --- a/src/tools/wasm-opt.cpp +++ b/src/tools/wasm-opt.cpp @@ -269,6 +269,7 @@ For more on how to optimize effectively, see [&outputSourceMapUrl](Options* o, const std::string& argument) { outputSourceMapUrl = argument; }) + .add_positional("INFILE", Options::Arguments::One, [](Options* o, const std::string& argument) { @@ -407,6 +408,9 @@ For more on how to optimize effectively, see ModuleWriter writer(options.passOptions); writer.setBinary(emitBinary); writer.setDebugInfo(options.passOptions.debugInfo); + if (options.emitModuleNames) { + writer.setEmitModuleName(true); + } writer.write(wasm, options.extra["output"]); firstOutput = runCommand(extraFuzzCommand); std::cout << "[extra-fuzz-command first output:]\n" << firstOutput << '\n'; @@ -496,6 +500,9 @@ For more on how to optimize effectively, see ModuleWriter writer(options.passOptions); writer.setBinary(emitBinary); writer.setDebugInfo(options.passOptions.debugInfo); + if (options.emitModuleNames) { + writer.setEmitModuleName(true); + } if (outputSourceMapFilename.size()) { writer.setSourceMapFilename(outputSourceMapFilename); writer.setSourceMapUrl(outputSourceMapUrl); diff --git a/src/tools/wasm-split/split-options.cpp b/src/tools/wasm-split/split-options.cpp index d62d22ad765..d20b57f6cd7 100644 --- a/src/tools/wasm-split/split-options.cpp +++ b/src/tools/wasm-split/split-options.cpp @@ -312,17 +312,7 @@ WasmSplitOptions::WasmSplitOptions() [&](Options* o, const std::string& argument) { secondaryMemoryName = argument; }) - .add( - "--emit-module-names", - "", - "Emit module names, even if not emitting the rest of the names section. " - "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::MultiSplit, Mode::Instrument}, - Options::Arguments::Zero, - [&](Options* o, const std::string& arguments) { emitModuleNames = true; }) + .add("--initial-table", "", "A hack to ensure the split and instrumented modules have the same " diff --git a/src/tools/wasm-split/split-options.h b/src/tools/wasm-split/split-options.h index 7955721f5d3..25b681a95f1 100644 --- a/src/tools/wasm-split/split-options.h +++ b/src/tools/wasm-split/split-options.h @@ -52,9 +52,6 @@ struct WasmSplitOptions : ToolOptions { bool placeholderMap = false; bool stripDebug = false; - // TODO: Remove this. See the comment in wasm-binary.h. - bool emitModuleNames = false; - std::string profileFile; std::string profileExport = DEFAULT_PROFILE_EXPORT; diff --git a/test/lit/emit-module-names.wast b/test/lit/emit-module-names.wast new file mode 100644 index 00000000000..8849d383636 --- /dev/null +++ b/test/lit/emit-module-names.wast @@ -0,0 +1,15 @@ +;; Check that --emit-module-names without -g strips function names but generates +;; and keeps the module name. + +;; RUN: wasm-opt %s --emit-module-names -o %t.wasm +;; RUN: wasm-dis %t.wasm -o - | filecheck %s + +;; CHECK: (module $module-name +;; CHECK: (func $0 +;; CHECK-NOT: $foo + +(module $module-name + (func $foo + (nop) + ) +) diff --git a/test/lit/help/wasm-as.test b/test/lit/help/wasm-as.test index fbb4f9c35e5..2b4902683c5 100644 --- a/test/lit/help/wasm-as.test +++ b/test/lit/help/wasm-as.test @@ -38,6 +38,9 @@ ;; CHECK-NEXT: --experimental-poppy Parse wast files as Poppy IR for testing ;; CHECK-NEXT: purposes. ;; CHECK-NEXT: +;; CHECK-NEXT: --emit-module-names Emit module names, even if not emitting +;; CHECK-NEXT: the rest of the names section +;; CHECK-NEXT: ;; CHECK-NEXT: --enable-sign-ext Enable sign extension operations ;; CHECK-NEXT: ;; CHECK-NEXT: --disable-sign-ext Disable sign extension operations diff --git a/test/lit/help/wasm-ctor-eval.test b/test/lit/help/wasm-ctor-eval.test index 7807de5e1de..1db625fc55d 100644 --- a/test/lit/help/wasm-ctor-eval.test +++ b/test/lit/help/wasm-ctor-eval.test @@ -45,6 +45,9 @@ ;; CHECK-NEXT: --experimental-poppy Parse wast files as Poppy IR for testing ;; CHECK-NEXT: purposes. ;; CHECK-NEXT: +;; CHECK-NEXT: --emit-module-names Emit module names, even if not emitting +;; CHECK-NEXT: the rest of the names section +;; CHECK-NEXT: ;; CHECK-NEXT: --enable-sign-ext Enable sign extension operations ;; CHECK-NEXT: ;; CHECK-NEXT: --disable-sign-ext Disable sign extension operations diff --git a/test/lit/help/wasm-dis.test b/test/lit/help/wasm-dis.test index 2f95f7a448a..ab022774484 100644 --- a/test/lit/help/wasm-dis.test +++ b/test/lit/help/wasm-dis.test @@ -31,6 +31,9 @@ ;; CHECK-NEXT: --experimental-poppy Parse wast files as Poppy IR for testing ;; CHECK-NEXT: purposes. ;; CHECK-NEXT: +;; CHECK-NEXT: --emit-module-names Emit module names, even if not emitting +;; CHECK-NEXT: the rest of the names section +;; CHECK-NEXT: ;; CHECK-NEXT: --enable-sign-ext Enable sign extension operations ;; CHECK-NEXT: ;; CHECK-NEXT: --disable-sign-ext Disable sign extension operations diff --git a/test/lit/help/wasm-emscripten-finalize.test b/test/lit/help/wasm-emscripten-finalize.test index 5ce391f9548..ac5cab80db4 100644 --- a/test/lit/help/wasm-emscripten-finalize.test +++ b/test/lit/help/wasm-emscripten-finalize.test @@ -73,6 +73,9 @@ ;; CHECK-NEXT: --experimental-poppy Parse wast files as Poppy IR for testing ;; CHECK-NEXT: purposes. ;; CHECK-NEXT: +;; CHECK-NEXT: --emit-module-names Emit module names, even if not emitting +;; CHECK-NEXT: the rest of the names section +;; CHECK-NEXT: ;; CHECK-NEXT: --enable-sign-ext Enable sign extension operations ;; CHECK-NEXT: ;; CHECK-NEXT: --disable-sign-ext Disable sign extension operations diff --git a/test/lit/help/wasm-merge.test b/test/lit/help/wasm-merge.test index f235c12fe5e..3909411ec08 100644 --- a/test/lit/help/wasm-merge.test +++ b/test/lit/help/wasm-merge.test @@ -68,6 +68,9 @@ ;; CHECK-NEXT: --experimental-poppy Parse wast files as Poppy IR for testing ;; CHECK-NEXT: purposes. ;; CHECK-NEXT: +;; CHECK-NEXT: --emit-module-names Emit module names, even if not emitting +;; CHECK-NEXT: the rest of the names section +;; CHECK-NEXT: ;; CHECK-NEXT: --enable-sign-ext Enable sign extension operations ;; CHECK-NEXT: ;; CHECK-NEXT: --disable-sign-ext Disable sign extension operations diff --git a/test/lit/help/wasm-metadce.test b/test/lit/help/wasm-metadce.test index aadf987cf33..f1068465fd3 100644 --- a/test/lit/help/wasm-metadce.test +++ b/test/lit/help/wasm-metadce.test @@ -698,6 +698,10 @@ ;; CHECK-NEXT: --experimental-poppy Parse wast files as Poppy IR for ;; CHECK-NEXT: testing purposes. ;; CHECK-NEXT: +;; CHECK-NEXT: --emit-module-names Emit module names, even if not +;; CHECK-NEXT: emitting the rest of the names +;; CHECK-NEXT: section +;; CHECK-NEXT: ;; CHECK-NEXT: --enable-sign-ext Enable sign extension operations ;; CHECK-NEXT: ;; CHECK-NEXT: --disable-sign-ext Disable sign extension diff --git a/test/lit/help/wasm-opt.test b/test/lit/help/wasm-opt.test index 4dec96a4104..903d6130089 100644 --- a/test/lit/help/wasm-opt.test +++ b/test/lit/help/wasm-opt.test @@ -734,6 +734,10 @@ ;; CHECK-NEXT: --experimental-poppy Parse wast files as Poppy IR for ;; CHECK-NEXT: testing purposes. ;; CHECK-NEXT: +;; CHECK-NEXT: --emit-module-names Emit module names, even if not +;; CHECK-NEXT: emitting the rest of the names +;; CHECK-NEXT: section +;; CHECK-NEXT: ;; CHECK-NEXT: --enable-sign-ext Enable sign extension operations ;; CHECK-NEXT: ;; CHECK-NEXT: --disable-sign-ext Disable sign extension diff --git a/test/lit/help/wasm-reduce.test b/test/lit/help/wasm-reduce.test index a85c42f13ec..f881c3d24f3 100644 --- a/test/lit/help/wasm-reduce.test +++ b/test/lit/help/wasm-reduce.test @@ -121,6 +121,9 @@ ;; CHECK-NEXT: --experimental-poppy Parse wast files as Poppy IR for testing ;; CHECK-NEXT: purposes. ;; CHECK-NEXT: +;; CHECK-NEXT: --emit-module-names Emit module names, even if not emitting +;; CHECK-NEXT: the rest of the names section +;; CHECK-NEXT: ;; CHECK-NEXT: --enable-sign-ext Enable sign extension operations ;; CHECK-NEXT: ;; CHECK-NEXT: --disable-sign-ext Disable sign extension operations diff --git a/test/lit/help/wasm-split.test b/test/lit/help/wasm-split.test index 0bd68869a09..c39cf69e534 100644 --- a/test/lit/help/wasm-split.test +++ b/test/lit/help/wasm-split.test @@ -124,15 +124,6 @@ ;; CHECK-NEXT: memory created to store profile ;; CHECK-NEXT: information. ;; CHECK-NEXT: -;; CHECK-NEXT: --emit-module-names [split, multi-split, instrument] Emit -;; CHECK-NEXT: module names, even if not emitting the -;; CHECK-NEXT: rest of the names section. Can help -;; CHECK-NEXT: differentiate the modules in stack -;; CHECK-NEXT: traces. This option will be removed once -;; CHECK-NEXT: simpler ways of naming modules are widely -;; CHECK-NEXT: available. See -;; CHECK-NEXT: https://bugs.chromium.org/p/v8/issues/detail?id=11808. -;; CHECK-NEXT: ;; CHECK-NEXT: --initial-table [split, instrument] A hack to ensure the ;; CHECK-NEXT: split and instrumented modules have the ;; CHECK-NEXT: same table size when using Emscripten's @@ -182,6 +173,9 @@ ;; CHECK-NEXT: --experimental-poppy Parse wast files as Poppy IR for testing ;; CHECK-NEXT: purposes. ;; CHECK-NEXT: +;; CHECK-NEXT: --emit-module-names Emit module names, even if not emitting +;; CHECK-NEXT: the rest of the names section +;; CHECK-NEXT: ;; CHECK-NEXT: --enable-sign-ext Enable sign extension operations ;; CHECK-NEXT: ;; CHECK-NEXT: --disable-sign-ext Disable sign extension operations diff --git a/test/lit/help/wasm2js.test b/test/lit/help/wasm2js.test index 550677a376f..acfc47bfc6f 100644 --- a/test/lit/help/wasm2js.test +++ b/test/lit/help/wasm2js.test @@ -662,6 +662,10 @@ ;; CHECK-NEXT: --experimental-poppy Parse wast files as Poppy IR for ;; CHECK-NEXT: testing purposes. ;; CHECK-NEXT: +;; CHECK-NEXT: --emit-module-names Emit module names, even if not +;; CHECK-NEXT: emitting the rest of the names +;; CHECK-NEXT: section +;; CHECK-NEXT: ;; CHECK-NEXT: --enable-sign-ext Enable sign extension operations ;; CHECK-NEXT: ;; CHECK-NEXT: --disable-sign-ext Disable sign extension