[llvm-dev] [EXTERNAL] Re: Linking issue with clang/libc++

Fangrui Song via llvm-dev llvm-dev at lists.llvm.org
Fri Sep 3 14:19:59 PDT 2021


On 2021-09-03, Oleg Smolsky via llvm-dev wrote:
>Wow, that's interesting! Thank you for hint, Anton!
>
>How did this dependency come into the build? I don't see any direct
>references to the symbol... so, is it something acquired transitively?... I
>am surprised that some (supposedly portable) code contains a buried libgcc
>dependency... I'm not linking binary artifacts here...

__divmodti4 is a library function for "Divides 128-bit signed integers w/ remainder".
Presumably libc++ has some int128 division which generates the reference.
libc++ has int128 usage in chrono/filesystem/etc.  I suspect chrono may
have int128 division, though I don't find the symbol in my build.

`clang -stdlib=libc++ a.o '-###'` prints the linker command line.
You should be able to find an argument -lgcc_s.
Adding -Wl,-t and removing `-###` should tell you which libgcc_s.so.1
file is picked.
You can dump its symbol table and inspect where __divmodti4 is there.

This issue is some installation or setup problem.


>On Fri, Sep 3, 2021 at 12:29 PM Anton Korobeynikov <anton at korobeynikov.info>
>wrote:
>
>> This symbol is a part of compiler runtime. In your case – you need to
>> link libgcc.
>>
>> On Fri, Sep 3, 2021 at 9:01 PM Oleg Smolsky via llvm-dev
>> <llvm-dev at lists.llvm.org> wrote:
>> >
>> > Folks, I'm hitting a funky issue while building a Boost tool with
>> Clang/libc++. Here is the compiler invocation:
>> >
>> > $ /opt/llvm-12/bin/clang++ -std=c++11 -O2 -stdlib=libc++
>> -Wno-mismatched-tags -O2 -s -DNDEBUG builtins.cpp class.cpp ...........
>> pathunix.cpp -o b2
>> >
>> > And I get this:
>> >
>> > /opt/llvm-12/bin/../lib/libc++.so.1: undefined reference to
>> `__divmodti4 at GCC_7.0.0'
>> >
>> > Clang itself was built with GCC-11... so I fail to understand where this
>> symbol is coming from. Can someone shed some light on this please?
>> >
>> > Thanks in advance,
>> > Oleg.
>> > _______________________________________________
>> > LLVM Developers mailing list
>> > llvm-dev at lists.llvm.org
>> > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>>
>>
>>
>> --
>> With best regards, Anton Korobeynikov
>> Department of Statistical Modelling, Saint Petersburg State University
>>
>>

>_______________________________________________
>LLVM Developers mailing list
>llvm-dev at lists.llvm.org
>https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev



More information about the llvm-dev mailing list