Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 555578 - net-p2p/bitcoin-qt-0.11.0 fails to build: #error "You must build your code with position independent code if Qt was built with -reduce-relocations"
Summary: net-p2p/bitcoin-qt-0.11.0 fails to build: #error "You must build your code wi...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Anthony Basile
URL:
Whiteboard:
Keywords:
: 575528 (view as bug list)
Depends on:
Blocks: 559130
  Show dependency tree
 
Reported: 2015-07-21 20:02 UTC by Alexey Shvetsov
Modified: 2017-01-17 09:01 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build.log (build.log,84.59 KB, text/plain)
2015-07-21 20:02 UTC, Alexey Shvetsov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexey Shvetsov archtester gentoo-dev 2015-07-21 20:02:03 UTC
/usr/include/qt5/QtCore/qglobal.h:1052: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)."


$ emerge --info bitcoin-qt
Portage 2.2.20 (python 3.4.3-final-0, default/linux/amd64/13.0/desktop/kde, gcc-5.2.0, glibc-2.20-r2, 4.1.0-gentoo x86_64)
=================================================================
                         System Settings
=================================================================
System uname: Linux-4.1.0-gentoo-x86_64-Intel-R-_Core-TM-_i3-4010U_CPU_@_1.70GHz-with-gentoo-2.2
KiB Mem:     8108204 total,   1751008 free
KiB Swap:   16777212 total,  16464780 free
Timestamp of repository gentoo: Mon, 20 Jul 2015 19:00:01 +0000
sh bash 4.3_p39
ld GNU ld (Gentoo 2.25 p1.2) 2.25
ccache version 3.2.1 [enabled]
app-shells/bash:          4.3_p39::gentoo
dev-java/java-config:     2.2.0::gentoo
dev-lang/perl:            5.22.0::gentoo
dev-lang/python:          2.7.10::gentoo, 3.4.3::gentoo
dev-util/ccache:          3.2.1-r1::gentoo
dev-util/cmake:           3.2.3::gentoo
dev-util/pkgconfig:       0.28-r3::gentoo
sys-apps/baselayout:      2.2::gentoo
sys-apps/openrc:          0.17::gentoo
sys-apps/sandbox:         2.6-r1::gentoo
sys-devel/autoconf:       2.13::gentoo, 2.69-r1::gentoo
sys-devel/automake:       1.11.6-r1::gentoo, 1.13.4::gentoo, 1.14.1::gentoo, 1.15::gentoo
sys-devel/binutils:       2.25-r1::gentoo
sys-devel/gcc:            5.2.0::gentoo
sys-devel/gcc-config:     1.8::gentoo
sys-devel/libtool:        2.4.6-r1::gentoo
sys-devel/make:           4.1-r1::gentoo
sys-kernel/linux-headers: 4.1::gentoo (virtual/os-headers)
sys-libs/glibc:           2.20-r2::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000

crossdev
    location: /usr/local/crossdev
    masters: gentoo

alexxy
    location: /var/lib/layman/alexxy
    sync-type: laymansync
    sync-uri: git://anongit.gentoo.org/dev/alexxy.git
    masters: gentoo
    priority: 50

axs
    location: /var/lib/layman/axs
    sync-type: laymansync
    sync-uri: git://anongit.gentoo.org/dev/axs.git
    masters: gentoo axs
    priority: 50

kde
    location: /var/lib/layman/kde
    sync-type: laymansync
    sync-uri: git://anongit.gentoo.org/proj/kde.git
    masters: gentoo
    priority: 50

science
    location: /var/lib/layman/science
    sync-type: laymansync
    sync-uri: git://github.com/gentoo-science/sci.git
    masters: gentoo
    priority: 50

tox-overlay
    location: /var/lib/layman/tox-overlay
    sync-type: laymansync
    sync-uri: git://github.com/urras/gentoo-overlay-tox.git
    masters: gentoo
    priority: 50

x11
    location: /var/lib/layman/x11
    sync-type: laymansync
    sync-uri: https://anongit.gentoo.org/git/proj/x11.git
    masters: gentoo
    priority: 50

Installed sets: @kde-frameworks-5.10
ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe -march=native -mtune=native -mfpmath=sse -mavx2"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/lib64/libreoffice/program/sofficerc /usr/share/config /usr/share/gnupg/qualified.txt /usr/share/themes/oxygen-gtk/gtk-2.0 /usr/share/themes/oxygen-gtk/gtk-3.0"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-O2 -pipe -march=native -mtune=native -mfpmath=sse -mavx2"
DISTDIR="/usr/portage/distfiles"
FCFLAGS="-O2 -pipe -march=native -mtune=native -mfpmath=sse -mavx2"
FEATURES="assume-digests binpkg-logs candy ccache cgroup config-protect-if-modified distlocks ebuild-locks fakeroot fixlafiles ipc-sandbox merge-sync metadata-transfer news parallel-fetch preserve-libs protect-owned sandbox sfperms sign strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync webrsync-gpg xattr"
FFLAGS="-O2 -pipe -march=native -mtune=native -mfpmath=sse -mavx2"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="ru_RU.UTF-8"
LDFLAGS="-Wl,-O1,--hash-style=gnu,--sort-common,--as-needed"
MAKEOPTS="-j4"
PKGDIR="/usr/portage/packages"
PORTAGE_COMPRESS="xz"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
USE="64bit X a52 aac acl acpi addressbook alsa amd64 attrib audit avahi avx avx2 avx256 bash-completion berkdb blas bluetooth branding bzip2 cairo caps cdda cli colord consolekit context cracklib crypt cups cvs cxx cyrillic dbus declarative detex device-mapper dhcp dhcpcd dirac djvu dri dts dvd dvdr dvi2tty dvipdfm eap-tls ebook egl embed_data_files emboss enca encode exif expoblending extensions extra extras faac faad fam fbcondecor fbsplash ffmpeg fftw firefox flac fma fontconfig fortran games gdbm geolocation gif gimp git glamor gmp gnuplot gnutls gpg gphoto2 gpm gps gpu graphics graphite graphviz gstreamer gtk gtk3 hdaps hdf5 hscolour humanities iconsets iconv icu id3tag imagemagick inotify iproute2 ipv6 irc jabber jadetex java jbig jingle jpeg kde kipi kpathsea lapack laptop lastfm latex latex3 lcms ldap lensfun libnotify libv4l libv4l2 lm_sensors lto luatex lvm lzma mad matroska mktemp mmx mmxext mng modemmanager modules mp3 mp4 mpeg mplayer msms multilib multimedia music mysql natspec ncurses netlink networkmanager nls nptl nsplugin ntp ogg omega opencl openexr opengl openmp oscar otr pam pam_ssh pango pcre pdf phonon pkcs11 plasma plotutils plugins pm-utils png policykit postscript povray ppds ps pstricks publishers pulseaudio qemu qt3support qt4 rar raw rdesktop readline realtime redeyes resolvconf romio rtsp schroedinger science script sctp sdl semantic-desktop session sip skins skype smp speex spell sse sse2 sse3 sse4 ssh ssl ssse3 stars startup-notification stream svg symlink syslog szip taglib tcpd telepathy tex4ht theora threads thumbnail tiff tk tools truetype twolame udev udisks unicode upnp upower urandom usb utils v4l v4l2 vaapi vde vdpau vhost-net video videos vim vim-syntax vlc vlm vnc vorbis vpx wayland webkit wifi wmf wxwidgets x264 xattr xcb xcomposite xetex xindy xinerama xml xmlpatterns xmp xscreensaver xv xvid xvmc zeroconf zlib" ABI_X86="64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx avx2 fma3 mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ublox ubx" GRUB_PLATFORMS="efi-64" INPUT_DEVICES="evdev synaptics" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="ru en" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_4" QEMU_SOFTMMU_TARGETS="x86_64" RUBY_TARGETS="ruby20 ruby22" USERLAND="GNU" VIDEO_CARDS="intel i965" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
USE_PYTHON="2.7"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

=================================================================
                        Package Settings
=================================================================

net-p2p/bitcoin-qt-0.10.0::gentoo was built with the following:
USE="1stclassmsg dbus kde ljr qrcode qt5 upnp wallet -bitcoin_policy_cpfp -bitcoin_policy_dcmp -bitcoin_policy_rbf -bitcoin_policy_spamfilter -qt4 -test -xt -zeromq" ABI_X86="64" LINGUAS="en ru -ach -af_ZA -ar -be_BY -bg -bs -ca -ca@valencia -ca_ES -cmn -cs -cy -da -de -el_GR -eo -es -es_CL -es_DO -es_MX -es_UY -et -eu_ES -fa -fa_IR -fi -fr -fr_CA -gl -gu_IN -he -hi_IN -hr -hu -id_ID -it -ja -ka -kk_KZ -ko_KR -ky -la -lt -lv_LV -mn -ms_MY -nb -nl -pam -pl -pt_BR -pt_PT -ro_RO -sah -sk -sl_SI -sq -sr -sv -th_TH -tr -uk -ur_PK -uz@Cyrl -vi -vi_VN -zh_CN -zh_HK -zh_TW"
Comment 1 Alexey Shvetsov archtester gentoo-dev 2015-07-21 20:02:44 UTC
Created attachment 407358 [details]
build.log
Comment 2 Luke-Jr 2015-07-23 14:04:22 UTC
I have no idea how to solve this. Does it affect other Qt5 programs?
Comment 3 Alexey Shvetsov archtester gentoo-dev 2015-07-24 07:50:57 UTC
(In reply to Luke-Jr from comment #2)
> I have no idea how to solve this. Does it affect other Qt5 programs?

No other qt5 programs build fine. But I think it may be related to gcc-5.x
Comment 4 Alexey Shvetsov archtester gentoo-dev 2015-07-24 08:51:13 UTC
(In reply to Alexey Shvetsov from comment #3)
> (In reply to Luke-Jr from comment #2)
> > I have no idea how to solve this. Does it affect other Qt5 programs?
> 
> No other qt5 programs build fine. But I think it may be related to gcc-5.x

Seems I was wrong. 

File from dev-qt/qtcore:5 
/usr/include/qt5/QtCore/qglobal.h
contains

#if !defined(QT_BOOTSTRAPPED) && defined(QT_REDUCE_RELOCATIONS) && defined(__ELF__) && \
    (!defined(__PIC__) || (defined(__PIE__) && defined(Q_CC_GNU) && Q_CC_GNU >= 500))
#  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)."
#endif

So seesm like its global problem for Qt5 packages and gcc-5.x
Comment 5 Davide Pesavento (RETIRED) gentoo-dev 2015-07-24 10:03:03 UTC
Why are we CC'ed?

Yes, you have to build with -fPIC if that's the question.
Comment 6 Luke-Jr 2015-07-24 19:56:24 UTC
How do we determine what otherwise-unnecessary CXXFLAGS Qt might require? -fPIC apparently has a performance hit, so it'd be bad to just add it unconditionally...?
Comment 7 Davide Pesavento (RETIRED) gentoo-dev 2015-07-24 21:43:14 UTC
(In reply to Luke-Jr from comment #6)
> How do we determine what otherwise-unnecessary CXXFLAGS Qt might require?

what do you mean by "otherwise"? gcc-5 decided to change behavior and start generating relocations even with -fPIE. GCC upstream said -fPIC is safe (for now, I've heard they're finally introducing a dedicated flag to disable relocations in gcc-6), therefore Qt5 was changed to require -fPIC so that apps fail at build-time rather than crash at runtime.

anyway, that's the only mandatory flag that I know of. If your package uses qmake or cmake you don't have to care because the flag is added automatically by the build system. Otherwise you're on your own (qt upstream never really cared about pkgconfig for example...)

> -fPIC apparently has a performance hit, so it'd be bad to just add it
> unconditionally...?

This is largely false on modern systems. x86 (IA32) might be the only exception, and even there the difference is probably unnoticeable. So don't worry about it.
Comment 8 Luke-Jr 2015-07-24 22:05:12 UTC
(In reply to Davide Pesavento from comment #7)
> (In reply to Luke-Jr from comment #6)
> > How do we determine what otherwise-unnecessary CXXFLAGS Qt might require?
> 
> what do you mean by "otherwise"? gcc-5 decided to change behavior and start
> generating relocations even with -fPIE. GCC upstream said -fPIC is safe (for
> now, I've heard they're finally introducing a dedicated flag to disable
> relocations in gcc-6), therefore Qt5 was changed to require -fPIC so that
> apps fail at build-time rather than crash at runtime.

Isn't -fPIC (and even -fPIE) generally inappropriate for non-libraries? Why does it even matter if the program has relocations or not?

> anyway, that's the only mandatory flag that I know of. If your package uses
> qmake or cmake you don't have to care because the flag is added
> automatically by the build system. Otherwise you're on your own (qt upstream
> never really cared about pkgconfig for example...)

We use autotools. How do qmake/cmake determine when -fPIC is necessary?

> > -fPIC apparently has a performance hit, so it'd be bad to just add it
> > unconditionally...?
> 
> This is largely false on modern systems. x86 (IA32) might be the only
> exception, and even there the difference is probably unnoticeable. So don't
> worry about it.

Well, the main concern is that we already spend hours (days on some systems) pegging the CPU - I wouldn't want to make that any longer; even 1% would be significant. Just how unnoticeable is it?
Comment 9 Luke-Jr 2015-07-24 22:06:45 UTC
> Why does it even matter if the program has relocations or not?

Also, while this question may seem like unnecessary technical details, it's particularly relevant because we need to decide whether it is safe to *only* build the Qt-using .cpp files with -fPIC (leaving the core code with just -fPIE), or if the *entire* program needs it.
Comment 10 Davide Pesavento (RETIRED) gentoo-dev 2015-07-24 22:51:37 UTC
(In reply to Luke-Jr from comment #8)
> Isn't -fPIC (and even -fPIE) generally inappropriate for non-libraries? Why
> does it even matter if the program has relocations or not?

I forgot most of this stuff sorry. Have a look at these
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65886
https://bugreports.qt.io/browse/QTBUG-45755

> We use autotools. How do qmake/cmake determine when -fPIC is necessary?

I dunno about cmake but I think qmake adds it unconditionally. You could check the version of gcc maybe... Also note that according to this http://code.qt.io/cgit/qt/qtbase.git/tree/dist/changes-5.4.2 clang is unsafe even with PIC if LTO is used...

> Well, the main concern is that we already spend hours (days on some systems)
> pegging the CPU - I wouldn't want to make that any longer; even 1% would be
> significant. Just how unnoticeable is it?

Well I can only suggest you to benchmark and measure the difference then. x86_64/amd64 systems have RIP-relative addressing though so the difference should really be small (1% or less?)
Comment 11 Alexey Shvetsov archtester gentoo-dev 2015-07-24 23:26:16 UTC
cmake didnt add -fPIC. For example i have same bug with phonon-vlc (its cmake based)
Comment 12 Davide Pesavento (RETIRED) gentoo-dev 2015-07-24 23:32:51 UTC
Well, then I guess upstream would like to hear about it. Question is which upstream. Either qt or phonon upstream is doing it wrong.
Comment 13 Davide Pesavento (RETIRED) gentoo-dev 2015-08-26 19:06:27 UTC
Anyway, this needs to be fixed in the package build system. It's not considered a qt bug. Removing qt@ from CC, re-add us if you need anything.
Comment 14 PetaMem R&D 2016-02-18 17:06:29 UTC
So is there a resolution to this? I'm not able to build bitcoin-qt for several weeks now. Neither with gcc 4.9.3 nor with 5.3, neither with qt4 nor with qt5, neither with or without fPIC.

Maybe another distribution would do the trick?
Comment 15 M. B. 2016-02-24 15:26:50 UTC
*** Bug 575528 has been marked as a duplicate of this bug. ***
Comment 16 M. B. 2016-02-24 17:44:19 UTC
Upstream created this commit.

https://github.com/bitcoin/bitcoin/commit/69d05134367da9a897ad14562a1d266750db450a

It's part of bitcoin 0.12.0.
Comment 17 Pacho Ramos gentoo-dev 2017-01-17 09:01:09 UTC
and we have a fixed version (0.13.1-r1) in stable too