<div dir="ltr"><div dir="ltr">Yes, apply comdats to get the old behavior. This was recently discussed in the swift tracker: <a href="https://github.com/apple/swift/pull/20059">https://github.com/apple/swift/pull/20059</a></div><div>It happened back in 2015, but I don't have any better reference material, unfortunately.</div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Nov 16, 2018 at 11:54 AM Daniele Vettorel via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div>
<div style="direction:ltr;font-family:Tahoma;color:#000000;font-size:10pt">
<div>Hi,</div>
<div><br>
</div>
<div>I'm compiling two files with clang 6.0: testA.c and testB.c.</div>
<div><br>
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.</div>
<div><br>
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. </div>
<div><br>
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?</div>
<div><br>
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.<br>
</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Daniele</div>
</div>
</div>

_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>