So everything in Rawhide must be compiled with -fPIC?

Richard W.M. Jones rjones at
Thu Feb 19 09:37:16 UTC 2015

On Thu, Feb 19, 2015 at 10:22:03AM +0100, Jakub Jelinek wrote:
> On Thu, Feb 19, 2015 at 09:14:32AM +0000, Richard W.M. Jones wrote:
> > 
> >
> > 
> > Basically everything in Rawhide which uses the normal RPM
> > opt flags will now have to be compiled with -fPIC, otherwise
> > you get errors like:
> > 
> > /usr/bin/ld: /tmp/ccqyK5ia.o: relocation R_X86_64_32S against `virConnectOpen' can not be used when making a shared object; recompile with -fPIC
> > 
> > This is somewhat surprising ..
> Of course not.  But, anything you link with
> -specs=/usr/lib/rpm/redhat/redhat-hardened-ld
> has to be compiled with
> -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
> The latter will supply -fPIE by default if you don't specify
> -fno-pic/-fpic/-fPIC/-fpie/-fPIE explicitly on the command line,
> similarly to how redhat-hardened-ld supplies -pie if -shared is not given.
> The rule is simple, objects to be linked into shared libraries
> have to be compiled with -fpic or -fPIC.
> Objects linked into position independent binaries have to be compiled
> with -fpie or -fPIE or -fpic or -fPIC (the latter two being less efficient
> for PIEs, on the other side can be linked into shared libraries too).
> Objects linked into position dependent binaries can be compiled with any of
> -fno-pic/-fpic/-fPIC/-fpie/-fPIE (-fno-pic is the default if you don't use
> -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 and is the most efficient
> -flag for position dependent binaries).

The thing is, I'm not adding -specs=/usr/lib/rpm/redhat/redhat-hardened-ld
explicitly in the real program.  It's being added to everything by
something in RPM.  I'm not exactly sure what, maybe %{configure}?

So I don't know how to control this behaviour in a real autotools-using


Richard Jones, Virtualization Group, Red Hat
Read my programming and virtualization blog:
virt-builder quickly builds VMs from scratch

More information about the devel mailing list