<div dir="ltr">Thanks Reid. The specific symbols in this case are static data structures, not methods.</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jul 14, 2014 at 3:17 PM, Reid Kleckner <span dir="ltr"><<a href="mailto:rnk@google.com" target="_blank">rnk@google.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Apparently lld accepts '-z muldefs' for this purpose.<div><br></div><div>I'm curious if you can't solve this easily at the C++ language level, though.</div>

<div><br></div><div>This explicit instantiation for example will be coalesced by the linker:</div>
<div><br></div><div><div>template <typename T> struct A {</div><div>  int foo() { return sizeof(T); }</div><div>};</div><div>template struct A<int>;</div></div><div><br></div><div>This explicit specialization also defines inline functions which will be coalesced:</div>


<div><br></div><div><div>template <typename T> struct A {</div><div>  int foo() { return sizeof(T); }</div><div>};</div><div>template <> struct A<int> {</div><div>  int foo() { return 4; }</div><div>};</div>


</div><div><br></div><div>Only this out of line method definition for a fully specialized class template generates strong symbols:</div><div><br></div><div><div>template <typename T> struct A {</div><div>  int foo() { return sizeof(T); }</div>


<div>};</div><div>template <> struct A<int> {</div><div>  int foo();</div><div>};</div><div>int A<int>::foo() { return 4; }</div></div><div><br></div><div>In which case, if I want them coalesced, I can probably just add the 'inline' keyword.</div>


</div><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div class="h5">On Mon, Jul 14, 2014 at 2:48 PM, Talin <span dir="ltr"><<a href="mailto:viridia@gmail.com" target="_blank">viridia@gmail.com</a>></span> wrote:<br>

</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
<div dir="ltr">I'm working with a C++ code generator that produces multiple instances of the same definition (specifically, it generates explicit instantiations of the same template in multiple output source files). With the GNU ld, I'm able to link successfully using the --allow-multiple-definitions flag; however this flag is not supported in llvm-ld.<div>




<br></div><div>Is there any way I can either convince llvm-ld to accept this without producing an error, or alternatively is there any way in C++ that I can trick the compiler into making these definitions linkonce?<span><font color="#888888"><br>


<div>

<div><br></div>-- <br>-- Talin
</div></font></span></div></div>
<br></div></div>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>-- Talin
</div>