On Sun, Jan 27, 2013 at 4:56 PM, Will Dietz <span dir="ltr"><<a href="mailto:willdtz@gmail.com" target="_blank">willdtz@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
See: <a href="http://llvm.org/bugs/show_bug.cgi?id=14469" target="_blank">http://llvm.org/bugs/show_bug.cgi?id=14469</a> , which I can<br>
reproduce locally using -fsanitize=integer -m32 and by multiplying two<br>
64bit integers together.<br>
<br>
The issue is we emit overflow intrinsics that aren't neatly supported<br>
on the platform and so a call to the supporting runtime is emitted<br>
instead.  Unfortunately libgcc doesn't implement __mulodi4<br>
(compiler-rt does) resulting in the undefined reference you're seeing.<br>
<br>
Unfortunately I don't know a good way to convince clang that<br>
compiler-rt is available and to use that instead of libgcc, and it<br>
seems Motsak in the bug report has the same question.  As a kludge of<br>
a workaround, you can manually add the libclang_rt library for your<br>
architecture to your linker invocation (like:<br>
/path/to/libclang_rt.i386.a), which I've used myself to get around<br>
this issue in the past.<br>
<br>
Perhaps someone more familiar with the issue can comment on the<br>
challenges in resolving the linked bug?<br></blockquote><div><br></div><div>Yes, I've seen this too. The easiest solution might be to include compiler-rt's mulodi4.o in libclang_rt.ubsan.*.a. -- that's the approach I've been using when testing UBSan -- although this doesn't fix the problem for code not using UBSan.<br>
 </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hope this helps,<br>
<br>
~Will<br>
<div class="HOEnZb"><div class="h5"><br>
On Sun, Jan 27, 2013 at 4:22 PM, zapadinsky <<a href="mailto:zapadinsky@gmail.com">zapadinsky@gmail.com</a>> wrote:<br>
> Sorry for bringing this thread up again...<br>
> I've updated clang and compiler-rt to current trunk. Now I have this error<br>
> trying to link against libMyLib.so which was linked with -fsanitize=integer<br>
> switch:<br>
><br>
> clang++ -fsanitize=integer ... -lMyLib -o ...<br>
> /.../libMyLib.so: undefined reference to `__mulodi4'<br>
> clang: error: linker command failed with exit code 1 (use -v to see<br>
> invocation)<br>
><br>
> I'm trying to localize the problem but have no big progress for now. It is<br>
> not reproduced on a simple shared lib project. Any ideas? Without -fsanitize<br>
> all works fine<br>
><br>
><br>
><br>
> --<br>
> View this message in context: <a href="http://clang-developers.42468.n3.nabble.com/fsanitize-undefined-and-shared-libraries-tp4029561p4030098.html" target="_blank">http://clang-developers.42468.n3.nabble.com/fsanitize-undefined-and-shared-libraries-tp4029561p4030098.html</a><br>

> Sent from the Clang Developers mailing list archive at Nabble.com.<br>
> _______________________________________________<br>
> cfe-dev mailing list<br>
> <a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</div></div></blockquote></div><br>