[llvm-dev] LinkOnceODRLinkage behavior on Windows

Daniele Vettorel via llvm-dev llvm-dev at lists.llvm.org
Fri Nov 16 11:53:15 PST 2018


Hi,

I'm compiling two files with clang 6.0: testA.c and testB.c.

On both files I am running a custom compiler IR-level pass that inserts a zero-initialized global variable called globalVarTest. I set the linkage of such global variable to be LinkOnceODRLinkage.

Now, when I link testA.c and testB.c together (that is, the object files obtained by compiling them separately), the linker complains that there are multiple definitions of globalVarTest.

Isn't LinkOnceODRLinkage supposed to tell the linker that if both definitions match, the symbols is the same and it can therefore pick any of the two definitions when building the final executable?

The same procedure works on Linux. Is this a limitation of the Windows linker? I have been able to achieve the same effect using COMDAT sections but I wonder if that's an appropriate thing to do or if there's a better mechanism to achieve what I want.

Thanks,
Daniele
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20181116/40243dea/attachment.html>


More information about the llvm-dev mailing list