Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 695618 - sys-devel/clang-9.0.0: crashes when compiling with -march=x86-64 -O1 -fno-plt -m32
Summary: sys-devel/clang-9.0.0: crashes when compiling with -march=x86-64 -O1 -fno-plt...
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: LLVM support project
Depends on:
Reported: 2019-09-25 12:26 UTC by Michał Bartoszkiewicz
Modified: 2020-02-19 10:42 UTC (History)
3 users (show)

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

build.log (compiler-rt-sanitizers-9.0.0:20190925-085432.log,918.42 KB, text/plain)
2019-09-25 12:26 UTC, Michał Bartoszkiewicz
Reproducer script (,7.80 KB, text/plain)
2019-09-25 12:27 UTC, Michał Bartoszkiewicz
Preprocessed source (wrappers_c-d34ae5.cpp.gz,167.51 KB, application/gzip)
2019-09-25 12:27 UTC, Michał Bartoszkiewicz

Note You need to log in before you can comment on or make changes to this bug.
Description Michał Bartoszkiewicz 2019-09-25 12:26:05 UTC
Created attachment 591020 [details]

sys-libs/compiler-rt-sanitizers-9.0.0 fails to compile for me (using clang 9.0.0) with a segfault.
This is completely reproducible and I have same failures on 3 of my computers running Gentoo, so I'm pretty sure it is not a hardware problem.

Build log attached.

# emerge --info
Portage 2.3.76 (python 3.7.4-final-0, default/linux/amd64/17.1/desktop/gnome/systemd, gcc-9.2.0, glibc-2.29-r5, 5.3.0-rc8 x86_64)
System uname: Linux-5.3.0-rc8-x86_64-Intel-R-_Core-TM-_i7-7700HQ_CPU_@_2.80GHz-with-gentoo-2.6
KiB Mem:    32711540 total,  11609928 free
KiB Swap:    8388604 total,   7553008 free
Timestamp of repository gentoo: Tue, 24 Sep 2019 08:06:21 +0000
Head commit of repository gentoo: 4efc8d3753f53bffda3f90644fc52d2541be9aa1

Head commit of repository embe: 3f441be182267fe8da37e83f3f815b1ae0ade8d7

sh bash 5.0_p11
ld GNU ld (Gentoo 2.32 p2) 2.32.0
app-shells/bash:          5.0_p11::gentoo
dev-java/java-config:     2.2.0-r4::gentoo
dev-lang/perl:            5.30.0::gentoo
dev-lang/python:          2.7.16::gentoo, 3.6.9::gentoo, 3.7.4-r1::gentoo
dev-util/cmake:           3.15.3::gentoo
dev-util/pkgconfig:       0.29.2::gentoo
sys-apps/baselayout:      2.6-r1::gentoo
sys-apps/sandbox:         2.18::gentoo
sys-devel/autoconf:       2.13-r1::gentoo, 2.69-r4::gentoo
sys-devel/automake:       1.11.6-r3::gentoo, 1.16.1-r1::gentoo
sys-devel/binutils:       2.32-r1::gentoo
sys-devel/gcc:            9.2.0-r1::gentoo
sys-devel/gcc-config:     2.1::gentoo
sys-devel/libtool:        2.4.6-r5::gentoo
sys-devel/make:           4.2.1-r4::gentoo
sys-kernel/linux-headers: 5.3::gentoo (virtual/os-headers)
sys-libs/glibc:           2.29-r5::gentoo

    location: /var/db/repos/gentoo
    sync-type: git
    sync-uri: git://
    priority: -1000
    sync-git-verify-commit-signature: true

    location: /var/db/repos/embe
    sync-type: git
    masters: gentoo

ACCEPT_KEYWORDS="amd64 ~amd64"
CFLAGS="-march=native -O2 -pipe -ggdb -fno-plt -fstack-clash-protection"
CONFIG_PROTECT="/etc /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=native -O2 -pipe -ggdb -fno-plt -fstack-clash-protection"
EMERGE_DEFAULT_OPTS="--with-bdeps y --complete-graph y --quiet-build y"
FCFLAGS="-march=native -O2 -pipe -ggdb -fno-plt -fstack-clash-protection"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs buildpkg clean-logs compressdebug config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync mount-sandbox multilib-strict network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned sandbox sfperms split-log splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-march=native -O2 -pipe -ggdb -fno-plt -fstack-clash-protection"
INSTALL_MASK="/etc/rmt /var/run /etc/xinetd.d /var/lock /var/mail /etc/skel /usr/share/man/cat*"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-z,now"
LINGUAS="en en_US pl pl_PL"
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"
USE="R X a52 aac aacplus acl acpi adns alsa amd64 android archive ass avahi avx bazaar bluetooth bluray brotli bzip2 cairo caps cdb cdda cddb cdr chromecast cli clutter colord conntrack crypt cryptsetup cups curl cvs cxx dbus dconf device-mapper dirac djvu dri dts dvd dvdr dvi eds egl elfutils emboss encode evdev evo exif fam fat ffmpeg fftw flac fontconfig fortran fuse gadu gd gdbm gegl geoclue gif gimp git glamor gmp gnome gnome-keyring gnome-online-accounts gnuplot gpg gphoto2 graphicsmagick graphviz gsl gstreamer gtk gtk3 gtkstyle guile harfbuzz http2 iconv icu id3tag idn introspection iproute2 ipv6 java jit jpeg jpeg2k lame lapack latex lcms libass libkms libnotify libproxy libsamplerate libsecret libtirpc live llvm lua lzma lzo mad maildir man matroska mercurial metalink metric mms mmxext mng modemmanager mp3 mp4 mpeg mtp multilib musepack nautilus ncurses netlink networkmanager nls nptl obex offensive ogg openal openexr opengl openmp opus osmesa pam pango pcap pch pcre pdf pgf pkcs11 playlist plotutils png policykit postproc postscript ppds pulseaudio python raw rdp readline rtmp rubberband samba sdl seccomp sftp sip smartcard smi smp snappy speex spell spice sqlite sse3 sse4 sse41 sse4_1 ssl ssse3 startup-notification subversion svg syslog systemd theora tiff tls tracker truetype udev udisks unicode upnp upnp-av upower urandom usb user-session uuid v4l vaapi vala vdpau vim-syntax vlc vorbis vpx vte wayland webp wifi wxwidgets x264 xattr xcb xinerama xml xmp xmpp xv xvid zeroconf zlib zsh-completion" ABI_X86="32 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" APACHE2_MPMS="prefork" 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 sse sse2 sse3 sse4_1 sse4_2 ssse3" CURL_SSL="openssl" 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 efi-64" INPUT_DEVICES="libinput" KERNEL="linux" L10N="en pl" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="nlpsolver" LLVM_TARGETS="AMDGPU BPF X86 WebAssembly" NETBEANS_MODULES="apisupport cnd groovy gsf harness ide identity j2ee java mobility nb php profiler soa visualweb webcommon websvccommon xml" OFFICE_IMPLEMENTATION="libreoffice" POSTGRES_TARGETS="postgres10 postgres11" PYTHON_SINGLE_TARGET="python3_6" PYTHON_TARGETS="python2_7 python3_6 python3_7" QEMU_SOFTMMU_TARGETS="x86_64 i386 arm" QEMU_USER_TARGETS="arm" RUBY_TARGETS="ruby25 ruby26" USERLAND="GNU" VIDEO_CARDS="radeon radeonsi r600 amdgpu intel i915 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"
Comment 1 Michał Bartoszkiewicz 2019-09-25 12:27:00 UTC
Created attachment 591022 [details]
Reproducer script
Comment 2 Michał Bartoszkiewicz 2019-09-25 12:27:37 UTC
Created attachment 591024 [details]
Preprocessed source
Comment 3 Sergei Trofimovich gentoo-dev 2019-09-27 07:47:55 UTC
Reduced example:

$ cat wrappers_c-d34ae5.cpp
__attribute__((weak)) void a();
void b() {
  if (a)

$ "/usr/lib/llvm/9/bin/clang-9" -c wrappers_c-d34ae5.cpp -o a.o -march=sandybridge -O2 -fno-plt -m32

Stack dump:
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module 'wrappers_c-d34ae5.cpp'.
4.	Running pass 'Machine Common Subexpression Elimination' on function '@_Z1bv'
 #0 0x00007f327641408a llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/usr/lib/llvm/9/bin/../lib64/
 #1 0x00007f3276412344 llvm::sys::RunSignalHandlers() (/usr/lib/llvm/9/bin/../lib64/
Comment 4 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2019-09-28 06:05:14 UTC
Thanks for reducing it.  I can reproduce with the reduced code, even with '-march=x86-64 -O1 -fno-plt -m32'.  I'm going to test trunk, in case it's been fixed upstream.
Comment 5 Mateusz Mikuła 2019-09-28 08:01:46 UTC
Also can reproduce Clang crahs when building 32 bit `compiler-rt-sanitizers` on amd64.
Moreover any 32 bit executable produced by Clang will segfault, I think it may be related to compiler-Rt (I use it by default) but I cannot check right now.
Comment 6 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2019-09-28 08:14:03 UTC
I've been able to reproduce with Clang 8 and trunk.  I'm currently rebuilding trunk with debug info to get a nice stack trace, and I'll file it upstream afterwards.
Comment 7 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2019-09-28 08:18:04 UTC
That said, looking at upstream Bugzilla -fno-plt may have more problems than that (apparently it can produce broken code), so I doubt it's a good idea to use it.
Comment 8 Mateusz Mikuła 2019-10-12 10:59:41 UTC is said to resolve this but I won't be able to test it for another 2 weeks.
Comment 9 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2019-10-12 11:10:57 UTC
No problem, it will probably take some time before it's merged anyway.  I'll subscribe and possibly call for backport when that happens.
Comment 10 Mateusz Mikuła 2019-10-21 09:53:27 UTC
With example from doesn't crash for me.

Compiler-rt testsuite was still crashing for me but because it ignores LDFLAGS (I've added `-fuse-ld=lld` to make.conf). Forcing it to use LLD made tests pass.
Maybe LD 2.32 cannot link properly compiler-rt objects or something else on my system is casing this issue but it doesn't matter.
I'll patch my Clang to use LLD by default instead of relying solely of LDFLAGS.
Comment 11 Derek Dolney 2020-02-18 16:26:23 UTC
Bump, this just hit stable. Stable tree will not build at this time.