So everything in Rawhide must be compiled with -fPIC?

Jakub Jelinek jakub at
Thu Feb 19 10:45:01 UTC 2015

On Thu, Feb 19, 2015 at 10:37:46AM +0000, Richard W.M. Jones wrote:
> On Thu, Feb 19, 2015 at 11:35:17AM +0100, Jakub Jelinek wrote:
> > On Thu, Feb 19, 2015 at 10:30:50AM +0000, Richard W.M. Jones wrote:
> > > info gcc, of course yes.  -DPIC is not documented at all, and the
> > > various pie/pic options are obscure to say the least.
> > 
> > Why should -DPIC be documented?  -D is documented.  -DPIC means define
> > macro PIC to 1.  There is no magic in that beyond, just a convention,
> > used e.g. by libtool, so that some sources can do things conditional on
> > whether they are compiled as position independent or not.  Of course, gcc
> > also predefines __pic__/__PIC__/__pie__/__PIE__ macros depending on command
> > line options.
> Can I ask you a simple question?  Which of:
> -fPIE
> -fpie
> should I use when compiling and/or linking binaries for Rawhide?

It depends.  If you want to compile/link position independent binaries,
use -fpie (-fPIE if you get linker errors on certain architectures if your
binaries are too big) to compile and -pie to link.
If you want normal binaries, no specific options in either case.
If you want to follow the redhat-rpm-config %_hardened_build, i.e. build
PIEs if it is 1 and normal binaries if it is 0, make sure you pass
%{optflags} aka $RPM_OPT_FLAGS to the compiler driver when compiling and
%{__global_ldflags} to the compiler driver when linking.
Overriding CFLAGS/CXXFLAGS globally to -fpie or -fPIE and LDFLAGS to -pie
if your package builds both binaries and shared libraries won't really work,
because you might end up compiling shared library objects with -fpie rather
than -fpic or try to link shared libraries with -shared -pie.

I haven't seen any recent redhat-rpm-config change in koji though.


More information about the devel mailing list