[cfe-dev] Why clang may not be compatible with gcc for .a file generation?

Peng Yu via cfe-dev cfe-dev at lists.llvm.org
Thu Jan 24 03:48:24 PST 2019


clang works fine.

On Thu, Jan 24, 2019 at 2:45 AM Csaba Raduly <rcsaba at gmail.com> wrote:

> Hi,
>
> On Thu, Jan 24, 2019 at 4:00 AM Peng Yu via cfe-dev <
> cfe-dev at lists.llvm.org> wrote:
>
>> Hi,
>>
>> I have the following trace.c file compiled with the following command
>> with clang.
>>
>> $ clang -Wall -pedantic -c -o trace.o trace.c
>> $ ar cr  libtrace.a trace.o
>> $ ranlib libtrace.a
>>
>> Then, I run configure from a GNU package, which gives the following
>> error. It asks to recompile the .a with -fPIC. Is it because gcc and
>> clang has different default on whether -fPIC is enabled? Could anybody
>> help explain why there is such a difference? Thanks.
>>
>> configure:3772: gcc -g -finstrument-functions
>> -L/root/linux/bin/wrappercomposite/src/xplat/llvmxplat/src/mkvar/bin/Linux
>> conftest.c -ltrace >&5
>> /usr/bin/ld:
>> /root/linux/bin/wrappercomposite/src/xplat/llvmxplat/src/mkvar/bin/Linux/libtrace.a(trace.o):
>> relocation R_X86_64_32S against `.bss' can not be used when making a
>> PIE object; recompile with -fPIC
>> /usr/bin/ld: final link failed: Nonrepresentable section on output
>>
>>
> What happens if you run this command with clang instead of gcc ?
>
>
> Csaba
> --
> You can get very substantial performance improvements
> by not doing the right thing. - Scott Meyers, An Effective C++11/14 Sampler
> So if you're looking for a completely portable, 100% standards-conformat
> way
> to get the wrong information: this is what you want. - Scott Meyers
> (C++TDaWYK)
>
-- 
Regards,
Peng
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20190124/7e10c6e3/attachment.html>


More information about the cfe-dev mailing list