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

Bug 598320

Summary: dev-libs/boost does not build with LTO and clang
Product: Gentoo Linux Reporter: Amit Prakash Ambasta <amit.prakash.ambasta>
Component: Current packagesAssignee: C++ Team [disbanded] <cpp+disabled>
Status: RESOLVED OBSOLETE    
Severity: normal CC: paolo.pedroni
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 618550    
Attachments: boost build log

Description Amit Prakash Ambasta 2016-10-28 08:49:39 UTC
Hi,

While building boost with clang and LTO, the following error occurs:

bin.v2/libs/atomic/build/gcc-4.2/gentoorelease/boost.locale.icu-off/pch-off/threading-multi/lockpool.o: file not recognized: File format not recognized

The clink command (and verbose) to the same are:

    "x86_64-pc-linux-gnu-clang++"  -ftemplate-depth-128 -O2 -pipe -march=haswell -mtune=haswell -flto=thin -stdlib=libc++ -std=c++14 -finline-functions -Wno-inline -Wall -pthread -fPIC -m64  -DBOOST_ALL_NO_LIB=1 -DBOOST_ATOMIC_DYN_LINK=1 -DBOOST_ATOMIC_SOURCE -DNDEBUG  -I"." -c -o "bin.v2/libs/atomic/build/gcc-4.2/gentoorelease/boost.locale.icu-off/pch-off/threading-multi/lockpool.o" "libs/atomic/src/lockpool.cpp"

"/usr/bin/x86_64-pc-linux-gnu-ld" --eh-frame-hdr -m elf_x86_64 -shared -use-gold-plugin -o bin.v2/libs/atomic/build/gcc-4.2/gentoorelease/boost.locale.icu-off/pch-off/threading-multi/libboost_atomic.so.1.62.0 /usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/../../../../lib64/crti.o /usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/crtbeginS.o -L/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0 -L/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/../../../../lib64 -L/usr/bin/../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/../../../../x86_64-pc-linux-gnu/lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/../../.. -L/usr/bin/../lib -L/lib -L/usr/lib -h libboost_atomic.so.1.62.0 --start-group bin.v2/libs/atomic/build/gcc-4.2/gentoorelease/boost.locale.icu-off/pch-off/threading-multi/lockpool.o -Bstatic -Bdynamic -lrt --end-group -O1 --as-needed -lc++ -lm -lgcc_s -lpthread -lc -lgcc_s /usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/crtendS.o /usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/../../../../lib64/crtn.o


This occurs since the gold plugin is not being passed to the linker. However, both binutils-config --linker ld.gold and LD="ld.gold" in make.conf are set

Manually adding:
-plugin /usr/x86_64-pc-linux-gnu/binutils-bin/lib/bfd-plugins/LLVMgold.so

to the ld command fixes this however.
Comment 1 Amit Prakash Ambasta 2016-10-28 08:51:02 UTC
Apologies, the verbose output of the link command is as below:
 "/usr/bin/x86_64-pc-linux-gnu-ld" --eh-frame-hdr -m elf_x86_64 -shared -o bin.v2/libs/atomic/build/gcc-4.2/gentoorelease/boost.locale.icu-off/pch-off/threading-multi/libboost_atomic.so.1.62.0 /usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/../../../../lib64/crti.o /usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/crtbeginS.o -L/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0 -L/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/../../../../lib64 -L/usr/bin/../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/../../../../x86_64-pc-linux-gnu/lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/../../.. -L/usr/bin/../lib -L/lib -L/usr/lib -h libboost_atomic.so.1.62.0 --start-group bin.v2/libs/atomic/build/gcc-4.2/gentoorelease/boost.locale.icu-off/pch-off/threading-multi/lockpool.o -Bstatic -Bdynamic -lrt --end-group -O1 --as-needed -lc++ -lm -lgcc_s -lpthread -lc -lgcc_s /usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/crtendS.o /usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/../../../../lib64/crtn.o
Comment 2 Michael Palimaka (kensington) gentoo-dev 2016-10-29 11:37:22 UTC
Please add emerge --info and attach the full build log.
Comment 3 Amit Prakash Ambasta 2016-10-29 12:24:24 UTC
emerge --info
-----------------------------------------------------------
Portage 2.3.2 (python 3.5.2-final-0, default/linux/amd64/13.0/no-multilib, gcc-5.4.0, glibc-2.23-r2, 4.8.4-gentoo x86_64)
=================================================================
System uname: Linux-4.8.4-gentoo-x86_64-Intel-R-_Core-TM-_i5-4210U_CPU_@_1.70GHz-with-gentoo-2.3
KiB Mem:    16334776 total,  10321636 free
KiB Swap:          0 total,         0 free
Timestamp of repository gentoo: Thu, 27 Oct 2016 13:00:01 +0000
sh bash 4.3_p48
ld GNU ld (Gentoo 2.26.1 p1.0) 2.26.1
app-shells/bash:          4.3_p48::gentoo
dev-java/java-config:     2.2.0-r3::gentoo
dev-lang/perl:            5.24.0-r2::gentoo
dev-lang/python:          2.7.12::gentoo, 3.5.2::gentoo
dev-util/cmake:           3.6.2::gentoo
dev-util/pkgconfig:       0.29.1::gentoo
sys-apps/baselayout:      2.3::gentoo
sys-apps/openrc:          0.22.2::gentoo
sys-apps/sandbox:         2.10-r2::gentoo
sys-devel/autoconf:       2.13::gentoo, 2.69-r2::gentoo
sys-devel/automake:       1.13.4-r1::gentoo, 1.14.1-r1::gentoo, 1.15-r2::gentoo
sys-devel/binutils:       2.26.1::gentoo
sys-devel/gcc:            5.4.0::gentoo
sys-devel/gcc-config:     1.8-r1::gentoo
sys-devel/libtool:        2.4.6-r2::gentoo
sys-devel/make:           4.2.1::gentoo
sys-kernel/linux-headers: 4.7::gentoo (virtual/os-headers)
sys-libs/glibc:           2.23-r2::gentoo
Repositories:

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

ambasta
    location: /var/lib/layman/ambasta
    masters: gentoo
    priority: 0

delhivery
    location: /var/lib/layman/delhivery
    masters: gentoo
    priority: 1

sublime-text
    location: /var/lib/layman/sublime-text
    sync-type: laymansync
    sync-uri: git://github.com/DamnWidget/sublime-text.git
    masters: gentoo
    priority: 50

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="* -@EULA google-chrome Oracle-BCLA-JavaSE Sublime Google-TOS OPERA-2014 PUEL"
CBUILD="x86_64-pc-linux-gnu"
CC="x86_64-pc-linux-gnu-clang"
CFLAGS="-O2 -pipe -march=haswell -mtune=haswell -flto=thin -fuse-ld=gold"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/chromium/policies/managed/chrome-gnome-shell.json /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/opt/chrome/policies/managed/chrome-gnome-shell.json /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXX="x86_64-pc-linux-gnu-clang++"
CXXFLAGS="-O2 -pipe -march=haswell -mtune=haswell -flto=thin -fuse-ld=gold -stdlib=libc++"
DISTDIR="/home/portage/distfiles/"
EMERGE_DEFAULT_OPTS="--autounmask=n"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync multilib-strict news nodoc noinfo nostrip parallel-fetch 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://mirror.leaseweb.com/gentoo/ http://gd.tuwien.ac.at/opsys/linux/gentoo/ http://gentoo.inode.at/ http://www.mirrorservice.org/sites/distfiles.gentoo.org/ http://gentoo.gg3.net/"
LANG="en_US.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
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/portage/"
USE="X acl amd64 berkdb bzip2 cli cracklib crypt cups cxx dbus directfb dri dri3 foomaticdb gdbm glamor gnome gnome-keyring gtk3 iconv infinality introspection libkms libsecret lz4 lzma mmx mmxext modules ncurses networkmanager nls nptl ntp opengl openmp pam pcre policykit ppds pulseaudio python3 readline seccomp session sna sse sse2 ssl systemd tcpd udev unicode xattr 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" INPUT_DEVICES="libinput" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="en_US" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-6" PYTHON_SINGLE_TARGET="python3_5" PYTHON_TARGETS="python3_5 python2_7" RUBY_TARGETS="ruby21" USERLAND="GNU" VIDEO_CARDS="intel i965 fbdev" 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:  CPPFLAGS, CTARGET, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON
Comment 4 Amit Prakash Ambasta 2016-10-29 12:27:20 UTC
Created attachment 451848 [details]
boost build log
Comment 5 Steve Arnold archtester gentoo-dev 2016-11-05 18:47:23 UTC
Hmm, boost-1.61 builds fine with default lto/vectorize/graphite flags, however boost-build needed a little env help (adding  -std=gnu89 as workaround to avoid nasty QA warnings about implicit declarations).

Now, boost-build-1.62 is the same as 1.61 but boost-1.62 fails with -flto or just the gold linker.  It builds as above (but without -flto or gold) so the rest of the "normal" optimization flags seem okay.

This is all with ~amd64 toolchain, not tried it with clang/llvm.  AFAICT the linker plugin stuff is handled correctly with the standard toolchain.

Without lto and just gold I get this:

    "x86_64-pc-linux-gnu-g++"  -ftemplate-depth-128 -march=athlon64 -mtune=amdfam10 -O2 -pipe -fgraphite-identity -floop-interchange -floop-strip-mine -floop-block -ftree-vectorize -ftree-loop-distribution -fvect-cost-m
odel=cheap -std=c++14 -finline-functions -Wno-inline -Wall -pthread -fPIC -m64 -fvisibility=hidden -DBOOST_ALL_NO_LIB=1 -DBOOST_MATH_TR1_DYN_LINK=1 -DNDEBUG  -I"." -I"libs/math/src/tr1" -c -o "bin.v2/libs/math/build/gcc
-5.3/gentoorelease/pch-off/threading-multi/riemann_zeta.o" "libs/math/build/../src/tr1/riemann_zeta.cpp"

gcc.compile.c++ bin.v2/libs/math/build/gcc-5.3/gentoorelease/pch-off/threading-multi/sph_legendre.o

    "x86_64-pc-linux-gnu-g++"  -ftemplate-depth-128 -march=athlon64 -mtune=amdfam10 -O2 -pipe -fgraphite-identity -floop-interchange -floop-strip-mine -floop-block -ftree-vectorize -ftree-loop-distribution -fvect-cost-m
odel=cheap -std=c++14 -finline-functions -Wno-inline -Wall -pthread -fPIC -m64 -fvisibility=hidden -DBOOST_ALL_NO_LIB=1 -DBOOST_MATH_TR1_DYN_LINK=1 -DNDEBUG  -I"." -I"libs/math/src/tr1" -c -o "bin.v2/libs/math/build/gcc
-5.3/gentoorelease/pch-off/threading-multi/sph_legendre.o" "libs/math/build/../src/tr1/sph_legendre.cpp"

gcc.compile.c++ bin.v2/libs/math/build/gcc-5.3/gentoorelease/pch-off/threading-multi/sph_neumann.o

    "x86_64-pc-linux-gnu-g++"  -ftemplate-depth-128 -march=athlon64 -mtune=amdfam10 -O2 -pipe -fgraphite-identity -floop-interchange -floop-strip-mine -floop-block -ftree-vectorize -ftree-loop-distribution -fvect-cost-m
odel=cheap -std=c++14 -finline-functions -Wno-inline -Wall -pthread -fPIC -m64 -fvisibility=hidden -DBOOST_ALL_NO_LIB=1 -DBOOST_MATH_TR1_DYN_LINK=1 -DNDEBUG  -I"." -I"libs/math/src/tr1" -c -o "bin.v2/libs/math/build/gcc
-5.3/gentoorelease/pch-off/threading-multi/sph_neumann.o" "libs/math/build/../src/tr1/sph_neumann.cpp"

gcc.compile.c++ bin.v2/libs/math/build/gcc-5.3/gentoorelease/pch-off/threading-multi/assoc_laguerref.o

    "x86_64-pc-linux-gnu-g++"  -ftemplate-depth-128 -march=athlon64 -mtune=amdfam10 -O2 -pipe -fgraphite-identity -floop-interchange -floop-strip-mine -floop-block -ftree-vectorize -ftree-loop-distribution -fvect-cost-m
odel=cheap -std=c++14 -finline-functions -Wno-inline -Wall -pthread -fPIC -m64 -fvisibility=hidden -DBOOST_ALL_NO_LIB=1 -DBOOST_MATH_TR1_DYN_LINK=1 -DNDEBUG  -I"." -I"libs/math/src/tr1" -c -o "bin.v2/libs/math/build/gcc
-5.3/gentoorelease/pch-off/threading-multi/assoc_laguerref.o" "libs/math/build/../src/tr1/assoc_laguerref.cpp"

gcc.link.dll bin.v2/libs/math/build/gcc-5.3/gentoorelease/pch-off/threading-multi/libboost_math_tr1.so.1.62.0

    "x86_64-pc-linux-gnu-g++"    -o "bin.v2/libs/math/build/gcc-5.3/gentoorelease/pch-off/threading-multi/libboost_math_tr1.so.1.62.0" -Wl,-h -Wl,libboost_math_tr1.so.1.62.0 -shared -Wl,--start-group "bin.v2/libs/math/b
uild/gcc-5.3/gentoorelease/pch-off/threading-multi/assoc_laguerre.o" "bin.v2/libs/math/build/gcc-5.3/gentoorelease/pch-off/threading-multi/assoc_legendre.o" "bin.v2/libs/math/build/gcc-5.3/gentoorelease/pch-off/threadin
g-multi/beta.o" "bin.v2/libs/math/build/gcc-5.3/gentoorelease/pch-off/threading-multi/comp_ellint_1.o" "bin.v2/libs/math/build/gcc-5.3/gentoorelease/pch-off/threading-multi/comp_ellint_2.o" "bin.v2/libs/math/build/gcc-5
.3/gentoorelease/pch-off/threading-multi/comp_ellint_3.o" "bin.v2/libs/math/build/gcc-5.3/gentoorelease/pch-off/threading-multi/cyl_bessel_i.o" "bin.v2/libs/math/build/gcc-5.3/gentoorelease/pch-off/threading-multi/cyl_b
essel_j.o" "bin.v2/libs/math/build/gcc-5.3/gentoorelease/pch-off/threading-multi/cyl_bessel_k.o" "bin.v2/libs/math/build/gcc-5.3/gentoorelease/pch-off/threading-multi/cyl_neumann.o" "bin.v2/libs/math/build/gcc-5.3/gento
orelease/pch-off/threading-multi/ellint_1.o" "bin.v2/libs/math/build/gcc-5.3/gentoorelease/pch-off/threading-multi/ellint_2.o" "bin.v2/libs/math/build/gcc-5.3/gentoorelease/pch-off/threading-multi/ellint_3.o" "bin.v2/li
bs/math/build/gcc-5.3/gentoorelease/pch-off/threading-multi/expint.o" "bin.v2/libs/math/build/gcc-5.3/gentoorelease/pch-off/threading-multi/hermite.o" "bin.v2/libs/math/build/gcc-5.3/gentoorelease/pch-off/threading-mult
i/laguerre.o" "bin.v2/libs/math/build/gcc-5.3/gentoorelease/pch-off/threading-multi/legendre.o" "bin.v2/libs/math/build/gcc-5.3/gentoorelease/pch-off/threading-multi/riemann_zeta.o" "bin.v2/libs/math/build/gcc-5.3/gento
orelease/pch-off/threading-multi/sph_bessel.o" "bin.v2/libs/math/build/gcc-5.3/gentoorelease/pch-off/threading-multi/sph_legendre.o" "bin.v2/libs/math/build/gcc-5.3/gentoorelease/pch-off/threading-multi/sph_neumann.o"  
-Wl,-Bstatic  -Wl,-Bdynamic -lrt -Wl,--end-group  -ftree-vectorize -ftree-loop-distribution -fvect-cost-model=cheap -pthread -m64 

/usr/lib/gcc/x86_64-pc-linux-gnu/5.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: bin.v2/libs/math/build/gcc-5.3/gentoorelease/pch-off/threading-multi/cyl_neumann.o:1:2: invalid character
/usr/lib/gcc/x86_64-pc-linux-gnu/5.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: bin.v2/libs/math/build/gcc-5.3/gentoorelease/pch-off/threading-multi/ellint_1.o:1:1: invalid character
/usr/lib/gcc/x86_64-pc-linux-gnu/5.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: bin.v2/libs/math/build/gcc-5.3/gentoorelease/pch-off/threading-multi/ellint_2.o:1:1: syntax error, unexpected '<', expecting $end
/usr/lib/gcc/x86_64-pc-linux-gnu/5.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: bin.v2/libs/math/build/gcc-5.3/gentoorelease/pch-off/threading-multi/ellint_2.o: not an object or archive
/usr/lib/gcc/x86_64-pc-linux-gnu/5.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: bin.v2/libs/math/build/gcc-5.3/gentoorelease/pch-off/threading-multi/hermite.o:1:1: invalid character
collect2: error: ld returned 1 exit status
...skipped <pstage/lib>libboost_math_tr1.so.1.62.0 for lack of <pbin.v2/libs/math/build/gcc-5.3/gentoorelease/pch-off/threading-multi>libboost_math_tr1.so.1.62.0...
gcc.compile.c++ bin.v2/libs/math/build/gcc-5.3/gentoorelease/pch-off/threading-multi/assoc_legendref.o

    "x86_64-pc-linux-gnu-g++"  -ftemplate-depth-128 -march=athlon64 -mtune=amdfam10 -O2 -pipe -fgraphite-identity -floop-interchange -floop-strip-mine -floop-block -ftree-vectorize -ftree-loop-distribution -fvect-cost-m
odel=cheap -std=c++14 -finline-functions -Wno-inline -Wall -pthread -fPIC -m64 -fvisibility=hidden -D
BOOST_ALL_NO_LIB=1 -DBOOST_MATH_TR1_DYN_LINK=1 -DNDEBUG  -I"." -I"libs/math/src/tr1" -c -o "bin.v2/libs/math/build/gcc-5.3/gentoorelease/pch-off/threading-multi/assoc_legendref.o" "libs/math/build/../src/tr1/assoc_legendref.cpp"

...failed updating 1 target...
 * ERROR: dev-libs/boost-1.62.0-r1::gentoo failed (compile phase):
Comment 6 Amit Prakash Ambasta 2018-08-20 09:53:38 UTC
boost-1.61 is no longer part of the portage tree and the bug does not affect 1.63+