Skip to content

Conversation

@marxin
Copy link
Contributor

@marxin marxin commented Dec 19, 2025

In rare cases (cowsay), we have multiple function indices share a common function name (dummy in my case). Similarly to wasm2wat, provide a unique name to the function (useful for --compiler-debug-dir option).

Copilot AI review requested due to automatic review settings December 19, 2025 13:35
@marxin marxin requested a review from syrusakbary as a code owner December 19, 2025 13:35
In rare cases (cowsay), we have multiple function indices sharing
a common function name (`dummy` in my case). Similarly to wasm2wat,
provide a unique name to the function (useful for `--compiler-debug-dir` option).
@marxin marxin force-pushed the preserve-unique-function-names branch from 696642d to 78a5431 Compare December 19, 2025 13:37
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses duplicate function names in WebAssembly modules by ensuring each function receives a unique name, similar to the behavior in wasm2wat. This is particularly useful for the --compiler-debug-dir option when analyzing modules with duplicate function names (e.g., multiple functions named "dummy" in cowsay).

Key Changes:

  • Modified name section parsing to detect and handle duplicate function names by appending numeric suffixes (.0, .1, etc.)
  • Changed the API from incrementally declaring individual function names to batching all function names and declaring them at once

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
lib/compiler/src/translator/sections.rs Added duplicate name detection logic using HashSet and generates unique names with numeric suffixes; batches function names in a HashMap before declaration
lib/compiler/src/translator/environ.rs Refactored API to accept a HashMap of all function names at once instead of declaring them individually

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@marxin marxin force-pushed the preserve-unique-function-names branch from 99729f0 to 78a5431 Compare December 19, 2025 14:36
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