From a2af4945425ca38537e0ee809e47a9faa120394e Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 26 Aug 2025 14:57:24 -0700 Subject: [PATCH] Remove --print-symbol-map / --symbolmap= This is no longer needed by emscripten. See https://github.com/emscripten-core/emscripten/pull/25053. --- CHANGELOG.md | 2 + src/passes/CMakeLists.txt | 1 - src/passes/PrintFunctionMap.cpp | 54 ------------ src/passes/pass.cpp | 11 --- src/passes/passes.h | 1 - src/tools/wasm-opt.cpp | 12 +-- test/lit/help/wasm-metadce.test | 5 -- test/lit/help/wasm-opt.test | 5 -- test/lit/help/wasm2js.test | 5 -- .../lit/wasm-split/symbolmap-multi-split.wast | 87 ------------------- test/lit/wasm-split/symbolmap.wast | 28 ------ test/passes/print-function-map.txt | 11 --- test/passes/print-function-map.wast | 6 -- test/unit/test_symbolmap.py | 20 ----- test/unit/test_warnings.py | 4 - 15 files changed, 8 insertions(+), 244 deletions(-) delete mode 100644 src/passes/PrintFunctionMap.cpp delete mode 100644 test/lit/wasm-split/symbolmap-multi-split.wast delete mode 100644 test/lit/wasm-split/symbolmap.wast delete mode 100644 test/passes/print-function-map.txt delete mode 100644 test/passes/print-function-map.wast delete mode 100644 test/unit/test_symbolmap.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 224563f612a..0352b4df3a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ Current Trunk - The --mod-asyncify-never-unwind and --mod-asyncify-always-and-only-unwind passed were deleted. They only existed to support the lazy code loading support in emscripten that was removed. (#7893) + - The --print-symbol-map/--symbolmap flags we removed. They only existed to + support an emscripten feature which was re-implemented downstream. (#7862) v124 ---- diff --git a/src/passes/CMakeLists.txt b/src/passes/CMakeLists.txt index e9818681a56..d5305fd540a 100644 --- a/src/passes/CMakeLists.txt +++ b/src/passes/CMakeLists.txt @@ -91,7 +91,6 @@ set(passes_SOURCES Print.cpp PrintCallGraph.cpp PrintFeatures.cpp - PrintFunctionMap.cpp RoundTrip.cpp SetGlobals.cpp SignaturePruning.cpp diff --git a/src/passes/PrintFunctionMap.cpp b/src/passes/PrintFunctionMap.cpp deleted file mode 100644 index 4fe266ec084..00000000000 --- a/src/passes/PrintFunctionMap.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2019 WebAssembly Community Group participants - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// -// Prints the a map of function indexes to function names. This can be -// useful for interpreting a stack trace from a production environment -// where names did not exist on the client. The map looks like this: -// -// 0:foo -// 1:bar -// 2:baz -// - -#include "ir/module-utils.h" -#include "pass.h" -#include "support/file.h" -#include "wasm.h" - -namespace wasm { - -struct PrintFunctionMap : public Pass { - bool modifiesBinaryenIR() override { return false; } - - void run(Module* module) override { - // If an argument is provided, write to that file; otherwise write to - // stdout. - auto outFile = getArgumentOrDefault("symbolmap", ""); - Output output(outFile, Flags::Text); - auto& o = output.getStream(); - Index i = 0; - auto write = [&](Function* func) { - o << i++ << ':' << func->name.str << '\n'; - }; - ModuleUtils::iterImportedFunctions(*module, write); - ModuleUtils::iterDefinedFunctions(*module, write); - } -}; - -Pass* createPrintFunctionMapPass() { return new PrintFunctionMap(); } - -} // namespace wasm diff --git a/src/passes/pass.cpp b/src/passes/pass.cpp index b3162642624..fdbac0a8b3b 100644 --- a/src/passes/pass.cpp +++ b/src/passes/pass.cpp @@ -391,17 +391,6 @@ void PassRegistry::registerPasses() { registerPass( "print-call-graph", "print call graph", createPrintCallGraphPass); - // Register PrintFunctionMap using its normal name. - registerPass("print-function-map", - "print a map of function indexes to names", - createPrintFunctionMapPass); - // Also register it as "symbolmap" so that wasm-opt --symbolmap=foo is the - // same as wasm-as --symbolmap=foo even though the latter is not a pass - // (wasm-as cannot run arbitrary passes). - // TODO: switch emscripten to this name, then remove the old one - registerPass( - "symbolmap", "(alias for print-function-map)", createPrintFunctionMapPass); - registerPass("propagate-globals-globally", "propagate global values to other globals (useful for tests)", createPropagateGlobalsGloballyPass); diff --git a/src/passes/passes.h b/src/passes/passes.h index e8223e0bac8..956c1781a8e 100644 --- a/src/passes/passes.h +++ b/src/passes/passes.h @@ -129,7 +129,6 @@ Pass* createPrecomputePropagatePass(); Pass* createPrinterPass(); Pass* createPrintCallGraphPass(); Pass* createPrintFeaturesPass(); -Pass* createPrintFunctionMapPass(); Pass* createPropagateGlobalsGloballyPass(); Pass* createRandomizeBranchHintsPass(); Pass* createRemoveNonJSOpsPass(); diff --git a/src/tools/wasm-opt.cpp b/src/tools/wasm-opt.cpp index 5edd2a15b83..2e76b274907 100644 --- a/src/tools/wasm-opt.cpp +++ b/src/tools/wasm-opt.cpp @@ -436,12 +436,12 @@ For more on how to optimize effectively, see if (options.extra.count("output") == 0) { if (!options.quiet) { - bool printsToStdout = std::any_of( - options.passes.begin(), - options.passes.end(), - [](const OptimizationOptions::PassInfo& info) { - return info.name == "print" || info.name == "print-function-map"; - }); + bool printsToStdout = + std::any_of(options.passes.begin(), + options.passes.end(), + [](const OptimizationOptions::PassInfo& info) { + return info.name == "print"; + }); if (!printsToStdout) { std::cerr << "warning: no output file specified, not emitting output\n"; } diff --git a/test/lit/help/wasm-metadce.test b/test/lit/help/wasm-metadce.test index a8906472a32..03bf725d42e 100644 --- a/test/lit/help/wasm-metadce.test +++ b/test/lit/help/wasm-metadce.test @@ -367,9 +367,6 @@ ;; CHECK-NEXT: --print-full print in full s-expression ;; CHECK-NEXT: format ;; CHECK-NEXT: -;; CHECK-NEXT: --print-function-map print a map of function indexes -;; CHECK-NEXT: to names -;; CHECK-NEXT: ;; CHECK-NEXT: --print-minified print in minified s-expression ;; CHECK-NEXT: format ;; CHECK-NEXT: @@ -522,8 +519,6 @@ ;; CHECK-NEXT: --stub-unsupported-js stub out unsupported JS ;; CHECK-NEXT: operations ;; CHECK-NEXT: -;; CHECK-NEXT: --symbolmap (alias for print-function-map) -;; CHECK-NEXT: ;; CHECK-NEXT: --table64-lowering alias for memory64-lowering ;; CHECK-NEXT: ;; CHECK-NEXT: --trace-calls instrument the build with code diff --git a/test/lit/help/wasm-opt.test b/test/lit/help/wasm-opt.test index 3ee35a69bb2..b12ae57a906 100644 --- a/test/lit/help/wasm-opt.test +++ b/test/lit/help/wasm-opt.test @@ -391,9 +391,6 @@ ;; CHECK-NEXT: --print-full print in full s-expression ;; CHECK-NEXT: format ;; CHECK-NEXT: -;; CHECK-NEXT: --print-function-map print a map of function indexes -;; CHECK-NEXT: to names -;; CHECK-NEXT: ;; CHECK-NEXT: --print-minified print in minified s-expression ;; CHECK-NEXT: format ;; CHECK-NEXT: @@ -546,8 +543,6 @@ ;; CHECK-NEXT: --stub-unsupported-js stub out unsupported JS ;; CHECK-NEXT: operations ;; CHECK-NEXT: -;; CHECK-NEXT: --symbolmap (alias for print-function-map) -;; CHECK-NEXT: ;; CHECK-NEXT: --table64-lowering alias for memory64-lowering ;; CHECK-NEXT: ;; CHECK-NEXT: --trace-calls instrument the build with code diff --git a/test/lit/help/wasm2js.test b/test/lit/help/wasm2js.test index f2102f89f7d..545b95046a3 100644 --- a/test/lit/help/wasm2js.test +++ b/test/lit/help/wasm2js.test @@ -331,9 +331,6 @@ ;; CHECK-NEXT: --print-full print in full s-expression ;; CHECK-NEXT: format ;; CHECK-NEXT: -;; CHECK-NEXT: --print-function-map print a map of function indexes -;; CHECK-NEXT: to names -;; CHECK-NEXT: ;; CHECK-NEXT: --print-minified print in minified s-expression ;; CHECK-NEXT: format ;; CHECK-NEXT: @@ -486,8 +483,6 @@ ;; CHECK-NEXT: --stub-unsupported-js stub out unsupported JS ;; CHECK-NEXT: operations ;; CHECK-NEXT: -;; CHECK-NEXT: --symbolmap (alias for print-function-map) -;; CHECK-NEXT: ;; CHECK-NEXT: --table64-lowering alias for memory64-lowering ;; CHECK-NEXT: ;; CHECK-NEXT: --trace-calls instrument the build with code diff --git a/test/lit/wasm-split/symbolmap-multi-split.wast b/test/lit/wasm-split/symbolmap-multi-split.wast deleted file mode 100644 index 77cbff0c8f2..00000000000 --- a/test/lit/wasm-split/symbolmap-multi-split.wast +++ /dev/null @@ -1,87 +0,0 @@ -;; RUN: wasm-split -all --multi-split %s --manifest %S/multi-split.wast.manifest --out-prefix=%t --symbolmap -o %t.wasm -;; RUN: filecheck %s --check-prefix PRIMARY-MAP < %t.wasm.symbols -;; RUN: filecheck %s --check-prefix MOD1-MAP < %t1.wasm.symbols -;; RUN: filecheck %s --check-prefix MOD2-MAP < %t2.wasm.symbols -;; RUN: filecheck %s --check-prefix MOD3-MAP < %t3.wasm.symbols - -;; PRIMARY-MAP: 0:placeholder_0 -;; PRIMARY-MAP: 1:placeholder_0_4 -;; PRIMARY-MAP: 2:placeholder_0_5 -;; PRIMARY-MAP: 3:trampoline_A -;; PRIMARY-MAP: 4:trampoline_B -;; PRIMARY-MAP: 5:trampoline_C - -;; MOD1-MAP: 0:B -;; MOD1-MAP: 1:C -;; MOD1-MAP: 2:A - -;; MOD2-MAP: 0:C -;; MOD2-MAP: 1:trampoline_A -;; MOD2-MAP: 2:B - -;; MOD3-MAP: 0:trampoline_A -;; MOD3-MAP: 1:trampoline_B -;; MOD3-MAP: 2:C - -(module - (type $ret-i32 (func (result i32))) - (type $ret-i64 (func (result i64))) - (type $ret-f32 (func (result f32))) - - (func $A (type $ret-i32) (result i32) - (drop - (call_ref $ret-i32 - (ref.func $A) - ) - ) - (drop - (call_ref $ret-i64 - (ref.func $B) - ) - ) - (drop - (call_ref $ret-f32 - (ref.func $C) - ) - ) - (i32.const 0) - ) - - (func $B (type $ret-i64) (result i64) - (drop - (call_ref $ret-i32 - (ref.func $A) - ) - ) - (drop - (call_ref $ret-i64 - (ref.func $B) - ) - ) - (drop - (call_ref $ret-f32 - (ref.func $C) - ) - ) - (i64.const 0) - ) - - (func $C (type $ret-f32) (result f32) - (drop - (call_ref $ret-i32 - (ref.func $A) - ) - ) - (drop - (call_ref $ret-i64 - (ref.func $B) - ) - ) - (drop - (call_ref $ret-f32 - (ref.func $C) - ) - ) - (f32.const 0) - ) -) diff --git a/test/lit/wasm-split/symbolmap.wast b/test/lit/wasm-split/symbolmap.wast deleted file mode 100644 index b1be9531bb6..00000000000 --- a/test/lit/wasm-split/symbolmap.wast +++ /dev/null @@ -1,28 +0,0 @@ -;; RUN: wasm-split %s --keep-funcs=bar -o1 %t.1.wasm -o2 %t.2.wasm --symbolmap -;; RUN: filecheck %s --check-prefix PRIMARY-MAP < %t.1.wasm.symbols -;; RUN: filecheck %s --check-prefix SECONDARY-MAP < %t.2.wasm.symbols -;; RUN: wasm-dis %t.1.wasm | filecheck %s --check-prefix PRIMARY - -;; PRIMARY-MAP: 0:placeholder_0 -;; PRIMARY-MAP: 1:placeholder_2 -;; PRIMARY-MAP: 2:bar - -;; SECONDARY-MAP: 0:baz -;; SECONDARY-MAP: 1:foo - -;; Check that the names have been stripped. -;; PRIMARY: (func $0 - -(module - (table $table 3 3 funcref) - (elem $table (i32.const 0) $foo $bar $baz) - (func $foo - (nop) - ) - (func $bar - (nop) - ) - (func $baz - (nop) - ) -) diff --git a/test/passes/print-function-map.txt b/test/passes/print-function-map.txt deleted file mode 100644 index 5cf4c5843fb..00000000000 --- a/test/passes/print-function-map.txt +++ /dev/null @@ -1,11 +0,0 @@ -0:Foo -1:bar -2:baz -(module - (type $0 (func)) - (import "env" "foo" (func $Foo)) - (func $bar - ) - (func $baz - ) -) diff --git a/test/passes/print-function-map.wast b/test/passes/print-function-map.wast deleted file mode 100644 index 91b638ba934..00000000000 --- a/test/passes/print-function-map.wast +++ /dev/null @@ -1,6 +0,0 @@ -(module - (import "env" "foo" (func $Foo)) - (func $bar) - (func $baz) -) - diff --git a/test/unit/test_symbolmap.py b/test/unit/test_symbolmap.py deleted file mode 100644 index 59ce1847e1e..00000000000 --- a/test/unit/test_symbolmap.py +++ /dev/null @@ -1,20 +0,0 @@ -from scripts.test import shared -from . import utils - - -class SymbolMapTest(utils.BinaryenTestCase): - def test_symbolmap(self): - input_wasm = self.input_path('hello_world.wat') - # write the symbol map to a file - args = [input_wasm, '--symbolmap=out.symbols'] - shared.run_process(shared.WASM_OPT + args) - with open('out.symbols') as f: - file_output = f.read() - # write the symbol map to stdout - args = [input_wasm, '--symbolmap'] - stdout_output = shared.run_process(shared.WASM_OPT + args, - capture_output=True).stdout - # ignore whitespace in the comparison as on windows stdout gets an \r - self.assertEqual(file_output.strip(), stdout_output.strip()) - # the wat contains a single function "add" - self.assertIn('0:add', file_output) diff --git a/test/unit/test_warnings.py b/test/unit/test_warnings.py index cb912f42c16..4f06cfe81b1 100644 --- a/test/unit/test_warnings.py +++ b/test/unit/test_warnings.py @@ -20,7 +20,3 @@ def test_quiet_suppresses_warnings(self): def test_no_warn_on_print(self): err = shared.run_process(shared.WASM_OPT + [self.input_path('asyncify-pure.wat'), '--print'], stderr=subprocess.PIPE).stderr self.assertNotIn('warning: no output file specified, not emitting output', err) - - def test_no_warn_on_print_function_map(self): - err = shared.run_process(shared.WASM_OPT + [self.input_path('asyncify-pure.wat'), '--print-function-map'], stderr=subprocess.PIPE).stderr - self.assertNotIn('warning: no output file specified, not emitting output', err)