Trying to build dev-util/radare2-4.5.0 with -flto as part of CFLAGS and CXXFLAGS leads to radare2 causing the linker to segfault. Reproducible: Always Steps to Reproduce: 1.emerge -1 radare2 Actual Results: during IPA pass: cp lto1: internal compiler error: Segmentation fault 0x7f7fe12e8c9f ??? /tmp/portage/sys-libs/glibc-2.31-r6/work/glibc-2.31/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0 0x7f7fe12d3d59 __libc_start_main ../csu/libc-start.c:308 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://bugs.gentoo.org/> for instructions. lto-wrapper: fatal error: x86_64-pc-linux-gnu-gcc returned 1 exit status compilation terminated. /usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: lto-wrapper failed collect2: error: ld returned 1 exit status Expected Results: emerge succeeds. I've added -flto to my CXXFLAGS and CFLAGS, and I am slowly letting programs update themselves to use LTO if possible (if not, I'm using -fno-lto in an an env configuration in package.env to disable it for those problematic ones). For my usecase I can disable LTO for radare2 (which builds in that case), but I wanted to report this bug as it is causing GCC to segfault. Should I rebuild GCC with debugging symbols and -fno-omit-frame-pointer (I'm also building with -fomit-frame-pointer)? Here's my emerge --info: Portage 3.0.0 (python 3.7.8-final-0, default/linux/amd64/17.1/desktop/plasma, gcc-10.1.0, glibc-2.31-r6, 5.7.9-gentoo x86_64) ================================================================= System uname: Linux-5.7.9-gentoo-x86_64-Intel-R-_Core-TM-_i7-3770K_CPU_@_3.50GHz-with-gentoo-2.7 KiB Mem: 16351848 total, 8015464 free KiB Swap: 16776192 total, 16776192 free Timestamp of repository gentoo: Tue, 21 Jul 2020 17:45:01 +0000 Head commit of repository gentoo: 19c3e94aa0d6f570381cd5f57e13c0e7925077c0 sh bash 5.0_p18 ld GNU ld (Gentoo 2.34 p4) 2.34.0 distcc 3.3.3 x86_64-pc-linux-gnu [disabled] ccache version 3.7.10 [disabled] app-shells/bash: 5.0_p18::gentoo dev-java/java-config: 2.3.1::gentoo dev-lang/perl: 5.30.3-r1::gentoo dev-lang/python: 2.7.18-r1::gentoo, 3.7.8-r2::gentoo, 3.8.5::gentoo, 3.9.0_beta5::gentoo dev-util/ccache: 3.7.10::gentoo dev-util/cmake: 3.17.3::gentoo dev-util/pkgconfig: 0.29.2::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::gentoo sys-devel/binutils: 2.34-r1::gentoo sys-devel/gcc: 10.1.0-r2::gentoo sys-devel/gcc-config: 2.3.1::gentoo sys-devel/libtool: 2.4.6-r6::gentoo sys-devel/make: 4.3::gentoo sys-kernel/linux-headers: 5.7::gentoo (virtual/os-headers) sys-libs/glibc: 2.31-r6::gentoo Repositories: gentoo location: /var/db/repos/gentoo sync-type: rsync sync-uri: rsync://rsync.us.gentoo.org/gentoo-portage priority: -1000 sync-rsync-verify-max-age: 24 sync-rsync-verify-jobs: 1 sync-rsync-verify-metamanifest: yes sync-rsync-extra-opts: Local_Overlay location: /var/db/repos/local masters: gentoo eclass-overrides: gentoo Local_Overlay crossdev location: /var/db/repos/crossdev masters: gentoo eclass-overrides: gentoo crossdev brother-overlay location: /var/lib/layman/brother-overlay masters: gentoo priority: 50 chrytoo location: /var/lib/layman/chrytoo masters: gentoo priority: 50 ACCEPT_KEYWORDS="amd64 ~amd64" ACCEPT_LICENSE="@FREE" CBUILD="x86_64-pc-linux-gnu" CFLAGS="-march=ivybridge -pipe -fomit-frame-pointer -O2 -flto" CHOST="x86_64-pc-linux-gnu" CONFIG_PROTECT="/etc /opt/brother/scanner/brscan4/brsanenetdevice4.cfg /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/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="-march=ivybridge -pipe -fomit-frame-pointer -O2 -flto" DISTDIR="/var/cache/distfiles" ENV_UNSET="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="-march=ivybridge -pipe -fomit-frame-pointer -O2 -flto" FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs clean-logs config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms split-log strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr" FFLAGS="-march=ivybridge -pipe -fomit-frame-pointer -O2 -flto" GENTOO_MIRRORS="http://distfiles.gentoo.org" LANG="en_US.utf8" LDFLAGS="-Wl,-O1 -Wl,--as-needed" LINGUAS="en es" MAKEOPTS="-j9" PKGDIR="/var/cache/binpkgs" 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="/tmp" USE="=-ppp X a52 aac acl acpi activities alsa amd64 avx bash-completion berkdb bluetooth branding bzip2 cairo cdda cdr cli crypt cups dbus declarative dri dts dvd dvdr elogind emboss encode exif flac fortran gdbm gif gpm gtk iconv icu ipv6 jpeg kde kipi kwallet lcms ldap libnotify libtirpc lm-sensors lto mad mmx mng mp3 mp4 mpeg mtp multilib ncurses nls nptl nvidia ogg opengl openmp pam pango pcre pdf phonon plasma png policykit ppds pulseaudio qml qt qt5 readline sdl seccomp semantic-desktop spell split-usr sse sse2 sse3 sse4 ssl startup-notification svg tcpd tiff truetype udev udisks unicode upower usb vdpau vorbis widgets wxwidgets x264 xattr xcb xml xv xvid zlib" ABI_X86="64" 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 mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 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" GRUB_PLATFORMS="efi-64 emu" INPUT_DEVICES="evdev roccat_tyon" KERNEL="linux" L10N="en es" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-2 php7-3" POSTGRES_TARGETS="postgres10 postgres11" PYTHON_SINGLE_TARGET="python3_7" PYTHON_TARGETS="python2_7 python3_7 python3_7 python3_8" RUBY_TARGETS="ruby25" SANE_BACKENDS="test" USERLAND="GNU" VIDEO_CARDS="nvidia" 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, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Created attachment 650160 [details] radare2 build segfault build.log Here is the build log showing the segmentation fault.
Reproduced locally. Fails for both gcc-10.1.0 and gcc-11.0.0. Looking.
Bit of gcc backtrace: """ x86_64-pc-linux-gnu-gcc -march=ivybridge -pipe -fomit-frame-pointer -O2 -flto -frecord-gcc-switches -march=ivybridge -pipe -fomit-frame-pointer -O2 -flto -frecord-gcc-switches -march=ivybridge -pipe -fomit-frame-pointer -O2 -flto -frecord-gcc-switches -MD -fPIC -g -Wall -D__UNIX__=1 -march=ivybridge -pipe -fomit-frame-pointer -O2 -flto -frecord-gcc-switches -MD -fPIC -g -Wall -D__UNIX__=1 -DR2_PLUGIN_INCORE -I/tmp/portage/dev-util/radare2-4.5.0/work/radare2-4.5.0/libr/..//shlr -I/tmp/portage/dev-util/radare2-4.5.0/work/radare2-4.5.0/libr/../shlr/zip/include -I/tmp/portage/dev-util/radare2-4.5.0/work/radare2-4.5.0/libr -I/tmp/portage/dev-util/radare2-4.5.0/work/radare2-4.5.0/libr/include -fvisibility=hidden -I../../shlr/sdb/src//src -DHAVE_FORK=1 -DUSE_R2=1 -I../../shlr -std=gnu99 -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -Wall -Wsign-compare -g -Wall -O0 -MMD -fPIC -g -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 -lm -lssl -lcrypto -lpthread -ldl -lm -fvisibility=hidden -o sdb main.o cdb.o buffer.o cdb_make.o ls.o sdbht.o ht_uu.o sdb.o num.o base64.o match.o json.o ns.o lock.o util.o disk.o query.o array.o fmt.o journal.o dict.o ht_pp.o ht_up.o set.o diff.o during IPA pass: cp lto1: internal compiler error: Segmentation fault 0xa6d3df crash_signal /usr/src/debug/sys-devel/gcc-11.0.0_pre9999/gcc-11.0.0_pre9999/gcc/toplev.c:328 0x7f01be86bc3f ??? /usr/src/debug/sys-libs/glibc-2.31-r6/glibc-2.31/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0 0x5d4751 has_undead_caller_from_outside_scc_p /usr/src/debug/sys-devel/gcc-11.0.0_pre9999/gcc-11.0.0_pre9999/gcc/ipa-cp.c:5670 0x680054 cgraph_node::call_for_symbol_thunks_and_aliases(bool (*)(cgraph_node*, void*), void*, bool, bool) /usr/src/debug/sys-devel/gcc-11.0.0_pre9999/gcc-11.0.0_pre9999/gcc/cgraph.c:2450 0x12fe86d identify_dead_nodes /usr/src/debug/sys-devel/gcc-11.0.0_pre9999/gcc-11.0.0_pre9999/gcc/ipa-cp.c:5687 0x12fe86d ipcp_decision_stage /usr/src/debug/sys-devel/gcc-11.0.0_pre9999/gcc-11.0.0_pre9999/gcc/ipa-cp.c:5730 0x12fe86d ipcp_driver /usr/src/debug/sys-devel/gcc-11.0.0_pre9999/gcc-11.0.0_pre9999/gcc/ipa-cp.c:5908 0x12fe86d execute /usr/src/debug/sys-devel/gcc-11.0.0_pre9999/gcc-11.0.0_pre9999/gcc/ipa-cp.c:5999 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://bugs.gentoo.org/> for instructions. """
Reported upstream as https://gcc.gnu.org/PR96291
Created attachment 650756 [details, diff] 0001-ipa-96291-don-t-crash-on-unoptimized-lto-functions.patch If you are feeling adventurous you can test 0001-ipa-96291-don-t-crash-on-unoptimized-lto-functions.patch gcc patch. You will need to add it to /etc/portage/patches/sys-devel/gcc:10/ and rebuild gcc.
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=8f9b6cda0cd772b5155d52a5effabd04fd656a18 commit 8f9b6cda0cd772b5155d52a5effabd04fd656a18 Author: Sergei Trofimovich <slyfox@gentoo.org> AuthorDate: 2020-07-26 10:34:45 +0000 Commit: Sergei Trofimovich <slyfox@gentoo.org> CommitDate: 2020-07-26 10:34:45 +0000 10.2.0: fix IPA ICE on LTO -O0/-O2 mix Bug: https://bugs.gentoo.org/733482 Bug: https://gcc.gnu.org/PR96291 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> .../gentoo/33_all_lto-O0-mix-ICE-ipa-PR96291.patch | 46 ++++++++++++++++++++++ 10.2.0/gentoo/README.history | 3 ++ 2 files changed, 49 insertions(+)
Queued patch for next gcc patchset. It usually takes about a month to get into next revbump of gcc in gentoo.
I have a similar ICE when compiling another package, and it's not solved by the proposed patch: x86_64-pc-linux-gnu-gcc -pthread -fPIC -fno-strict-aliasing -O3 -march=native -mlwp -pipe -fwrapv -DNDEBUG -fprofile-generate -flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none -g -I. -I/var/tmp/portage/dev-lang/tauthon-2.8.2/work/tauthon-2.8.2/Include -I/var/tmp/portage/dev-lang/tauthon -2.8.2/work/x86_64-pc-linux-gnu -c /var/tmp/portage/dev-lang/tauthon-2.8.2/work/tauthon-2.8.2/Modules/parsermodule.c -o build/temp.linux-x86_64-2.8/var /tmp/portage/dev-lang/tauthon-2.8.2/work/tauthon-2.8.2/Modules/parsermodule.o [...] x86_64-pc-linux-gnu-gcc -pthread -fPIC -fno-strict-aliasing -O3 -march=native -mlwp -pipe -fwrapv -DNDEBUG -fprofile-use -fprofile-correction -flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none -g -I. -I/var/tmp/portage/dev-lang/tauthon-2.8.2/work/tauthon-2.8.2/Include -I/var/tmp/portage/dev-lang/tauthon-2.8.2/work/x86_64-pc-linux-gnu -c /var/tmp/portage/dev-lang/tauthon-2.8.2/work/tauthon-2.8.2/Modules/parsermodule.c -o build/temp.linux-x86_64-2.8/var/tmp/portage/dev-lang/tauthon-2.8.2/work/tauthon-2.8.2/Modules/parsermodule.o during IPA pass: inline /var/tmp/portage/dev-lang/tauthon-2.8.2/work/tauthon-2.8.2/Modules/parsermodule.c:3760:1: internal compiler error: in add_new_edges_to_heap, at ipa-inline.c:1746 3760 | } | ^
(In reply to Ștefan Talpalaru from comment #8) > I have a similar ICE when compiling another package, and it's not solved by > the proposed patch: > > x86_64-pc-linux-gnu-gcc -pthread -fPIC -fno-strict-aliasing -O3 > -march=native -mlwp -pipe -fwrapv -DNDEBUG -fprofile-generate -flto > -fuse-linker-plugin > -ffat-lto-objects -flto-partition=none -g -I. > -I/var/tmp/portage/dev-lang/tauthon-2.8.2/work/tauthon-2.8.2/Include > -I/var/tmp/portage/dev-lang/tauthon > -2.8.2/work/x86_64-pc-linux-gnu -c > /var/tmp/portage/dev-lang/tauthon-2.8.2/work/tauthon-2.8.2/Modules/ > parsermodule.c -o build/temp.linux-x86_64-2.8/var > /tmp/portage/dev-lang/tauthon-2.8.2/work/tauthon-2.8.2/Modules/parsermodule.o > > [...] > > x86_64-pc-linux-gnu-gcc -pthread -fPIC -fno-strict-aliasing -O3 > -march=native -mlwp -pipe -fwrapv -DNDEBUG -fprofile-use > -fprofile-correction -flto -fuse-linker-plugin -ffat-lto-objects > -flto-partition=none -g -I. > -I/var/tmp/portage/dev-lang/tauthon-2.8.2/work/tauthon-2.8.2/Include > -I/var/tmp/portage/dev-lang/tauthon-2.8.2/work/x86_64-pc-linux-gnu -c > /var/tmp/portage/dev-lang/tauthon-2.8.2/work/tauthon-2.8.2/Modules/ > parsermodule.c -o > build/temp.linux-x86_64-2.8/var/tmp/portage/dev-lang/tauthon-2.8.2/work/ > tauthon-2.8.2/Modules/parsermodule.o > during IPA pass: inline > /var/tmp/portage/dev-lang/tauthon-2.8.2/work/tauthon-2.8.2/Modules/ > parsermodule.c:3760:1: internal compiler error: in add_new_edges_to_heap, at > ipa-inline.c:1746 > 3760 | } > | ^ This is probably a similar but distinct bug in ipa-inline (opposed to SIGSEGV in ipa constrant propagation in this bug). I suggest sorting it out in a new bug. Can you file one with a link to the ebuild? I'll try to reproduce locally.
Filed https://bugs.gentoo.org/734006
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=9bba1f72a9210743fddf664b716b5cf288132922 commit 9bba1f72a9210743fddf664b716b5cf288132922 Author: Sergei Trofimovich <slyfox@gentoo.org> AuthorDate: 2020-08-23 09:11:31 +0000 Commit: Sergei Trofimovich <slyfox@gentoo.org> CommitDate: 2020-08-23 09:11:31 +0000 10.2.0: cut 2 patchset Four new patches: + 33_all_lto-O0-mix-ICE-ipa-PR96291.patch: fix -O0 crash for ipa/lto + 34_all_fundecl-ICE-PR95820.patch: fix ICE on invalid templates + 35_all_ipa-fix-bit-CP.patch: fix bad code generation in ipa bit constprop + 36_all_ipa-fix-bit-CP-p2.patch: part 2 of previous patch Bug: https://bugs.gentoo.org/733482 Bug: https://gcc.gnu.org/PR96291 Bug: https://bugs.gentoo.org/730406 Bug: https://gcc.gnu.org/PR95820 Bug: https://bugs.gentoo.org/736685 Bug: https://gcc.gnu.org/PR96482 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> 10.2.0/gentoo/README.history | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=653d6bf6ea15bdf2db033e3099913bac47f5b0e0 commit 653d6bf6ea15bdf2db033e3099913bac47f5b0e0 Author: Sergei Trofimovich <slyfox@gentoo.org> AuthorDate: 2020-08-23 09:17:12 +0000 Commit: Sergei Trofimovich <slyfox@gentoo.org> CommitDate: 2020-08-23 09:17:12 +0000 sys-devel/gcc: cut 2 patchset Four new patches: + 33_all_lto-O0-mix-ICE-ipa-PR96291.patch: fix -O0 crash for ipa/lto + 34_all_fundecl-ICE-PR95820.patch: fix ICE on invalid templates + 35_all_ipa-fix-bit-CP.patch: fix bad code generation in ipa bit constprop + 36_all_ipa-fix-bit-CP-p2.patch: part 2 of previous patch Closes: https://bugs.gentoo.org/733482 Bug: https://gcc.gnu.org/PR96291 Closes: https://bugs.gentoo.org/730406 Bug: https://gcc.gnu.org/PR95820 Closes: https://bugs.gentoo.org/736685 Bug: https://gcc.gnu.org/PR96482 Package-Manager: Portage-3.0.4, Repoman-3.0.1 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> sys-devel/gcc/Manifest | 1 + sys-devel/gcc/gcc-10.2.0-r1.ebuild | 13 +++++++++++++ 2 files changed, 14 insertions(+)