-
Notifications
You must be signed in to change notification settings - Fork 12.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SandboxIR] Add extern templates for GlobalWithNodeAPI #111940
Conversation
These symbols will need to be explicitly exported for SandboxIRTests when LLVM is built as shared library on window with explicitly visibility macros are enabled. This is part of the work to enable LLVM_BUILD_LLVM_DYLIB and plugins on window.
I am trying to understand why these would need to be explicitly exported for SandboxIRTests. The tests don't use the template directly. There are other similar CRTPs, like the |
idk if this helps much but these are the linker errors i get without this change, this is a debug build so a lot of stuff is not inlined:
I think those might of got exported from visibility macros that will be added on classes that derived from an instantiation of them like here https://github.com/fsfod/llvm-project/blob/fdf88b914978d57c6c75892a3133d4476b8995d1/llvm/include/llvm/SandboxIR/Instruction.h#L411 I just didn't want add them all in this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG, please add a brief comment that this is for LLVM_BUILD_LLVM_DYLIB
.
@@ -797,6 +798,24 @@ class GlobalWithNodeAPI : public ParentT { | |||
} | |||
}; | |||
|
|||
extern template LLVM_TEMPLATE_ABI GlobalIFunc & |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment that this is for LLVM_BUILD_LLVM_DYLIB
.
@@ -301,6 +302,24 @@ template class GlobalWithNodeAPI<GlobalVariable, llvm::GlobalVariable, | |||
template class GlobalWithNodeAPI<GlobalAlias, llvm::GlobalAlias, GlobalValue, | |||
llvm::GlobalValue>; | |||
|
|||
template LLVM_EXPORT_TEMPLATE GlobalIFunc & |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
This doesn't look right - why do we instantiate each of these templates twice? I'm seeing warnings from clang-cl now since there are duplicate instantiations between
|
I have double checked again for shared library debug builds with clang-cl and the template function symbols are not exported without them being explicitly exported from the source file, explicit template instantiation of containing classes is not enough. I could add some clang warning suppression macros around them though. |
Do they need to be explicitly exported in both the header and the source file? That doesn't make a lot of sense to me. The instantiations look identical, as the warning implies. |
These symbols will need to be explicitly exported for SandboxIRTests when LLVM is built as shared library on window with explicitly visibility macros are enabled. This is part of the work to enable LLVM_BUILD_LLVM_DYLIB and plugins on windows.
These symbols will need to be explicitly exported for SandboxIRTests when LLVM is built as shared library on window with explicitly visibility macros are enabled.
This is part of the work to enable LLVM_BUILD_LLVM_DYLIB and plugins on window.