Skip to content

[wasm-split] Set import namespace only when given in multi-split#7966

Merged
aheejin merged 3 commits into
WebAssembly:mainfrom
aheejin:multi_split_import_namespace
Oct 11, 2025
Merged

[wasm-split] Set import namespace only when given in multi-split#7966
aheejin merged 3 commits into
WebAssembly:mainfrom
aheejin:multi_split_import_namespace

Conversation

@aheejin
Copy link
Copy Markdown
Member

@aheejin aheejin commented Oct 11, 2025

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 (#6943), so I'm not sure whether this difference was intentional.

config.importNamespace = "";

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.

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 aheejin requested a review from tlively October 11, 2025 04:47
"namespace from which to import the secondary memory, if any.",
WasmSplitOption,
{Mode::Split, Mode::Instrument, Mode::MultiSplit},
{Mode::Split, Mode::MultiSplit, Mode::Instrument},
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just changed the order

@aheejin aheejin merged commit 253ed6c into WebAssembly:main Oct 11, 2025
16 checks passed
@aheejin aheejin deleted the multi_split_import_namespace branch October 13, 2025 05:53
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants