Arch Linux

Please read this before reporting a bug:

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!

FS#45283 - [qt5-base] -reduce-relocations breaks build for many downstream project

Attached to Project: Arch Linux
Opened by Matt Corallo (BlueMatt) - Tuesday, 09 June 2015, 20:28 GMT
Last edited by Felix Yan (felixonmars) - Monday, 13 July 2015, 03:30 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Felix Yan (felixonmars)
Architecture All
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No


Description: qt5-base recently started being built with -reduce-relocations, which breaks many downstream project builds with the error /usr/include/qt/QtCore/qglobal.h:1050:4: error: #error "You must build your code with position independent code if Qt was built with -reduce-relocations. " "Compile your code with -fPIC (-fPIE is not enough)."
See and
This task depends upon

Closed by  Felix Yan (felixonmars)
Monday, 13 July 2015, 03:30 GMT
Reason for closing:  Fixed
Additional comments about closing:  specified -no-reduce-relocations in 5.5.0-1
Comment by Evangelos Foutras (foutrelis) - Wednesday, 10 June 2015, 08:13 GMT
The requirement for -fPIC is due to an upstream change:

Not an Arch decision or issue.
Comment by Matt Corallo (BlueMatt) - Wednesday, 10 June 2015, 08:20 GMT
Indded, but it seems Qt suggests we build without -reduce-relocations to fix this issue.
Comment by Evangelos Foutras (foutrelis) - Wednesday, 10 June 2015, 08:38 GMT
I have seen that suggestion from Cory Fields in the bitcoin pull request; I don't think upstream Qt has ever suggested that.

While we do specify -reduce-relocations in the Qt5 PKGBUILD, it is also the default on x86 platforms with linker support for -Bsymbolic-functions.

Finally, it's worth noting that -fPIC is added automatically by cmake and qmake; only projects using autotools need to add it manually.
Comment by Cory Fields (coryfields) - Wednesday, 10 June 2015, 21:30 GMT
Hi Evangelos, thanks for discussing.

The issue here is that Qt's -reduce-relocations option reduces our ability to harden our binaries.

With newer versions of GCC, -Bsymbolic-functions no longer plays nice with PIEs. While we could certainly downgrade to -fPIC instead, it would be detrimental to security. This is not a matter of us needing to set the correct flags, it's a matter of Qt's build breaking legitimate functionality.

I don't think it's reasonable for upstream libs to be setting policy for downstream applications, especially when it involves known divergence from the abi.

I think the -reduce-relocations option really needs to be reconsidered by distros now that GCC5 is in use.
Comment by Evangelos Foutras (foutrelis) - Wednesday, 10 June 2015, 22:30 GMT
Thank you for taking the time to discuss this issue here; your input as
a downstream project developer is certainly valuable.

I agree that the current situation is not ideal but I also feel that
these concerns need to be raised at the Qt bug tracker. Assuming that
no resolution is reached by Qt upstream and -reduce-relocations remains
enabled by default (along with the -fPIC requirement) then downstream
projects using autotools will need to adjust and build with -fPIC.
Comment by Cory Fields (coryfields) - Wednesday, 10 June 2015, 23:03 GMT
Unfortunately, there is no way for us to adjust here as a downstream, though. Building with -fPIC does not fix the issue.

To clarify: if Qt was built with -reduce-relocations, there is no way for us to create a valid PIE binary. This is because -reduce-relocations breaks psABI compliance.

Projects using other buildsystems (Cmake, Qmake, etc) will suffer from this issue as well. I suspect that soon most distros will disable this option, prompting Qt to disable it by default.
Comment by Evangelos Foutras (foutrelis) - Wednesday, 10 June 2015, 23:21 GMT
What issue are you referring to when you say that -fPIC doesn't fix it?
I tested building our bitcoin package group (which includes bitcoin-qt)
against Qt5 with -fPIC and it seems to compile fine.
Comment by Cory Fields (coryfields) - Monday, 15 June 2015, 18:17 GMT
Hi Evangelos

The issue is that by setting fPIC, we lose out on the optimizations that fPIE provides. Several sources say that -pie binaries should always be built with -fPIE objects, but in practice it appears as though fPIC/fPIE can be mixed safely.

I'm working on a change to Bitcoin that builds the qt objects with fPIC, but the rest as fPIE. I'll post the results here when they're ready.