Add @dllname decorator for custom exported symbol names - #320
Merged
Conversation
- Introduced DLL_NAME attribute for functions, methods, variables, and accessors. - Updated relevant classes and methods to handle DLL_NAME during export and import. - Added tests to ensure correct handling of @dllname in declarations.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@dllname("custom_name")decorator sets the symbol an exported function, method, accessor or variable gets in a shared library / DLL. For example@dllname("custom_add") export function add(...)is exported ascustom_addinstead ofM.add.dllnameattribute thatLowerToLLVMforwards as an LLVM function attribute, andExportFixPassrenames the function (all uses follow the rename).TypeScriptToLLVMLoweringPassrenames the global symbol and all its uses before lowering. A dynamic-import copy in an importer is not renamed.DeclarationPrinteremits@dllname(...)into__declsfor functions, variables, methods and accessors, and every runtime symbol lookup (dynamic import of functions/variables, static/constructor methods, vtable slots, accessors, indexers) resolves the custom name.Test plan
test-compile-shared-export-import-dllname: renamed function, intra-library call, renamed variable changed through a library function, renamed static/instance methods, renamed getter/setterDeclarationPrinterTest.*59/59 pass, including 5 new dllname casesllvm-objdump -pon the built DLL showscustom_add,custom_counter,calc_twice,calc_scale,calc_get_double,calc_set_doubleand noM.add/M.counter/M.Calc.*entries for them🤖 Generated with Claude Code