Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 633930

Summary: dev-qt/qtcore-5.9.2 with GCC 7/LTO fails to compile with "undefined reference to 'QStringList::~QStringList()'"
Product: Gentoo Linux Reporter: Steffen Hau <steffen>
Component: Current packagesAssignee: Qt Bug Alias <qt>
Status: RESOLVED OBSOLETE    
Severity: normal CC: arfrever.fta, cryptopsy, cryptopsy, gentoo, hanno, ionen, klaus.kusche, marc_heimann, sam, tsmksubc
Priority: Normal Keywords: PATCH
Version: unspecified   
Hardware: AMD64   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 618550, 670138    
Attachments: qt5-build-eclass.patch
qt5-build.eclass.patch

Description Steffen Hau 2017-10-10 10:46:39 UTC
g++ -o "../qmake/qmake" project.o option.o property.o main.o ioutils.o proitems.o qmakevfs.o qmakeglobals.o qmakeparser.o qmakeevaluator.o qmakebuiltins.o makefile.o unixmake2.o unixmake.o mingw_make.o winmakefile.o projectgenerator.o meta.o makefiledeps.o metamakefile.o xmloutput.o pbuilder_pbx.o msvc_vcproj.o msvc_vcxproj.o msvc_nmake.o msvc_objectmodel.o msbuild_objectmodel.o qtextcodec.o qutfcodec.o qstring.o qstring_compat.o qstringbuilder.o qtextstream.o qiodevice.o qringbuffer.o qdebug.o qmalloc.o qglobal.o qarraydata.o qbytearray.o qbytearraymatcher.o qdatastream.o qbuffer.o qlist.o qfiledevice.o qfile.o qfilesystementry.o qfilesystemengine.o qfsfileengine.o qfsfileengine_iterator.o qregexp.o qbitarray.o qdir.o qdiriterator.o quuid.o qhash.o qfileinfo.o qdatetime.o qstringlist.o qabstractfileengine.o qtemporaryfile.o qmap.o qmetatype.o qsettings.o qsystemerror.o qvariant.o qvsnprintf.o qlocale.o qlocale_tools.o qlinkedlist.o qnumeric.o qcryptographichash.o qxmlstream.o qxmlutils.o qlogging.o qoperatingsystemversion.o qjson.o qjsondocument.o qjsonparser.o qjsonarray.o qjsonobject.o qjsonvalue.o qfilesystemengine_unix.o qfilesystemiterator_unix.o qfsfileengine_unix.o qlocale_unix.o  qlibraryinfo_final.o   -Wl,--gc-sections
qlibraryinfo_final.o:qlibraryinfo.cpp:function QLibrarySettings::load(): error: undefined reference to 'QStringList::~QStringList()'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: the symbol should have been defined by a plugin
qlibraryinfo_final.o:qlibraryinfo.cpp:function QLibrarySettings::load(): error: undefined reference to 'QStringList::~QStringList()'
/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: the symbol should have been defined by a plugin
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:152: ../qmake/qmake] Error 1
make[2]: Leaving directory '/home/gentoo/tmp/portage/dev-qt/qtcore-5.9.2/work/qtbase-opensource-src-5.9.2/qmake'
make[1]: *** [Makefile.qmake-aux:504: /home/gentoo/tmp/portage/dev-qt/qtcore-5.9.2/work/qtbase-opensource-src-5.9.2/qmake/qmake] Error 2
make[1]: Leaving directory '/home/gentoo/tmp/portage/dev-qt/qtcore-5.9.2/work/qtbase-opensource-src-5.9.2/qmake'
make: *** [Makefile:136: sub-qmake-qmake-aux-pro-install_subtargets] Error 2
 * ERROR: dev-qt/qtcore-5.9.2::gentoo failed (install phase):
 *   emake failed
Comment 1 Steffen Hau 2017-10-10 10:47:36 UTC
emerge --info '=dev-qt/qtcore-5.9.2::gentoo'
Portage 2.3.11 (python 3.5.4-final-0, default/linux/amd64/13.0/systemd, gcc-7.2.0, glibc-2.25-r7, 4.13.5-HAUIHAU x86_64)
=================================================================
                         System Settings
=================================================================
System uname: Linux-4.13.5-HAUIHAU-x86_64-Intel-R-_Core-TM-_i3-4330_CPU_@_3.50GHz-with-gentoo-2.4.1
KiB Mem:     7820496 total,   1368124 free
KiB Swap:    8388604 total,   8388604 free
Timestamp of repository gentoo: Mon, 09 Oct 2017 12:30:01 +0000
Head commit of repository gentoo: 1ef30f6cdcee7414eff23c728daf5643f456dde2
sh bash 4.4_p12
ld GNU gold (Gentoo 2.29.1 p1.0 2.29.1) 1.14
app-shells/bash:          4.4_p12::gentoo
dev-java/java-config:     2.2.0-r3::gentoo
dev-lang/perl:            5.24.3::gentoo
dev-lang/python:          2.7.14::gentoo, 3.5.4::gentoo
dev-util/cmake:           3.9.4::gentoo
dev-util/pkgconfig:       0.29.2::gentoo
sys-apps/baselayout:      2.4.1-r2::gentoo
sys-apps/sandbox:         2.12::gentoo
sys-devel/autoconf:       2.13::gentoo, 2.69-r4::gentoo
sys-devel/automake:       1.15.1-r1::gentoo
sys-devel/binutils:       2.29.1::gentoo
sys-devel/gcc:            7.2.0::gentoo
sys-devel/gcc-config:     1.9.0::gentoo
sys-devel/libtool:        2.4.6-r4::gentoo
sys-devel/make:           4.2.1-r1::gentoo
sys-kernel/linux-headers: 4.13::gentoo (virtual/os-headers)
sys-libs/glibc:           2.25-r7::gentoo
Repositories:

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

hauihau
    location: /usr/local/portage/hauihau
    masters: gentoo
    priority: 0

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="*"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O3 -pipe -flto=5 -fuse-linker-plugin"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt"
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"
CXXFLAGS="-march=native -O3 -pipe -flto=5 -fuse-linker-plugin -fno-delete-null-pointer-checks -flifetime-dse=1"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--autounmask=n --keep-going=y --quiet-build=y --quiet-fail=y --with-bdeps=y"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fakeroot fixlafiles merge-sync metadata-transfer multilib-strict news parallel-fetch parallel-install preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="de_DE.utf8"
LC_ALL="de_DE.utf8"
LDFLAGS="-march=native -O3 -pipe -flto=5 -fuse-linker-plugin -Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu -Wl,--gc-sections -Wl,--icf=safe"
MAKEOPTS="-j5"
PKGDIR="/usr/portage/packages"
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 --exclude=/.git"
PORTAGE_TMPDIR="/home/gentoo/tmp/"
USE="X a52 aac aalib acl alsa amd64 avx avx2 bash-completion berkdb bluray branding bzip2 cairo caps cdda cddb cdparanoia cdr cli cracklib crypt curl cxx dbus dga dri dts dv dvd egl encode exif ffmpeg flac fontconfig fortran ftp gd gdbm gif gmp gstreamer iconv icu imagemagick imlib ipv6 jpeg jpeg2k lame libcaca libnotify libsamplerate lzma lzo mad matroska mmx mmxext mng modules mp3 mpeg mtp multilib musepack ncurses nls nptl nsplugin ogg openal opengl openmp pam pcre pdf png policykit pulseaudio qt5 quicktime readline seccomp session sndfile spell sse sse2 sse3 sse4 sse4_1 sse4_2 ssl ssse3 svg syslog systemd tcpd theora threads tiff truetype udev unicode usb v4l vaapi vcd vim-syntax vorbis wavpack wayland webkit x264 xattr xcb xcomposite xinerama xml xmp xorg xosd xpm xv xvid zlib" ABI_X86="64" ALSA_CARDS="hda-intel" 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" 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 isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" GRUB_PLATFORMS="efi-64" INPUT_DEVICES="libinput" KERNEL="linux" L10N="de" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="de" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-6" POSTGRES_TARGETS="postgres9_5" PYTHON_SINGLE_TARGET="python3_5" PYTHON_TARGETS="python3_5" QEMU_SOFTMMU_TARGETS="i386 x86_64" QEMU_USER_TARGETS="i386 x86_64" RUBY_TARGETS="ruby24" 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"
Unset:  CC, CPPFLAGS, CTARGET, CXX, INSTALL_MASK, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

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

dev-qt/qtcore-5.9.2::gentoo was built with the following:
USE="icu systemd -debug -test" ABI_X86="(64)"
Comment 2 Steffen Hau 2017-10-10 10:48:00 UTC
Forget to say that disabling LTO fixes the linker error.
Comment 3 Bug Bugs 2017-10-11 11:48:00 UTC
> make[2]: Leaving directory '/home/gentoo/tmp/portage/dev-qt/qtcore-5.9.2/work/qtbase-opensource-src-5.9.2/qmake'
There is an bug somewhere in configure phase leads to ignored/cleared *FLAGS in Makefile there.

Temporary fix is to add 
EXTRA_CXXFLAGS="${CXXFLAGS}"
EXTRA_LFLAGS="${LDFLAGS}"
to /etc/portage/packages.env/

Please note:
you may need to add -ffat-lto-objects flag for this package as it produces *.a files which may required later by other packages to build with LTO or no-LTO
or alternatively set FEATURE="nostrip" or STRIP_MASK="*.a" as workaround (https://bugs.gentoo.org/603594)
Comment 4 Michael Palimaka (kensington) gentoo-dev 2017-12-22 11:26:25 UTC
*** Bug 641814 has been marked as a duplicate of this bug. ***
Comment 5 Michael Palimaka (kensington) gentoo-dev 2018-02-10 12:44:44 UTC
*** Bug 647092 has been marked as a duplicate of this bug. ***
Comment 6 Alexander Miller 2018-04-01 20:54:29 UTC
Created attachment 526276 [details, diff]
qt5-build-eclass.patch

There are several issues contributing to this build failure.
First, as mentioned by Bug Bugs in comment 3, compiler/flags are not set in the makefile for qmake, and this causes some objects to be built without -flto (and the other flags), leading to a link failure. See also bug 649420.

This should be fixed in qt5-build.eclass. With the attached patch applied to the eclass, dev-qt/qtcore-5.9.4-r2 builds successfully. I haven't checked whether it needs further adjustments to support all qt5 versions.

In qt5-build_src_prepare(), the configure script is modified in an attempt to respect the various compiler/flags environment variables when bootstrapping qmake. However, that's not enough. When qmake is rebuilt later during install phase (which seems wrong, but let's ignore that issue for now), the variables are not respected. This is because they are only passed to "make" on the command line for the initial bootstrap. They should be recorded in the makefile instead, such that they're respected in either case; that's what my patch accomplishes.

Finally, the link shouldn't fail even when mixing lto and non-lto objects. Recall the error:
  qlibraryinfo_final.o:qlibraryinfo.cpp:function QLibrarySettings::load(): error: undefined reference to 'QStringList::~QStringList()'
The apparently missing destructor was actually present (as a weak symbol) in the very same object file when my build failed. That looks like a linker bug to me.
Comment 7 n05ph3r42 2018-04-16 12:24:18 UTC
Can confirm,
dev-qt/qtcore-5.9.5
CFLAGS="-march=sandybridge -mfpmath=both -mavx -maes -O2 -pipe -fuse-ld=gold -flto=8 -fomit-frame-pointer -ftree-vectorize"
produces same error.

Solved creating 

/etc/portage/env/force_CXXFLAGS_LDFLAGS.conf :
EXTRA_CXXFLAGS="${CXXFLAGS}"
EXTRA_LFLAGS="${LDFLAGS}"

and
/etc/portage/package.env :
dev-qt/qtcore force_CXXFLAGS_LDFLAGS.conf
Comment 8 Alexander Miller 2018-07-18 22:42:22 UTC
Still the same for dev-qt/qtcore-5.9.6.

The EXTRA_CXXFLAGS hack doesn't work for me, but my eclass patch did the trick.
Is there any chance we can get qt5-build.eclass fixed?
Comment 9 Klaus Kusche 2018-07-29 15:14:14 UTC
Same problem for qt 5.11.1 here.

Fixed the link problem by adding a destructor to the source code,
don't know if this messes up things at runtime.
Comment 10 Hanno Böck gentoo-dev 2018-10-24 14:11:52 UTC
For what it's worth: the same issue breaks builds with address sanitizer. Patch fixes it.
Comment 11 Alexander Miller 2019-06-03 16:11:26 UTC
Created attachment 578520 [details, diff]
qt5-build.eclass.patch

Updated patch to account for recent eclass changes.
Tested with qtcore-5.12.3.
Comment 12 immolo 2022-10-07 10:55:23 UTC
This issue no longer exists in gcc11 or 12 with QTcore 5.15.3-r3 so bug can be closed.
Comment 13 Ionen Wolkens gentoo-dev 2023-09-09 17:01:28 UTC
(In reply to immolo from comment #12)
> This issue no longer exists in gcc11 or 12 with QTcore 5.15.3-r3 so bug can
> be closed.
Thanks.