[wasm-split] Allow empty string for options#8243
Merged
aheejin merged 5 commits intoWebAssembly:mainfrom Jan 28, 2026
Merged
Conversation
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.
tlively
reviewed
Jan 27, 2026
src/tools/wasm-split/split-options.h
Outdated
Comment on lines
69
to
70
| std::string importNamespace; | ||
| bool hasImportNamespace = false; |
Member
There was a problem hiding this comment.
Let's make these all std::optional<std::string> instead of having separate bools.
tlively
approved these changes
Jan 28, 2026
| #define wasm_tools_wasm_split_options_h | ||
|
|
||
| #include "tools/tool-options.h" | ||
| #include <optional> |
Member
There was a problem hiding this comment.
This system include should go above the non-system includes.
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.
We weren't able to give empty strings as options like
--import-namespace=or--import-namespace=""so far becausecommand-line.cppparses--option=, it parses the next option as its value. For example, if we havewasm-split ... --import-namespace -o output.wasm, it parses-oas the value for--import-namespace.wasm-split.cppchecks forif (options.optionName.size())so the option with size 0 cannot be processed.This fixes them and allow
--import-namespaceand 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.