[wasm-split] Set import namespace only when given in multi-split#7966
Merged
Conversation
Currently, in the case of two-way split, we set `config.importNamespace` only when `--import-namespace` option is given, and otherwise just use the default namespace "primary". But in the case of multi split, we set it regardless of whether the option is given, resulting in the "" namespace when no option is given. The default import namespace for multi-split was "" when the multi-split function was first added (WebAssembly#6943), so I'm not sure whether this difference was intentional. In case it wasn't, I think it makes sense to be consistent between two-way split and multi-split. So this in effect changes the import namespace in multi split tests from "" to `primary`. This also factors out the part that moves `WasmSplitOptions` into `Config` to a function.
aheejin
commented
Oct 11, 2025
| "namespace from which to import the secondary memory, if any.", | ||
| WasmSplitOption, | ||
| {Mode::Split, Mode::Instrument, Mode::MultiSplit}, | ||
| {Mode::Split, Mode::MultiSplit, Mode::Instrument}, |
Member
Author
There was a problem hiding this comment.
This just changed the order
tlively
approved these changes
Oct 11, 2025
aheejin
added a commit
to aheejin/binaryen
that referenced
this pull request
Jan 27, 2026
We weren't able to give empty strings as options like `--import-namespace=` or `--import-namespace=""` so far because 1. When `command-line.cpp` parses `--option=`, it parses the next option as its value. For example, if we have `wasm-split ... --import-namespace -o output.wasm`, it parses `-o` as the value for `--import-namespace`. 2. Even if we fix 1, many places in `wasm-split.cpp` checks for `if (options.optionName.size())` so the option with size 0 cannot be processed. This fixes them and allow `--import-namespace` and other similar options take an empty string for a value. Since WebAssembly#7966 changed the default primary export namespace to `primary`, acx_gallery failed to run (which I realized it only recently) and giving it `--import-namespace=""` didn't work because of the above reasons.
aheejin
added a commit
that referenced
this pull request
Jan 28, 2026
We weren't able to give empty strings as options like `--import-namespace=` or `--import-namespace=""` so far because 1. When `command-line.cpp` parses `--option=`, it parses the next option as its value. For example, if we have `wasm-split ... --import-namespace -o output.wasm`, it parses `-o` as the value for `--import-namespace`. 2. Even if we fix 1, many places in `wasm-split.cpp` checks for `if (options.optionName.size())` so the option with size 0 cannot be processed. This fixes them and allow `--import-namespace` and other similar options take an empty string for a value. Since #7966 changed the default primary export namespace to `primary`, acx_gallery failed to run (which I realized it only recently) because it assumed the empty string namespace, and giving it `--import-namespace=""` didn't work because of the above reasons.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, in the case of two-way split, we set
config.importNamespaceonly when--import-namespaceoption is given, and otherwise just use the default namespace "primary". But in the case of multi split, we set it regardless of whether the option is given, resulting in the "" namespace when no option is given.The default import namespace for multi-split was "" when the multi-split function was first added (#6943), so I'm not sure whether this difference was intentional.
binaryen/src/tools/wasm-split/wasm-split.cpp
Line 419 in a9a7f91
In case it wasn't, I think it makes sense to be consistent between two-way split and multi-split. So this in effect changes the import namespace in multi split tests from "" to
primary.This also factors out the part that moves
WasmSplitOptionsintoConfigto a function.