Skip to content

llvm: mangle extern function names for Wasm target#13396

Merged
andrewrk merged 2 commits intoziglang:masterfrom
Luukdegram:fix-12880
Nov 2, 2022
Merged

llvm: mangle extern function names for Wasm target#13396
andrewrk merged 2 commits intoziglang:masterfrom
Luukdegram:fix-12880

Conversation

@Luukdegram
Copy link
Contributor

@Luukdegram Luukdegram commented Nov 1, 2022

When Wasm extern functions contain the same name but have a different module name such as extern "a" vs extern "b" LLVM backend will currently resolve the two functions to the same symbol. By mangling the name of the symbol, we ensure the functions are resolved separately. We mangle the name by applying <name>|<module> where module is also known as the library name.

Closes #12880

Sorry, this wasn't part of the 0.10.0 release, but this should at least make it available in 0.10.1

When Wasm extern functions contain the same name, but have a
different module name such as `extern "a"` vs `extern "b"` LLVM will
currently resolve the two functions to the same symbol. By mangling
the name of the symbol, we ensure the functions are resolved
seperately. We mangle the name by applying <name>|<module> where
module is also known as the library name.
This adds a simple linker test to ensure the built library contains
an import entry for each extern function call that was mangled.
@jedisct1
Copy link
Contributor

jedisct1 commented Nov 2, 2022

Wooo-oooh!

@andrewrk andrewrk merged commit 57dbeb9 into ziglang:master Nov 2, 2022
@Luukdegram Luukdegram deleted the fix-12880 branch November 2, 2022 18:14
andrewrk added a commit that referenced this pull request Nov 2, 2022
llvm: mangle extern function names for Wasm target
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.

Second Webassembly fn import of the same name but different module name is ignored

3 participants