-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Fix Qt build on arch by setting -fPIC #6248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Theres probably another way to do it (I know @theuni wanted to build with different flags for release, but it would be good to at least fix build). |
|
We discussed this on IRC. I don't think -fPIC should be the default, for executables -fPIE is superior option. See e.g. http://www.openbsd.org/papers/nycbsdcon08-pie/ Though I'm fine with enabling it as a fallback if you can add a check to autoconf that |
|
Many distros force PIC anyway, so this actually wont change anything for most builds. |
|
After researching the issue some over the weekend, I agree with @laanwj. To clarify, this is an issue with gcc5 and newer clang+lto when qt is built with -reduce-relocations. Upstream GCC discussion is here. We have a few options:
2 and 3 would be necessary only for building bitcoin-qt, but we'd end up having to disable PIE for bitcoind as well, to avoid building 2 sets of objects. I believe that the root issue here is that distros are shipping qt libs with -reduce-relocations, which is known to violate abi specs and makes assumptions about how downstreams will use their libs. That abi spec violation became a real-world issue with the latest compilers. So IMO, the more reasonable thing to do here would be to try to convince Arch to disable -reduce-relocations for their qt build. We can't be the only downstream with this issue. |
|
OK, @theuni I filed a bug at https://bugs.archlinux.org/task/45283 lets see what the maintainers there say. |
|
@cfields I'm ok with all those options, except "Default to -PIC everywhere and override with -PIE when creating release binaries." Let's not have everyone suffer because a distro builds libraries with broken options. |
|
@cfields would you mind discussing with the arch maintainer @ https://bugs.archlinux.org/task/45283#comment136231 ? On June 9, 2015 11:06:00 PM PDT, "Wladimir J. van der Laan" [email protected] wrote:
|
|
This issue is present on Fedora 22 as well. |
|
I have a fix for this in the works. I'll try to push it up in the next few days. |
|
Arch changed their build settings and this is no longer an issue there, is it still on Fedora? Can we file a bug there? @dankeder |
|
Yes, the problem is still present on F22: In my bitcoin repo (checkout tag v0.10.2): I have these QT5 packages: |
|
I'm unsure what to do here. I have a rather complicated patch that changes around the PIC flags for qt objects if it was built with -reduce-locations, but since Arch elected to quit doing that, I'm somewhat hopeful that we can lobby the other distros to do the same. That really is the correct fix. |
|
I asked a friend who is a contributor to the Fedora Project what he thinks about this issue. His opinion is that bitcoin build logic shouldn't set compiler options on its own, it should rather make use of qmake to get the flags of the particular platform. Also, it seems that |
|
We're setting custom compiler options because of I do like having hardening enabled by default, though. @theuni Can we add a test to configure that detects this problem, and disables or falls back to other options if it fails? |
|
Well, reviewing PIE vs. PIC, no immediate security issue jumps out (via hardening) at the introduction of PIC. It's just a bit slower. Capturing the flags from qmake seems reasonable? |
|
Building with PIC instead of PIE means the Address Space Layout Randomization & features from Grsecurity / PaX are less effective. |
|
In Alpine Linux |
Right, detecting this would be the right way to solve this. Although the logic is quite ugly, it's not that much worse than other auto* checks. And agree it would be even better if Still NACK on setting |
|
Bleh, getting the same on Ubuntu 15.10 now. @theuni can you take a look at this? |
|
Closing in favor of #6978 |
Without -fPIC you get /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)."