[Development] Qt, fPIE, fPIC and changes coming in Qt 5.4.2

Thiago Macieira thiago.macieira at intel.com
Thu May 28 19:34:31 CEST 2015

On Thursday 28 May 2015 12:24:55 Lisandro Damián Nicanor Pérez Meyer wrote:
> Hi! I've been watching the recent changes in Qt 5.4.2 due to gcc5. I have
> some doubts I would like to clear.

Hi Lisandro

> Please feel free to correct me and/or expand whatever you think it's worth.
> As I understand the issue is that gcc5 created a BIC in qt5 due to us using
> -Bsymbolic and -fPIE, so the solution was to use -fPIC instead.

Actually, no. Long-story short: we relied on an undocumented, side-effect 
behaviour in GCC that using -fPIE would avoid copy relocations in binaries. As 
noticed previously in other platforms (ARM had this problem), -fPIE does not 
imply no-copy-relocation. GCC 5 made that change for x86 too.

So you need to use -fPIC now. The version of GCC requires that change varies 
per platform. I don't remember (and have no interest in finding out) which 
version was for ARM. For x86, that's 5.0.

> That means that applications need to use -fPIC when building against Qt
> 5.4.2 too.

We're discussing whether we should enforce that for all GCC versions or 
whether to enforce only for GCC >= 5. Otherwise, you're right.

> * Will the same happen with Qt4? Do we need to patch it?

Technically yes, in practice no. Everyone who enabled -reduce-relocations, 
needs to use it. But that is not enabled by default in Qt 4.

> * Suppose I now push Qt 5.4.2 compiled against gcc4.9 to Debian: do I need
> to recompile whatever depends on Qt5? I would expect I shouldn't, but
> better asking :)

You need to recompile anything you compiled using GCC 5. Everything that had 
been compiled with 4.9 should be fine.

On x86 and x86-64.

Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center

More information about the Development mailing list