[PATCH] D28596: [compiler-rt] General definition for weak functions.
Marcos Pividori via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 18 16:18:33 PST 2017
mpividori added a comment.
Hi @kubabrecka ,
Thanks for your suggestions.
>> I need to define a function with a different name adding the suffix "__def" and also define a weak alias, and declare the original function. So, definitely this can not be accomplished in that way.
>
> Have you looked into e.g. changing the exported symbol names with `/export:...=...`? Couldn't this help? Could we use it to basically switch the two functions?
Unfortunately, `/export:...=...` doesn't help.
> If there's really no other way, then I suggest either:
>
> 1. Changing WEAK_DEF to drop the extra set of parentheses to have parity with INTERCEPTOR macro. I.e.: `WEAK_DEF(void, OnPrint, const char *str) { code }`.
Ok. Yes, I agree. I will do that.
> 2. Having a macro only around the function name, i.e.: `WEAK_ATTRIBUTE void WEAK_NAME(OnPrint)(const char *str) { code }`.
I can't do that because not only I need to change the name, I also need to add a linker pragma `WIN_WEAK_ALIAS(OnPrint, OnPrint__def)` and declare `OnPrint`.
I mean, for non-windows `OnPrint` definition will be:
void OnPrint(const char *str) {
// Default implementation
}
And for Windows, it will be:
void OnPrint__def(const char *str) {
// Default implementation
}
void OnPrint(const char *str);
WIN_WEAK_ALIAS(OnPrint, OnPrint__def)
Thanks.
https://reviews.llvm.org/D28596
More information about the llvm-commits
mailing list