Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 616038 - =dev-libs/elfutils-0.168 with LTO failes with "ld: internal error in override_version, at /tmp/portage/sys-devel/binutils-2.27/work/binutils-2.27/gold/resolve.cc:61"
Summary: =dev-libs/elfutils-0.168 with LTO failes with "ld: internal error in override...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Toolchain Maintainers
URL: https://sourceware.org/PR23958
Whiteboard: LTO
Keywords:
: 640832 652834 (view as bug list)
Depends on: 677342
Blocks: lto
  Show dependency tree
 
Reported: 2017-04-19 18:42 UTC by Petross404(Petros S)
Modified: 2019-05-26 09:18 UTC (History)
4 users (show)

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


Attachments
build.log (dev-libs:elfutils-0.168:20170419-183540.log,615.30 KB, text/x-log)
2017-04-19 18:42 UTC, Petross404(Petros S)
Details
emerge --info (info,23.22 KB, text/plain)
2017-04-19 18:43 UTC, Petross404(Petros S)
Details
elfutils-0.168:20170516-122819.log.gz (elfutils-0.168:20170516-122819.log.gz,42.77 KB, application/gzip)
2017-05-16 12:32 UTC, Paolo Pedroni
Details
elfutils-0.168:20170517-083612.log.gz (elfutils-0.168:20170517-083612.log.gz,44.81 KB, application/gzip)
2017-05-17 08:40 UTC, Paolo Pedroni
Details
gcc-lto-616038.tar.gz (gcc-lto-616038.tar.gz,521 bytes, application/gzip)
2018-12-05 23:37 UTC, Sergei Trofimovich
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Petross404(Petros S) 2017-04-19 18:42:45 UTC
Created attachment 470428 [details]
build.log

dev-libs/elfutils-0.168 failed to build with LTO.

/tmp/portage/dev-libs/elfutils-0.168/temp/cckt4lEY.lto.o
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: internal error in override_version, at /tmp/portage/sys-devel/binutils-2.27/work/binutils-2.27/gold/resolve.cc:61
collect2: error: ld returned 1 exit status
make[3]: *** [Makefile:1004: libdw.so] Error 1
make[2]: *** [Makefile:508: all] Error 2
make[1]: *** [Makefile:481: all-recursive] Error 1
make: *** [Makefile:397: all] Error 2
Comment 1 Petross404(Petros S) 2017-04-19 18:43:25 UTC
Created attachment 470430 [details]
emerge --info
Comment 2 Petross404(Petros S) 2017-04-19 18:50:00 UTC
Elfutils failes with ld.bfd too : 

/tmp/portage/dev-libs/elfutils-0.168/temp/ccPtjIYM.lto.o:(*IND*+0x0): multiple definition of `dwarf_bytesize'
dwarf_bytesize.os (symbol from plugin):(.text+0x0): first defined here
/tmp/portage/dev-libs/elfutils-0.168/temp/ccPtjIYM.lto.o:(*IND*+0x0): multiple definition of `dwarf_arrayorder'
dwarf_arrayorder.os (symbol from plugin):(.text+0x0): first defined here
/tmp/portage/dev-libs/elfutils-0.168/temp/ccPtjIYM.lto.o:(*IND*+0x0): multiple definition of `dwarf_bitsize'
dwarf_bitsize.os (symbol from plugin):(.text+0x0): first defined here
/tmp/portage/dev-libs/elfutils-0.168/temp/ccPtjIYM.lto.o:(*IND*+0x0): multiple definition of `dwarf_bitoffset'
dwarf_bitoffset.os (symbol from plugin):(.text+0x0): first defined here
/tmp/portage/dev-libs/elfutils-0.168/temp/ccPtjIYM.lto.o:(*IND*+0x0): multiple definition of `dwarf_srclang'
dwarf_srclang.os (symbol from plugin):(.text+0x0): first defined here
/tmp/portage/dev-libs/elfutils-0.168/temp/ccPtjIYM.lto.o:(*IND*+0x0): multiple definition of `dwarf_decl_file'
dwarf_decl_file.os (symbol from plugin):(.text+0x0): first defined here
/tmp/portage/dev-libs/elfutils-0.168/temp/ccPtjIYM.lto.o:(*IND*+0x0): multiple definition of `dwarf_decl_line'
dwarf_decl_line.os (symbol from plugin):(.text+0x0): first defined here
/tmp/portage/dev-libs/elfutils-0.168/temp/ccPtjIYM.lto.o:(*IND*+0x0): multiple definition of `dwarf_decl_column'
dwarf_decl_column.os (symbol from plugin):(.text+0x0): first defined here
/tmp/portage/dev-libs/elfutils-0.168/temp/ccPtjIYM.lto.o:(*IND*+0x0): multiple definition of `dwarf_aggregate_size'
dwarf_aggregate_size.os (symbol from plugin):(.text+0x0): first defined here
/tmp/portage/dev-libs/elfutils-0.168/temp/ccPtjIYM.lto.o:(*IND*+0x0): multiple definition of `dwfl_report_elf'
dwfl_report_elf.os (symbol from plugin):(.text+0x0): first defined here
/tmp/portage/dev-libs/elfutils-0.168/temp/ccPtjIYM.lto.o:(*IND*+0x0): multiple definition of `dwfl_module_build_id'
dwfl_module_build_id.os (symbol from plugin):(.text+0x0): first defined here
/tmp/portage/dev-libs/elfutils-0.168/temp/ccPtjIYM.lto.o:(*IND*+0x0): multiple definition of `dwfl_core_file_report'
core-file.os (symbol from plugin):(.text+0x0): first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: link errors found, deleting executable `libdw.so'
collect2: error: ld returned 1 exit status
)
make[3]: *** [Makefile:1004: libdw.so] Error 1
make[2]: *** [Makefile:508: all] Error 2
make[1]: *** [Makefile:481: all-recursive] Error 1
make: *** [Makefile:397: all] Error 2
Comment 3 Mike Lothian 2017-05-03 11:47:50 UTC
I think this might be a change in binutils, elfutils previously compiled for me with gcc 6.3 with LTO enabled
Comment 4 Steffen Hau 2017-05-09 10:10:41 UTC
I have the same error with GCC 7.1.0 and binutils 2.28 (using ld.gold).
Comment 5 Paolo Pedroni 2017-05-16 10:22:29 UTC
(In reply to Mike Lothian from comment #3)
> I think this might be a change in binutils, elfutils previously compiled for
> me with gcc 6.3 with LTO enabled

elfutils-0.168, with gcc-6.3.0 and binutils-2.26.1 or binutils-2.27 compiles fine here.
Comment 6 Paolo Pedroni 2017-05-16 10:41:11 UTC
Works fine with binutils-2.28 as well...
Comment 7 Petross404(Petros S) 2017-05-16 12:18:45 UTC
(In reply to Paolo Pedroni from comment #6)
> Works fine with binutils-2.28 as well...

Perphaps running: 
> emerge <your_stuff> 2>&1 | tee file.log

and attaching file.log here could help us compare and identify why your build succedds.
Comment 8 Paolo Pedroni 2017-05-16 12:32:18 UTC
Created attachment 472784 [details]
elfutils-0.168:20170516-122819.log.gz

As requested...
Comment 9 Petross404(Petros S) 2017-05-16 12:49:33 UTC
(In reply to Paolo Pedroni from comment #8)
> Created attachment 472784 [details]
> elfutils-0.168:20170516-122819.log.gz
> 
> As requested...

Can you try without -ffat-lto-objects? Like:

cat /etc/portage/env/fno-fat.conf
> CFLAGS="${CFLAGS} -fno-fat-lto-objects"
> CXXFLAGS="${CFLAGS}"
> LDFLAGS="${LDFLAGS} ${CFLAGS}"

cat /etc/portage/package.env | grep elfutils
> dev-libs/elfutils fno-fat.conf

Also report once again which compiler and linker were used (emerge --info might be useful too).
Comment 10 Paolo Pedroni 2017-05-17 08:40:42 UTC
Created attachment 472902 [details]
elfutils-0.168:20170517-083612.log.gz

gcc-6.3.0, binutils-2.28

# emerge --info
emerge --info
Portage 2.3.5 (python 3.5.3-final-0, default/linux/amd64/13.0/desktop/plasma/systemd, gcc-6.3.0, glibc-2.23-r3, 4.8.17-gentoo x86_64)
=================================================================
System uname: Linux-4.8.17-gentoo-x86_64-Intel-R-_Core-TM-_i7-2600_CPU_@_3.40GHz-with-gentoo-2.3
KiB Mem:    15864524 total,   4854088 free
KiB Swap:    8171516 total,   8171516 free
Timestamp of repository gentoo: Wed, 17 May 2017 05:15:01 +0000
sh dash 0.5.8.2
ld GNU gold (Gentoo 2.28 p1.0 2.28) 1.14
distcc 3.2rc1 x86_64-pc-linux-gnu [enabled]
ccache version 3.3.4 [disabled]
app-shells/bash:          4.3_p48-r1::gentoo
dev-java/java-config:     2.2.0-r3::gentoo
dev-lang/perl:            5.24.1-r1::gentoo
dev-lang/python:          2.7.13::gentoo, 3.5.3::gentoo
dev-util/ccache:          3.3.4::gentoo
dev-util/cmake:           3.7.2::gentoo
dev-util/pkgconfig:       0.28-r2::gentoo
sys-apps/baselayout:      2.3::gentoo
sys-apps/sandbox:         2.10-r3::gentoo
sys-devel/autoconf:       2.13::gentoo, 2.69::gentoo
sys-devel/automake:       1.11.6-r1::gentoo, 1.15-r2::gentoo
sys-devel/binutils:       2.26.1::gentoo, 2.27::gentoo, 2.28::gentoo
sys-devel/gcc:            6.3.0::gentoo
sys-devel/gcc-config:     1.8-r1::gentoo
sys-devel/libtool:        2.4.6-r3::gentoo
sys-devel/make:           4.2.1::gentoo
sys-kernel/linux-headers: 4.10::gentoo (virtual/os-headers)
sys-libs/glibc:           2.23-r3::gentoo
Repositories:

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

x-portage
    location: /usr/local/portage
    masters: gentoo
    priority: 0

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe -march=sandybridge -msahf --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=8192 -flto=8 -fuse-linker-plugin -floop-nest-optimize -ftree-loop-distribution -fgraphite-identity -ftree-vectorize"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/lib64/libreoffice/program/sofficerc /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/php/apache2-php7.0/ext-active/ /etc/php/cgi-php7.0/ext-active/ /etc/php/cli-php7.0/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -pipe -march=sandybridge -msahf --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=8192 -flto=8 -fuse-linker-plugin -floop-nest-optimize -ftree-loop-distribution -fgraphite-identity -ftree-vectorize"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--keep-going y --with-bdeps y"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs cgroup compress-build-logs config-protect-if-modified distcc distlocks ebuild-locks ipc-sandbox merge-sync news parallel-fetch protect-owned sandbox sfperms split-elog split-log strict test unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://tux.rainside.sk/gentoo/ http://mirror.leaseweb.com/gentoo/ http://ftp.uni-erlangen.de/pub/mirrors/gentoo http://ftp.spline.inf.fu-berlin.de/mirrors/gentoo/"
LANG="it_IT.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu -Wl,--sort-common -flto=8 -fuse-linker-plugin -floop-nest-optimize -ftree-loop-distribution -fgraphite-identity -ftree-vectorize"
MAKEOPTS="-j11 -l8"
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="/var/tmp"
USE="X a52 aac aalib acl acpi adns alsa amd64 ao audiofile bash-completion bluetooth branding bzip2 cairo caps cdda cddb cdparanoia cdr cli cracklib crypt css cups curl cxx dbus declarative dga djvu dri dts dvd dvdr emboss encode exif expat fbcon ffmpeg fftw firefox flac fontconfig foomaticdb fortran ftp gd gdbm geoip gif gimp glamor gmp gnutls gphoto2 gpm graphviz gtk handbook iconv icu idn imagemagick imlib ipv6 java javascript jbig jpeg jpeg2k kde kipi kwallet lame lcms libass libcaca libnotify libsamplerate lm_sensors lua lzma lzo mad mmap mng modules mp3 mp4 mpeg mplayer multilib musicbrainz ncurses nls nptl nsplugin offensive ogg openal openexr opengl openmp pam pango pcre pdf phonon plasma png policykit postscript ppds pulseaudio qml qt3support qt4 qt5 rdesktop readline recode samba sctp sdl seccomp session sndfile sockets speex spell sqlite ssl startup-notification subversion svg symlink syslog systemd sysvipc taglib theora threads tidy tiff truetype udev udisks unicode upower usb vaapi vcd vim-syntax vnc vorbis wayland widgets win32codecs wmf wxwidgets x264 xattr xcb xcomposite xine xinerama xml xpm xscreensaver xv xvid yahoo zlib" ABI_X86="64" ALSA_CARDS="hda-intel virmidi" 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="kodak ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3" CURL_SSL="gnutls" 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="pc" INPUT_DEVICES="libinput" KERNEL="linux" L10N="it en" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="nlpsolver" LINGUAS="it it_IT" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-6" PYTHON_TARGETS="python2_7 python3_5 pypy pypy3" RUBY_TARGETS="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"
Unset:  CC, CPPFLAGS, CTARGET, CXX, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON
Comment 11 Paolo Pedroni 2017-05-17 08:43:00 UTC
Linker is ld.gold, of course. All -ffat-lto-objects does is getting rid of those "x86_64-pc-linux-gnu-strip: ... plugin needed to handle lto object"
Comment 12 Steffen Hau 2017-05-17 08:50:29 UTC
Regarding I've found a post from Markus Trippelsdorf in the Gentoo forums:

https://forums.gentoo.org/viewtopic-t-1052716-postdays-0-postorder-asc-start-50.html#8010578
---
For -ffat-lto-objects it works without the symlink. But in this case you're not using any LTO optimizations, 
because only the non-lto part of the "fat" object is used and the IR (GIMPLE) part is simply discarded.
---

I'm building with:
CFLAGS="-march=native -O3 -pipe -flto=5 -fuse-linker-plugin"
CXXFLAGS="${CFLAGS} -fno-delete-null-pointer-checks -flifetime-dse=1"
LDFLAGS="${CFLAGS} ${LDFLAGS} -Wl,--hash-style=gnu -Wl,--gc-sections -Wl,--icf=safe"
Comment 13 Steffen Hau 2017-05-24 12:36:18 UTC
I temporarily switched to ld.bfd:

/home/gentoo/tmp/portage/dev-libs/elfutils-0.169/temp/cczedbKX.ltrans0.ltrans.o:(*IND*+0x0): multiple definition of `dwarf_bytesize'
dwarf_bytesize.os (symbol from plugin):(.text+0x0): first defined here
/home/gentoo/tmp/portage/dev-libs/elfutils-0.169/temp/cczedbKX.ltrans0.ltrans.o:(*IND*+0x0): multiple definition of `dwarf_arrayorder'
dwarf_arrayorder.os (symbol from plugin):(.text+0x0): first defined here
/home/gentoo/tmp/portage/dev-libs/elfutils-0.169/temp/cczedbKX.ltrans0.ltrans.o:(*IND*+0x0): multiple definition of `dwarf_bitsize'
dwarf_bitsize.os (symbol from plugin):(.text+0x0): first defined here
/home/gentoo/tmp/portage/dev-libs/elfutils-0.169/temp/cczedbKX.ltrans0.ltrans.o:(*IND*+0x0): multiple definition of `dwarf_bitoffset'
dwarf_bitoffset.os (symbol from plugin):(.text+0x0): first defined here
/home/gentoo/tmp/portage/dev-libs/elfutils-0.169/temp/cczedbKX.ltrans0.ltrans.o:(*IND*+0x0): multiple definition of `dwarf_srclang'
dwarf_srclang.os (symbol from plugin):(.text+0x0): first defined here
/home/gentoo/tmp/portage/dev-libs/elfutils-0.169/temp/cczedbKX.ltrans0.ltrans.o:(*IND*+0x0): multiple definition of `dwarf_decl_file'
dwarf_decl_file.os (symbol from plugin):(.text+0x0): first defined here
/home/gentoo/tmp/portage/dev-libs/elfutils-0.169/temp/cczedbKX.ltrans0.ltrans.o:(*IND*+0x0): multiple definition of `dwarf_decl_line'
dwarf_decl_line.os (symbol from plugin):(.text+0x0): first defined here
/home/gentoo/tmp/portage/dev-libs/elfutils-0.169/temp/cczedbKX.ltrans0.ltrans.o:(*IND*+0x0): multiple definition of `dwarf_decl_column'
dwarf_decl_column.os (symbol from plugin):(.text+0x0): first defined here
/home/gentoo/tmp/portage/dev-libs/elfutils-0.169/temp/cczedbKX.ltrans0.ltrans.o:(*IND*+0x0): multiple definition of `dwarf_aggregate_size'
dwarf_aggregate_size.os (symbol from plugin):(.text+0x0): first defined here

Disabling LTO is still the only way to successfully compile.
Comment 14 Petross404(Petros S) 2017-05-25 11:43:17 UTC
(In reply to Paolo Pedroni from comment #11)
> those "x86_64-pc-linux-gnu-strip: ... plugin needed to handle lto object"

In that case you are not using the symlink or gcc-ar etc. Please do setup your toolchain to correctly link with LTO and afterwards test emerging without -ffat-lto.

Please read here : https://www.reddit.com/r/Gentoo/comments/6b1dlc/plugin_needed_to_handle_lto_object_and_correct/
Comment 15 Petross404(Petros S) 2017-06-18 00:00:23 UTC
Using binutils 2.28 can't link dev-libs/elfutils-0.169-r1 either. I get the exact same error but instead of "binutils-2.27/gold/", I get "binutils-2.28/gold".
Comment 16 Paolo Pedroni 2017-08-17 14:15:21 UTC
(In reply to Petross404(Petros S) from comment #14)
> (In reply to Paolo Pedroni from comment #11)
> > those "x86_64-pc-linux-gnu-strip: ... plugin needed to handle lto object"
> 
> In that case you are not using the symlink or gcc-ar etc. Please do setup
> your toolchain to correctly link with LTO and afterwards test emerging
> without -ffat-lto.
> 
> Please read here :
> https://www.reddit.com/r/Gentoo/comments/6b1dlc/
> plugin_needed_to_handle_lto_object_and_correct/

Read. My toolchain is setup correctly, according to the article (and it was before):

# grep FLAGS /etc/portage/make.conf
CFLAGS="-O2 -pipe -march=sandybridge -msahf --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=8192 -flto=8 -fuse-linker-plugin -floop-nest-optimize -ftree-loop-distribution -fgraphite-identity -ftree-vectorize"
CXXFLAGS="${CFLAGS}"
LDFLAGS="${LDFLAGS} -Wl,--hash-style=gnu -Wl,--sort-common -flto=8 -fuse-linker-plugin -floop-nest-optimize -ftree-loop-distribution -fgraphite-identity -ftree-vectorize

# grep gcc- /etc/portage/make.conf
AR="gcc-ar"
NM="gcc-nm"
RANLIB="gcc-ranlib"

and yet, as of today, I get:
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblopenbackend.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblclosebackend.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblreloctypename.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblsegmenttypename.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblsectiontypename.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblmachineflagname.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblsymboltypename.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/ebldynamictagname.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblsectionname.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblsymbolbindingname.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblbackendname.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblosabiname.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblmachineflagcheck.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblmachinesectionflagcheck.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblreloctypecheck.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblrelocvaliduse.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblrelocsimpletype.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/ebldynamictagcheck.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblcorenotetypename.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblobjnotetypename.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblcorenote.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblobjnote.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/ebldebugscnp.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblgotpcreloccheck.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblcopyrelocp.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblsectionstripp.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblelfclass.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblelfdata.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblelfmachine.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/ebl_check_special_symbol.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblbsspltp.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblretval.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblreginfo.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblnonerelocp.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblrelativerelocp.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblsysvhashentrysize.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblauxvinfo.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblcheckobjattr.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/ebl_check_special_section.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/ebl_syscall_abi.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblabicfi.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblstother.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblinitreg.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/ebldwarftoregno.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblnormalizepc.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblunwind.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblresolvesym.o: plugin needed to handle lto object
x86_64-pc-linux-gnu-strip: /var/tmp/portage/dev-libs/elfutils-0.169-r1/image/usr/lib64/stl4loW5/eblcheckreloctargettype.o: plugin needed to handle lto object

at install time.
Comment 17 Steffen Hau 2017-08-17 14:17:54 UTC
It's a bug in binutils: https://sourceware.org/bugzilla/show_bug.cgi?id=21479
Comment 18 Bug Bugs 2017-10-19 14:19:14 UTC
Builds with --disable-symbol-versioning configure flag.
Comment 19 Sergei Trofimovich gentoo-dev 2018-12-04 23:41:01 UTC
(In reply to Steffen Hau from comment #17)
> It's a bug in binutils: https://sourceware.org/bugzilla/show_bug.cgi?id=21479

I'm not sure about that. It might also be lack of proper $(RANLIB) run or intermediate .a stripping.
Comment 20 Petross404(Petros S) 2018-12-05 09:44:04 UTC
(In reply to Sergei Trofimovich from comment #19)
> (In reply to Steffen Hau from comment #17)
> > It's a bug in binutils: https://sourceware.org/bugzilla/show_bug.cgi?id=21479
> 
> I'm not sure about that. It might also be lack of proper $(RANLIB) run or
> intermediate .a stripping.

Do you suggest that using STRIP_MASK="*.a" or FEATURE="nostrip" can solve the problem in the proper way?
Comment 21 Steffen Hau 2018-12-05 13:35:31 UTC
The issue with strip is solved, see bug603594
Comment 22 Sergei Trofimovich gentoo-dev 2018-12-05 19:52:35 UTC
(In reply to Petross404(Petros S) from comment #20)
> (In reply to Sergei Trofimovich from comment #19)
> > (In reply to Steffen Hau from comment #17)
> > > It's a bug in binutils: https://sourceware.org/bugzilla/show_bug.cgi?id=21479
> > 
> > I'm not sure about that. It might also be lack of proper $(RANLIB) run or
> > intermediate .a stripping.
> 
> Do you suggest that using STRIP_MASK="*.a" or FEATURE="nostrip" can solve
> the problem in the proper way?

To have some progress here in this bug I suggest focusing on originally reported problem: multiple definitions of versioned symbols (and leaving out undefined symbols to #603594 as Steffen noted).

I propose a plan:
- extract minimal yet sensible example for multiple symbol definitions
- from minimal example figure out it it's an LTO gcc/codegen bug or binutils/gold bug
- report a bug upstream if not already done
Comment 23 Sergei Trofimovich gentoo-dev 2018-12-05 23:37:58 UTC
Created attachment 557134 [details]
gcc-lto-616038.tar.gz

Extracted minimal reproducer. On bfd It fails here as:

  $ ./bug.bash
  Non-lto build:
  lto build:
  lto --whole-archive build:
  /usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /tmp/ccJimU68.ltrans0.ltrans.o:(*IND*+0x0): multiple definition of `dwarf_bytesize'; dwarf_bytesize.os (symbol from plugin):(.text+0x0): first defined here
  collect2: error: ld returned 1 exit status

gold passes. Thus at lease we have mismatch here.
Comment 24 Sergei Trofimovich gentoo-dev 2018-12-06 23:26:24 UTC
> Extracted minimal reproducer. On bfd It fails here as:

Filed gcc bug: https://gcc.gnu.org/PR88396
Will extract similar example for ld.gold.
Comment 25 Sergei Trofimovich gentoo-dev 2018-12-06 23:31:46 UTC
(In reply to Sergei Trofimovich from comment #24)
> Will extract similar example for ld.gold.

With binutils-2.31.1-r1 LDFLAGS="-flto -fuse-ld=gold" seems to just work.
Comment 26 Petross404(Petros S) 2018-12-07 10:11:43 UTC
(In reply to Sergei Trofimovich from comment #25)
> (In reply to Sergei Trofimovich from comment #24)
> > Will extract similar example for ld.gold.
> 
> With binutils-2.31.1-r1 LDFLAGS="-flto -fuse-ld=gold" seems to just work.

Aren't LDFLAGS supposed to accept a -Wl,--some-flag prefix?
Comment 27 Sergei Trofimovich gentoo-dev 2018-12-07 20:15:07 UTC
(In reply to Petross404(Petros S) from comment #26)
> (In reply to Sergei Trofimovich from comment #25)
> > (In reply to Sergei Trofimovich from comment #24)
> > > Will extract similar example for ld.gold.
> > 
> > With binutils-2.31.1-r1 LDFLAGS="-flto -fuse-ld=gold" seems to just work.
> 
> Aren't LDFLAGS supposed to accept a -Wl,--some-flag prefix?

Not necessary. LDFLAGS is a variable that is passed to compiler, not linker directly. There are quite a few compiler flags that get translated to linker flags by compiler driver. Examples are -fuse-ld=gold, -m32, -rdynamic, -pie, -static, -Bstatic, etc.

'-Wl,--foo' is a flag to compiler to pass '--foo' directly to linker (or compiler's linker plugin). LDFLAGS can contain both.

Thus LDFLAGS can occasionally contain a mix of '-Wl,'-prefixed (for linker) and unprefixed (for compiler driver) options.
Comment 28 Sergei Trofimovich gentoo-dev 2018-12-08 00:02:55 UTC
Confirmed to be ld.bfd bug:
    https://sourceware.org/PR23958
2.32 will have a few fixes around it.
Comment 29 Steffen Hau 2018-12-08 14:43:32 UTC
(In reply to Sergei Trofimovich from comment #28)
> Confirmed to be ld.bfd bug:
>     https://sourceware.org/PR23958
> 2.32 will have a few fixes around it.

Did you manage to compile elfutils-173 with LTO enabled? I got a new error:
/home/gentoo/tmp/portage/dev-libs/elfutils-0.173/temp/ccMeglaQ.ltrans0.ltrans.o:<artificial>:function parse_opt: error: undefined reference to 'dwfl_core_file_report'
Comment 30 Sergei Trofimovich gentoo-dev 2018-12-08 19:07:33 UTC
(In reply to Steffen Hau from comment #29)
> (In reply to Sergei Trofimovich from comment #28)
> > Confirmed to be ld.bfd bug:
> >     https://sourceware.org/PR23958
> > 2.32 will have a few fixes around it.
> 
> Did you manage to compile elfutils-173 with LTO enabled? I got a new error:
> /home/gentoo/tmp/portage/dev-libs/elfutils-0.173/temp/ccMeglaQ.ltrans0.
> ltrans.o:<artificial>:function parse_opt: error: undefined reference to
> 'dwfl_core_file_report'

#comment25 is my successful build on ~amd64 system, yes.

My precise test was:
  # USE=test FEATURES=test CFLAGS="-O2 -flto" CXXFLAGS="-O2 -flto" LDFLAGS="-O1 -flto -fuse-ld=gold" emerge -v1 elfutils --quiet-build=n

If it differs for you please post
- 'emerge --info' output
- build.log
and we'll try to find what's wrong
Comment 31 Sergei Trofimovich gentoo-dev 2019-01-26 22:14:55 UTC
*** Bug 640832 has been marked as a duplicate of this bug. ***
Comment 32 Sergei Trofimovich gentoo-dev 2019-01-26 22:15:01 UTC
*** Bug 652834 has been marked as a duplicate of this bug. ***
Comment 33 Sergei Trofimovich gentoo-dev 2019-05-26 09:18:25 UTC
binutils-2.32 is in tree. Please file a new bug report if it still fails to you in lto mode.