Skip to content

[wasm-merge] Make empty function names explicit with --output-manifest#8871

Open
aheejin wants to merge 3 commits into
WebAssembly:mainfrom
aheejin:wasm_merge_duplicate_names
Open

[wasm-merge] Make empty function names explicit with --output-manifest#8871
aheejin wants to merge 3 commits into
WebAssembly:mainfrom
aheejin:wasm_merge_duplicate_names

Conversation

@aheejin

@aheejin aheejin commented Jun 27, 2026

Copy link
Copy Markdown
Member

Even for empty function names, they will be written to a manifest file when --output-manifest is given. But currently we don't print their names in the name section, making them not searchable by wasm-split that use the manifest file.

Even for empty function names, they will be written to a manifest file
when `--output-manifest` is given. But currently we don't print their
names in the name section, making them not searchable by wasm-split that
use the manifest file.
@aheejin aheejin requested a review from tlively June 27, 2026 04:06
@aheejin aheejin requested a review from a team as a code owner June 27, 2026 04:06
Comment thread src/tools/wasm-merge.cpp
// Even if function name is empty, if we were to put it in the output
// manifest, it has to be emitted in the name section.
if (!manifestFile.empty()) {
merged.getFunction(func->name)->hasExplicitName = true;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The function might have been renamed when it was copied to the merged module, so func->name might refer to a different function, right? I think we have to make the name explicit at the point where we add the copied function to the merged module.

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.

Renaming is done in in-place currModule before merging, so it will refer to the same function.

// Rename things in the input module so that there are no conflicts with names
// in the merged module. We do so in place for efficiency.
renameInputItems(input);

Comment thread src/tools/wasm-merge.cpp
for (auto& func : currModule->functions) {
if (!func->imported()) {
funcs.push_back(func->name);
if (!manifestFile.empty()) {

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.

NFC: I wrapped the whole for loop with if(!manifstFile.empty()), given that funcs will only be used for the output manifest file generation.

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