<div dir="ltr">Yep, llvm::GlobalValue::ExternalWeakLinkage.</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Feb 12, 2014 at 2:31 AM, Carl <span dir="ltr"><<a href="mailto:name.is.carl@gmail.com" target="_blank">name.is.carl@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">So instead of using linkagetypes.weak I should use externalweaklinkage ?</p>
<div class="gmail_quote">Le 11 févr. 2014 18:29, "Reid Kleckner" <<a href="mailto:rnk@google.com" target="_blank">rnk@google.com</a>> a écrit :<div><div class="h5"><br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">You'd have to use extern_weak linkage. Clang compiles the foo declaration to:<div><div>$ clang -cc1 -emit-llvm -o - t.c | grep declare.*@foo</div><div>declare extern_weak i32 @foo(...) #1</div></div><div>
<br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Feb 11, 2014 at 4:16 AM, Carl <span dir="ltr"><<a href="mailto:name.is.carl@gmail.com" target="_blank">name.is.carl@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">Thanks for your clear answer. Do you know what modifier should I use to declare such weak symbols in my llvm intermediate code?</p>
<p dir="ltr">So that it can be compiled to the .o file with the weak attribute ?</p>
<div class="gmail_quote">Le 10 févr. 2014 19:44, "Reid Kleckner" <<a href="mailto:rnk@google.com" target="_blank">rnk@google.com</a>> a écrit :<div><div><br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">COFF doesn't support the same kind of concept of 'weak' that ELF does. This is the issue that users brought up with mingw: <a href="https://sourceware.org/bugzilla/show_bug.cgi?id=9687" target="_blank">https://sourceware.org/bugzilla/show_bug.cgi?id=9687</a><div>
<br></div><div>Instead, COFF supports weak externals, which you can use like:<br></div><div><div><div><br></div><div>$ cat t.c</div><div>int foo() __attribute__((weak));</div><div>int main() {</div><div> if (foo)</div><div>
return foo();</div><div> return 13;</div><div>}</div><div><br></div><div>$ cat t2.c</div><div>int foo() {</div><div> return 42;</div><div>}</div><div><br></div><div>$ clang t.c t2.c -o t && ./t ; echo $?</div>
<div>42</div></div><div><br></div><div>So, we got the definition of foo from t2.c. If t2.c hadn't been linked, foo would be null.</div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Feb 10, 2014 at 6:28 AM, Carl <span dir="ltr"><<a href="mailto:name.is.carl@gmail.com" target="_blank">name.is.carl@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br><div class="gmail_quote">Hello,<br><br>I'm generating C code (and the resulting obj files) using llvm 3.4 for both unix and windows.<br>
And I use the dreaded weak references, that, for windows, are not too widely supported.<br>
<br>When I link my application on linux, I have no issue.<br>
But when I'm doing the same on windows using mingw I got a duplicate symbol error : <br><span style="font-family:courier new,monospace"><br>..\robovm-0.0.8\lib\robovm-rt.jar\dalvik\system\BlockGuard$BlockGuardPolicyException.class.o:(.text$dalvik_system_BlockGuard$24BlockGuardPolicyException_getPolicy__I_lookup[_dalvik_system_BlockGuard$24BlockGuardPolicyException_getPolicy__I_lookup]+0x0): multiple definition of `dalvik_system_BlockGuard$24BlockGuardPolicyException_getPolicy__I_lookup'<br>
..\Temp\robovm3774596063679264132.tmp\linker.o:(.text+0x340): first defined here<br>..\robovm-0.0.8\lib\robovm-rt.jar\dalvik\system\BlockGuard$BlockGuardPolicyException.class.o:(.text$dalvik_system_BlockGuard$24BlockGuardPolicyException_getPolicyViolation__I_lookup[_dalvik_system_BlockGuard$24BlockGuardPolicyException_getPolicyViolation__I_lookup]+0x0): multiple definition of `dalvik_system_BlockGuard$24BlockGuardPolicyException_getPolicyViolation__I_lookup'<br>
..\Temp\robovm3774596063679264132.tmp\linker.o:(.text+0x350): first defined here<br>..\robovm-0.0.8\lib\robovm-rt.jar\dalvik\system\BlockGuard$BlockGuardPolicyException.class.o:(.text$dalvik_system_BlockGuard$24BlockGuardPolicyException_getMessage__Ljava_lang_String$3B_lookup[_dalvik_system_BlockGuard$24BlockGuardPolicyException_getMessage__Ljava_lang_String$3B_lookup]+0x0): multiple definition of `dalvik_system_BlockGuard$24BlockGuardPolicyException_getMessage__Ljava_lang_String$3B_lookup'<br>
<br></span>Because those symbols are declared as weak.<br><br>What is the status about the support of weak symbols on windows?<br>Are they supposed to work? Are they supposed to <i>never </i>work ?<br><br>Do you know any way to fix this (or work around it). I use weak symbols everywhere in my code generation, so I would prefer a fix that doesn't involve to rewrite my code.<br>
<br>I'm considering rewriting the obj files using objcopy. <br>Has this any chance to work ?<br>Here are the o.<br><br>Cheers,<br>Carl.<br>
</div><br>
<br>_______________________________________________<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></div></div>
</blockquote></div><br></div>
</blockquote></div></div></div>
</blockquote></div><br></div>