-
Notifications
You must be signed in to change notification settings - Fork 836
[wasm-split] Allow empty string for options #8243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initial comment
src/tools/wasm-split/split-options.h
Outdated
| std::string importNamespace; | ||
| bool hasImportNamespace = false; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
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.