InBetweenNames / gentooLTO

A Gentoo Portage configuration for building with -O3, Graphite, and LTO optimizations
GNU General Public License v2.0
571 stars 97 forks source link

libgcrypt 1.9.0 fails to build with LTO #689

Open automorphism88 opened 3 years ago

automorphism88 commented 3 years ago

I tried to build the libgcrypt 1.9.0 upgrade just now and got this error:

libtool: link: x86_64-pc-linux-gnu-gcc -m32 -shared  -fPIC -DPIC  .libs/libgcrypt_la-visibility.o .libs/libgcrypt_la-misc.o .libs/libgcrypt_la-global.o .libs/libgcrypt_la-sexp.o .libs/libgcrypt_la-hwfeatures.o .libs/libgcrypt_la-stdmem.o .libs/libgcrypt_la-secmem.o .libs/libgcrypt_la-missing-string.o .libs/libgcrypt_la-fips.o .libs/libgcrypt_la-hmac256.o .libs/libgcrypt_la-context.o .libs/libgcrypt_la-hwf-x86.o  -Wl,--whole-archive ../cipher/.libs/libcipher.a ../random/.libs/librandom.a ../mpi/.libs/libmpi.a ../compat/.libs/libcompat.a -Wl,--no-whole-archive  -Wl,--as-needed -lgpg-error  -m32 -O3 -flto=24 -fuse-linker-plugin -O3 -march=znver2 -Wl,-O1 -Wl,--version-script=/var/tmp/portage/dev-libs/libgcrypt-1.9.0/work/libgcrypt-1.9.0/src/libgcrypt.vers -Wl,-O1 -O3 -flto=24 -fuse-linker-plugin -march=znver2   -Wl,-soname -Wl,libgcrypt.so.20 -o .libs/libgcrypt.so.20.3.0
../../libgcrypt-1.9.0/cipher/poly1305.c: Assembler messages:
../../libgcrypt-1.9.0/cipher/poly1305.c:389: Error: no such instruction: `umlal %ecx,%ebp,%edi,%esi'
../../libgcrypt-1.9.0/cipher/poly1305.c:389: Error: no such instruction: `umlal %edx,%ebx,%edi,%esi'
../../libgcrypt-1.9.0/cipher/poly1305.c:389: Error: no such instruction: `umlal %esi,%edx,%edi,%ecx'
../../libgcrypt-1.9.0/cipher/poly1305.c:389: Error: no such instruction: `umlal %eax,%edx,%edi,%ecx'
../../libgcrypt-1.9.0/cipher/poly1305.c:389: Error: no such instruction: `umlal %ecx,%eax,%ebp,%edi'
../../libgcrypt-1.9.0/cipher/poly1305.c:389: Error: no such instruction: `umlal %edi,%ebx,%eax,%ebp'
../../libgcrypt-1.9.0/cipher/poly1305.c:389: Error: no such instruction: `umlal %eax,%ebx,%ebp,%esi'
../../libgcrypt-1.9.0/cipher/poly1305.c:389: Error: no such instruction: `umlal %eax,%edx,%ebp,%esi'
../../libgcrypt-1.9.0/cipher/poly1305.c:389: Error: no such instruction: `umlal %edx,%esi,%ebx,%ebp'
../../libgcrypt-1.9.0/cipher/poly1305.c:389: Error: no such instruction: `umlal %edi,%ebp,%ebx,%ecx'
../../libgcrypt-1.9.0/cipher/poly1305.c:389: Error: no such instruction: `umlal %esi,%ebp,%ebx,%ecx'
../../libgcrypt-1.9.0/cipher/poly1305.c:389: Error: no such instruction: `umlal %ecx,%edx,%ebx,%eax'
make[3]: *** [/var/tmp/portage/dev-libs/libgcrypt-1.9.0/temp/ccwRbyDc.mk:50: /var/tmp/portage/dev-libs/libgcrypt-1.9.0/temp/libgcrypt.so.20.3.0.qzUcBc.ltrans16.ltrans.o] Error 1
make[3]: *** Waiting for unfinished jobs....
../../libgcrypt-1.9.0/cipher/poly1305.c: Assembler messages:
../../libgcrypt-1.9.0/cipher/poly1305.c:389: Error: no such instruction: `umlal %edx,%esi,%ebp,%ebx'
../../libgcrypt-1.9.0/cipher/poly1305.c:389: Error: no such instruction: `umlal %ecx,%edi,%ebp,%ebx'
../../libgcrypt-1.9.0/cipher/poly1305.c:389: Error: no such instruction: `umlal %ebx,%edx,%ebp,%esi'
../../libgcrypt-1.9.0/cipher/poly1305.c:389: Error: no such instruction: `umlal %esi,%edx,%ebp,%eax'
../../libgcrypt-1.9.0/cipher/poly1305.c:389: Error: no such instruction: `umlal %edx,%esi,%ebp,%eax'
../../libgcrypt-1.9.0/cipher/poly1305.c:389: Error: no such instruction: `umlal %ecx,%edi,%ebp,%eax'
../../libgcrypt-1.9.0/cipher/poly1305.c:389: Error: no such instruction: `umlal %ebx,%esi,%ebp,%eax'
../../libgcrypt-1.9.0/cipher/poly1305.c:389: Error: no such instruction: `umlal %eax,%ebx,%ebp,%esi'
../../libgcrypt-1.9.0/cipher/poly1305.c:389: Error: no such instruction: `umlal %ebx,%edx,%esi,%ebp'
../../libgcrypt-1.9.0/cipher/poly1305.c:389: Error: no such instruction: `umlal %edx,%edi,%esi,%ebp'
../../libgcrypt-1.9.0/cipher/poly1305.c:389: Error: no such instruction: `umlal %ebx,%esi,%ebp,%ecx'
../../libgcrypt-1.9.0/cipher/poly1305.c:389: Error: no such instruction: `umlal %eax,%edx,%ebp,%ecx'
make[3]: *** [/var/tmp/portage/dev-libs/libgcrypt-1.9.0/temp/ccwRbyDc.mk:11: /var/tmp/portage/dev-libs/libgcrypt-1.9.0/temp/libgcrypt.so.20.3.0.qzUcBc.ltrans3.ltrans.o] Error 1
lto-wrapper: fatal error: make returned 2 exit status
compilation terminated.
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:730: libgcrypt.la] Error 1
make[2]: Leaving directory '/var/tmp/portage/dev-libs/libgcrypt-1.9.0/work/libgcrypt-1.9.0-abi_x86_32.x86/src'
make[1]: *** [Makefile:502: all-recursive] Error 1
make[1]: Leaving directory '/var/tmp/portage/dev-libs/libgcrypt-1.9.0/work/libgcrypt-1.9.0-abi_x86_32.x86'
make: *** [Makefile:434: all] Error 2

Disabling LTO allowed the build to complete successfully, but I haven't tried all possible combinations of flags to see if there might be a way to make LTO work with different flags. However, I did try disabling ccache, and that didn't help. Output of emerge --info is below:

Portage 3.0.13 (python 3.9.1-final-0, default/linux/amd64/17.1/hardened, gcc-10.2.0, glibc-2.32-r5, 5.10.7-gentoo x86_64)
=================================================================
System uname: Linux-5.10.7-gentoo-x86_64-AMD_Ryzen_9_3900X_12-Core_Processor-with-glibc2.32
KiB Mem:   131774476 total,  34121352 free
KiB Swap:          0 total,         0 free
Head commit of repository gentoo: 5923dacae3e17828d547132ef19968f5a0610638

Head commit of repository automorphism: 4660d50ea073435aedfbf77f2f3010312167feae

Timestamp of repository brother-overlay: Tue, 05 Jan 2021 23:59:15 +0000
Head commit of repository brother-overlay: 0e4a8e2e71074904bea62290bb49299472256c94

Timestamp of repository lto-overlay: Fri, 15 Jan 2021 18:10:01 +0000
Head commit of repository lto-overlay: 8a176719ca6ad0dba2cb51abc125639174da46a2

Timestamp of repository mv: Wed, 20 Jan 2021 20:33:00 +0000
Head commit of repository mv: 3ee6444842344996420ca05db293609cb47127ed

sh dash 0.5.11.3-r1
ld GNU ld (Gentoo 2.34 p6) 2.34.0
ccache version 4.1 [enabled]
app-shells/bash:          5.0_p18::gentoo
dev-java/java-config:     2.3.1::gentoo
dev-lang/perl:            5.30.3::gentoo
dev-lang/python:          2.7.18-r100::lto-overlay, 3.8.7-r1::lto-overlay, 3.9.1-r1::lto-overlay
dev-util/ccache:          4.1::gentoo
dev-util/cmake:           3.17.4-r1::gentoo
sys-apps/baselayout:      2.7::gentoo
sys-apps/openrc:          0.42.1::gentoo
sys-apps/sandbox:         2.20::gentoo
sys-devel/autoconf:       2.13-r1::gentoo, 2.69-r5::gentoo
sys-devel/automake:       1.16.2-r1::gentoo
sys-devel/binutils:       2.34-r2::gentoo
sys-devel/gcc:            6.5.0-r3::gentoo, 7.5.0-r1::gentoo, 8.4.0-r1::gentoo, 9.3.0-r1::gentoo, 10.2.0-r3::gentoo
sys-devel/gcc-config:     2.3.2-r1::gentoo
sys-devel/libtool:        2.4.6-r6::gentoo
sys-devel/make:           4.3::gentoo
sys-kernel/linux-headers: 5.4-r1::gentoo (virtual/os-headers)
sys-libs/glibc:           2.32-r5::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: git
    sync-uri: https://github.com/gentoo/gentoo.git
    priority: -1000

automorphism
    location: /home/alex/git/gentoo-overlay
    sync-type: git
    sync-uri: https://github.com/automorphism88/gentoo-overlay.git/
    sync-user: alex
    masters: gentoo

brother-overlay
    location: /var/db/repos/brother-overlay
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/brother-overlay.git
    masters: gentoo

lto-overlay
    location: /var/db/repos/lto-overlay
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/lto-overlay.git
    masters: gentoo mv

mv
    location: /var/db/repos/mv
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/mv.git
    masters: gentoo

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="@FREE unRAR"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O3 -fgraphite-identity -floop-nest-optimize -fdevirtualize-at-ltrans -fipa-pta -fno-semantic-interposition -flto=24 -fuse-linker-plugin -O3 -pipe -march=znver2"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/lib64/libreoffice/program/sofficerc /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.4/ext-active/ /etc/php/cgi-php7.4/ext-active/ /etc/php/cli-php7.4/ext-active/ /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="-O3 -fgraphite-identity -floop-nest-optimize -fdevirtualize-at-ltrans -fipa-pta -fno-semantic-interposition -flto=24 -fuse-linker-plugin -O3 -pipe -march=znver2"
DISTDIR="/var/cache/distfiles"
EMERGE_DEFAULT_OPTS="--with-bdeps=y --buildpkg-exclude "*/*-bin acct-*/* games-board/tablebase-syzygy net-im/skypeforlinux net-im/zoom net-misc/dropbox virtual/* sys-devel/multilib-gcc-wrapper sys-kernel/*-sources sys-kernel/linux-firmware www-client/google-chrome-*" --binpkg-respect-use=y --binpkg-changed-deps=y"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
FCFLAGS="-O3 -fgraphite-identity -floop-nest-optimize -fdevirtualize-at-ltrans -fipa-pta -fno-semantic-interposition -flto=24 -fuse-linker-plugin -O3 -pipe -march=znver2"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg ccache config-protect-if-modified distlocks ebuild-locks fakeroot fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O3 -fgraphite-identity -floop-nest-optimize -fdevirtualize-at-ltrans -fipa-pta -fno-semantic-interposition -flto=24 -fuse-linker-plugin -O3 -pipe -march=znver2"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
INSTALL_MASK="/usr/share/locale -/usr/share/locale/en*"
LANG="C.UTF8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LINGUAS="en"
MAKEOPTS="-j24"
PKGDIR="/var/cache/binpkgs"
PORTAGE_COMPRESS="xz"
PORTAGE_COMPRESS_FLAGS="-9e"
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 acl acpi amd64 bittorrent bluetooth bluray branding brotli btrfs bzip2 cairo cdda cdr crypt cryptsetup cups dbus dri dts dvd dvdr egl emacs emboss encode exif ffmpeg flac gif gles2 gnome gnome-keyring gnome-shell gpm gstreamer gtk gtk3 gui hardened iconv icu introspection ipv6 jpeg lcms libglvnd libnotify libtirpc lm-sensors lto mad mng mp3 mp4 mpeg multilib ncurses networkmanager nls nptl nss offensive ogg opencl opengl openmp opus pam pango pcre pdf pgo pie png policykit ppds pulseaudio qt5 readline scanner sdl seccomp spell split-usr ssl ssp startup-notification svg systemd theora tiff truetype udev udisks unicode upower usb user-session vaapi vdpau vorbis vulkan wayland wifi wxwidgets x264 x265 xattr xcb xfce xml xtpax xv xvid zlib zstd" ABI_X86="64 32" ADA_TARGET="gnat_2018" 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="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx avx2 f16c fma3 mmx mmxext pclmul popcnt rdrand sha sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput" KERNEL="linux" L10N="en en_US" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LLVM_TARGETS="X86 AMDGPU BPF" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-3 php7-4" POSTGRES_TARGETS="postgres10 postgres11" PYTHON_SINGLE_TARGET="python3_8" PYTHON_TARGETS="python2_7 python3_8 python3_9" RUBY_TARGETS="ruby25 ruby26 ruby27 ruby30" SANE_BACKENDS="net" USERLAND="GNU" VIDEO_CARDS="amdgpu radeonsi" 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, LC_ALL, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_RSYNC_EXTRA_OPTS
AntarcticanWaffles commented 3 years ago

I encountered the same error, and adding -ffat-lto-objects lets it build again.

dev-libs/libgcrypt-1.9.0::gentoo was built with the following:
USE="-doc -o-flag-munging -static-libs" ABI_X86="32 (64) (-x32)"
CFLAGS="-march=skylake -O3 -fgraphite-identity -floop-nest-optimize -fdevirtualize-at-ltrans -fipa-pta -fno-semantic-interposition -flto=auto -fuse-linker-plugin -pipe -falign-functions=32 -ffat-lto-objects -Wl,-O1 -Wl,--as-needed"
CXXFLAGS="-march=skylake -O3 -fgraphite-identity -floop-nest-optimize -fdevirtualize-at-ltrans -fipa-pta -fno-semantic-interposition -flto=auto -fuse-linker-plugin -pipe -falign-functions=32 -ffat-lto-objects -Wl,-O1 -Wl,--as-needed"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -march=skylake -O3 -fgraphite-identity -floop-nest-optimize -fdevirtualize-at-ltrans -fipa-pta -fno-semantic-interposition -flto=auto -fuse-linker-plugin -pipe -falign-functions=32 -ffat-lto-objects"
pchome commented 3 years ago

Add this in your env:

gcry_cv_gcc_arm_platform_as_ok=no
gcry_cv_gcc_aarch64_platform_as_ok=no

or disable other platforms via EXTRA_ECONF (see ./configure --help).

alanswanson commented 3 years ago

Trying fat-lto-objects failed in configures C compilation test - usual occurrence with fat-lto-objects for a 32/64 multilib build. However applying the following upstream commit (needed to remove the last four hunks for s390 for the ebuild) fixes the LTO build.

https://git.gnupg.org/cgi-bin/gitweb.cgi?p=libgcrypt.git;a=commitdiff;h=393bd6c3d1aa2b2a1b05be0e2d7fb2514e6c5ad0

khuei commented 3 years ago

Are you still having the same issue?

I don't seem to encounter with this issue on libgcrypt-1.9.2

alanswanson commented 3 years ago

All fine since the libgcrypt release with previously referenced commit.