This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Does gcc enable -fPIC by default?


On Thu, 24 Jan 2019, Peng Yu wrote:

> Is it because gcc enables -fPIC by default, but clang does not? I
> don't see this documented. Or it is due to some other reasons. On what
> systems gcc enables -fPIC by default?

There are platforms (e.g. Darwin) where all code is implicitly PIC by
convention (but there Clang will emit position-independent code as well),
but in your case the issue is likely because in your distribution GCC
is configured to produce PIE by default (see --enable-default-pie in
output of gcc -v):

> 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

   ^^^^^^^^^
   (as the error message hints)

Hope that helps.
Alexander


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]