Skip to content

Conversation

@aheejin
Copy link
Member

@aheejin aheejin commented 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 #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.

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 aheejin requested a review from tlively January 27, 2026 22:19
Copy link
Member

@tlively tlively left a comment

Choose a reason for hiding this comment

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

Initial comment

Comment on lines 69 to 70
std::string importNamespace;
bool hasImportNamespace = false;
Copy link
Member

Choose a reason for hiding this comment

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

Let's make these all std::optional<std::string> instead of having separate bools.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea. Done: 5c4a57c

#define wasm_tools_wasm_split_options_h

#include "tools/tool-options.h"
#include <optional>
Copy link
Member

Choose a reason for hiding this comment

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

This system include should go above the non-system includes.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@aheejin aheejin merged commit f9a3380 into WebAssembly:main Jan 28, 2026
17 checks passed
@aheejin aheejin deleted the empty_options branch January 28, 2026 04:56
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