Skip to content

Improve fallback names for imported and exported items - #9079

Open
GtechGovind wants to merge 1 commit into
WebAssembly:mainfrom
GtechGovind:fix/use-import-export-names
Open

Improve fallback names for imported and exported items#9079
GtechGovind wants to merge 1 commit into
WebAssembly:mainfrom
GtechGovind:fix/use-import-export-names

Conversation

@GtechGovind

Copy link
Copy Markdown

Fixes #2504

Summary

  • use import field names as fallbacks for imported items without explicit name-section entries
  • pre-scan exports and use the first export name as the fallback for unnamed defined items
  • preserve explicit name-section priority and deduplicate fallback names through the existing naming logic

Testing

  • cmake --build build --target wasm-as wasm-dis wasm-opt -j4
  • PATH=/tmp/binaryen-sep6-venv/bin:$PATH /tmp/binaryen-sep6-venv/bin/python build/bin/binaryen-lit test/lit/binary -j4 (21 passed)

@GtechGovind
GtechGovind marked this pull request as ready for review September 6, 2026 05:29
@GtechGovind
GtechGovind requested a review from a team as a code owner September 6, 2026 05:29
@GtechGovind
GtechGovind requested review from tlively and removed request for a team September 6, 2026 05:29
@kripken

kripken commented Sep 8, 2026

Copy link
Copy Markdown
Member

(looks like there are test failures)

Comment thread src/wasm/wasm-binary.cpp
Comment on lines +2790 to +2792
memoryNames,
numImports + i,
getFallbackName(memoryExportNames, numImports + i, makeName("", i)),

@tlively tlively Sep 9, 2026

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.

It would be good to clean up the duplication of passing in memoryNames and numImports + i in two places here.

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.

Improve scheme to generating internal names

3 participants