Open AllanZyne opened 4 weeks ago
@llvm/issue-subscribers-clang-frontend
Author: Yang Zhao (AllanZyne)
CC @MaskRay
GCC's docs state that #pragma weak takes a "symbol" name which I suspect means not the name in the source code but the potentially mangled symbol name after codegen. Given that I suspect that the bug is that Clang shouldn't be applying name mangling (or any other manipulation) to the arguments to #pragma weak.
A workaround is to combine an alias attribute with the other form of #pragma weak.
// weak.cpp
extern "C" {
int __xxx(void) { return 0; };
int xxx(void) __attribute__((alias("__xxx")));
#pragma weak xxx
}
example:
clang:
compare with gcc: