<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Sep 3, 2021 at 2:20 PM Fangrui Song <<a href="mailto:maskray@google.com">maskray@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 2021-09-03, Oleg Smolsky via llvm-dev wrote:<br>
>Wow, that's interesting! Thank you for hint, Anton!<br>
><br>
>How did this dependency come into the build? I don't see any direct<br>
>references to the symbol... so, is it something acquired transitively?... I<br>
>am surprised that some (supposedly portable) code contains a buried libgcc<br>
>dependency... I'm not linking binary artifacts here...<br>
<br>
__divmodti4 is a library function for "Divides 128-bit signed integers w/ remainder".<br>
Presumably libc++ has some int128 division which generates the reference.<br>
libc++ has int128 usage in chrono/filesystem/etc.  I suspect chrono may<br>
have int128 division, though I don't find the symbol in my build.<br>
</blockquote><div><br></div><div>Oh, right! Thank you very much, Fangrui!</div><div><br></div><div>The issue comes down to the discrepancy between libgcc_s versions. I have an alternative compiler and that's how Clang was built. That alternative compiler has the right support library:</div><div><br></div>$ nm /opt/gcc-11/lib64/libgcc_s.so.1 | grep __divmodti4<br>00000000000061d0 T __divmodti4<br><div><br></div><div>And Clang's `ld` invocation has this trailer:</div><div><br></div><div>..."-lgcc_s" "-lgcc" "-lc" "-lgcc_s" "-lgcc" "/usr/lib/gcc/x86_64-linux-gnu/5.4.0/crtend.o" "/usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../x86_64-linux-gnu/crtn.o"</div><div><br></div><div>Here is it trying and failing to find the symbol in the system's compiler's libs. </div><div><br></div><div>So, naturally, I can fix this with custom flags as well as `--gcc-toolchain=/opt/gcc-11` (I forgot about that completely).</div><div><br></div><div>Thanks again!</div><div><br>Hopefully this message will help posterity...</div><div><br></div><div>Oleg.</div></div></div>