Skip to content

wasm-merge: When fixing name collisions, do not collide in either module#8836

Merged
kripken merged 7 commits into
WebAssembly:mainfrom
kripken:merge-conflict-squared
Jun 12, 2026
Merged

wasm-merge: When fixing name collisions, do not collide in either module#8836
kripken merged 7 commits into
WebAssembly:mainfrom
kripken:merge-conflict-squared

Conversation

@kripken

@kripken kripken commented Jun 12, 2026

Copy link
Copy Markdown
Member

When a name $a appears in both modules, we picked a new name not in
the first module. But if the new name, something like $a_1, is in the
second module, that is also a problem: we will get mixed up about what in
the second module is what. To avoid this, when handling a name collision,
just pick a totally novel name.

Fixes #8835

@kripken kripken requested a review from a team as a code owner June 12, 2026 16:54
@kripken kripken requested review from aheejin and removed request for a team June 12, 2026 16:54
Comment thread src/tools/wasm-merge.cpp Outdated
auto name = Names::getValidFunctionName(merged, curr->name);
auto name = getValidName(
curr->name,
[&](Name test) { return merged.getFunctionOrNull(test); },

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.

This could all be a little more concise if you just passed a method pointer, e.g. Module::getFunctionOrNull, and getValidName took care of calling the method on both merged and input.

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.

Done, it is indeed a little shorter that way.

@kripken kripken merged commit c21e492 into WebAssembly:main Jun 12, 2026
16 checks passed
@kripken kripken deleted the merge-conflict-squared branch June 12, 2026 17:57
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.

wasm-merge crash on multimodule kotlin wasm app

2 participants