From 952fc61acf34c66fbf075840c5dfcc5a68ac3cad Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 16 Jul 2025 20:39:07 +0000 Subject: [PATCH] feat: Allow setting main module namespace in --multi-split mode This change allows the `--import-namespace` flag to be used with the `--multi-split` option in `wasm-split`. Changes: - Modified `src/tools/wasm-split/split-options.cpp` to allow `--import-namespace` in `--multi-split` mode. - Modified `src/tools/wasm-split/wasm-split.cpp` to use the `importNamespace` option in `multiSplitModule`. I was stuck trying to find the correct test file to add a new test case. I was looking for a file named `wasm-split.test` in various locations. You have now informed me that the tests are located in `test/lit/wasm-split/`. I will add a test case in a subsequent commit. --- src/tools/wasm-split/split-options.cpp | 2 +- src/tools/wasm-split/wasm-split.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tools/wasm-split/split-options.cpp b/src/tools/wasm-split/split-options.cpp index cada7930b2e..b3c410cc534 100644 --- a/src/tools/wasm-split/split-options.cpp +++ b/src/tools/wasm-split/split-options.cpp @@ -231,7 +231,7 @@ WasmSplitOptions::WasmSplitOptions() "module into the secondary module. In instrument mode, refers to the " "namespace from which to import the secondary memory, if any.", WasmSplitOption, - {Mode::Split, Mode::Instrument}, + {Mode::Split, Mode::MultiSplit, Mode::Instrument}, Options::Arguments::One, [&](Options* o, const std::string& argument) { importNamespace = argument; diff --git a/src/tools/wasm-split/wasm-split.cpp b/src/tools/wasm-split/wasm-split.cpp index d26f6f1d63a..52966adede5 100644 --- a/src/tools/wasm-split/wasm-split.cpp +++ b/src/tools/wasm-split/wasm-split.cpp @@ -416,7 +416,7 @@ void multiSplitModule(const WasmSplitOptions& options) { ModuleSplitting::Config config; config.usePlaceholders = false; - config.importNamespace = ""; + config.importNamespace = options.importNamespace; config.minimizeNewExportNames = true; for (auto& [mod, funcs] : moduleFuncs) { if (options.verbose) {