Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 330553 - sys-devel/clang-2.7-r2 builds but can't compile trivial C code
Summary: sys-devel/clang-2.7-r2 builds but can't compile trivial C code
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Bernard Cafarelli
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-30 18:28 UTC by David Ripton
Modified: 2010-08-08 14:59 UTC (History)
0 users

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Ripton 2010-07-30 18:28:41 UTC
emerged sys-devel/clang-2.7-r2.  It builds fine.  But trying to compile the following program:

#include <stdio.h>
int main()
{
    printf("Hello world!\n");
}

results in signal 11

$ clang hello.c
0  clang 0x08e49208
Stack dump:
0.      Program arguments: /usr/bin/clang -cc1 -triple i386-pc-linux-gnu -S -disable-free -disable-llvm-verifier -main-file-name hello.c -mrelocation-model static -mdisable-fp-elim -mconstructor-aliases -target-cpu pentium4 -resource-dir /usr/lib/clang/1.1 -fmessage-length 103 -fgnu-runtime -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/cc-GbqGt6.s -x c hello.c
1.      <eof> parser at end of file
2.      Per-module optimization passes
clang: error: compiler command failed due to signal 11 (use -v to see invocation)

$ clang -v hello.c
clang version 1.1 (branches/release_27)
Target: i386-pc-linux-gnu
Thread model: posix
 "/usr/bin/clang" -cc1 -triple i386-pc-linux-gnu -S -disable-free -disable-llvm-verifier -main-file-name hello.c -mrelocation-model static -mdisable-fp-elim -mconstructor-aliases -target-cpu pentium4 -v -resource-dir /usr/lib/clang/1.1 -fmessage-length 103 -fgnu-runtime -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/cc-fcTmbR.s -x c hello.c
clang -cc1 version 1.1 based upon llvm 2.7 hosted on i386-pc-linux-gnu
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/clang/1.1/include
 /usr/local/include
 /usr/include
End of search list.
0  clang 0x08e49208
Stack dump:
0.      Program arguments: /usr/bin/clang -cc1 -triple i386-pc-linux-gnu -S -disable-free -disable-llvm-verifier -main-file-name hello.c -mrelocation-model static -mdisable-fp-elim -mconstructor-aliases -target-cpu pentium4 -v -resource-dir /usr/lib/clang/1.1 -fmessage-length 103 -fgnu-runtime -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/cc-fcTmbR.s -x c hello.c
1.      <eof> parser at end of file
clang: error: compiler command failed due to signal 11 (use -v to see invocation)

100% repeatable, not one of those random sig 11s due to bad memory.
Comment 1 David Ripton 2010-07-30 18:29:04 UTC
$ emerge --info
Portage 2.1.8.3 (default/linux/x86/10.0/desktop, gcc-4.3.4, glibc-2.11.2-r0, 2.6.34-gentoo i686)
=================================================================
System uname: Linux-2.6.34-gentoo-i686-AMD_Processor_model_-with-gentoo-2.0.1
Timestamp of tree: Fri, 30 Jul 2010 08:00:20 +0000
app-shells/bash:     4.1_p7
dev-java/java-config: 2.1.11
dev-lang/python:     2.6.5-r3, 3.1.2-r4
dev-util/cmake:      2.8.1-r2
sys-apps/baselayout: 2.0.1
sys-apps/openrc:     0.6.1-r1
sys-apps/sandbox:    2.2
sys-devel/autoconf:  2.13, 2.65-r1
sys-devel/automake:  1.5, 1.7.9-r1, 1.9.6-r3, 1.10.3, 1.11.1
sys-devel/binutils:  2.20.1-r1
sys-devel/gcc:       4.3.4, 4.4.4-r1
sys-devel/gcc-config: 1.4.1
sys-devel/libtool:   2.2.10
virtual/os-headers:  2.6.34
ACCEPT_KEYWORDS="x86 ~x86"
ACCEPT_LICENSE="*"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-Qunused-arguments"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/X11/xkb /usr/share/config /var/bind /var/lib/hsqldb"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/games/angband/edit/ /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"
CPPFLAGS="-Qunused-arguments"
CXXFLAGS="-march=amdfam10 -O3 -pipe -fomit-frame-pointer"
DISTDIR="/usr/portage/distfiles"
FEATURES="assume-digests distlocks fixpackages news parallel-fetch protect-owned sandbox sfperms strict unmerge-logs unmerge-orphans userfetch userpriv"
GENTOO_MIRRORS="http://gentoo.oregonstate.edu/ http://gentoo.mirrors.pair.com/ http://mirror.datapipe.net/gentoo http://128.213.5.34/gentoo/ http://mirror.datapipe.net/gentoo"
LDFLAGS="-Wl,--as-needed"
MAKEOPTS="-j8"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="3dnow X a52 aac acl acpi alsa apache2 bash-completion branding bzip2 cairo cdr cli consolekit cracklib crypt cups cxx d dbus dri dts dvd dvdr emboss encode exif fam firefox flac fortran gdbm gif glitz gpm gtk gtk2 hal iconv imap ipv6 java jpeg junit kde kde4 lcms ldap libnotify mad maildir mikmod mmx mng modules mozdevelop mozilla mozsvg mp3 mp4 mpeg mudflap ncurses nls nptl nptlonly ogg oggvorbis opengl openmp oss pam pango pcre pdf perl png ppds pppd python qt qt3support qt4 quicktime readline reflection sdl session spell spl sse ssl startup-notification svg sysfs tcpd theora tiff truetype unicode usb vorbis win32codecs x264 x86 xcb xinerama xml xmms xorg xulrunner xv xvid zlib" ALSA_CARDS="emu10k1" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="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" ELIBC="glibc" INPUT_DEVICES="evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="nvidia nv vesa" 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:  CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, LANG, LC_ALL, LINGUAS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 2 Rafał Mużyło 2010-07-30 18:37:55 UTC
I'd say it's a mix of two bugs: one of clang and one of your code.

Does it work if 'int main()' does i.e. 'return 0;' ?
Comment 3 David Ripton 2010-07-30 18:48:10 UTC
You're right, that was a lazy hello world.  (Though if failing to return an int or declare argc and argv were an error, you would expect an error message not a sig 11.)  Here's a more canonical hello world:

#include <stdio.h>

int main(int argc, char **argv)
{
    printf("Hello world!\n");
    return 0;
}

Still fails:

$ clang hello.c
0  clang 0x08e49208
Stack dump:
0.      Program arguments: /usr/bin/clang -cc1 -triple i386-pc-linux-gnu -S -disable-free -disable-llvm-verifier -main-file-name hello.c -mrelocation-model static -mdisable-fp-elim -mconstructor-aliases -target-cpu pentium4 -resource-dir /usr/lib/clang/1.1 -fmessage-length 103 -fgnu-runtime -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/cc-SWYueN.s -x c hello.c
1.      <eof> parser at end of file
clang: error: compiler command failed due to signal 11 (use -v to see invocation)
dripton@al ~ $ clang -v hello.c
clang version 1.1 (branches/release_27)
Target: i386-pc-linux-gnu
Thread model: posix
 "/usr/bin/clang" -cc1 -triple i386-pc-linux-gnu -S -disable-free -disable-llvm-verifier -main-file-name hello.c -mrelocation-model static -mdisable-fp-elim -mconstructor-aliases -target-cpu pentium4 -v -resource-dir /usr/lib/clang/1.1 -fmessage-length 103 -fgnu-runtime -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/cc-qhA34V.s -x c hello.c
clang -cc1 version 1.1 based upon llvm 2.7 hosted on i386-pc-linux-gnu
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/clang/1.1/include
 /usr/local/include
 /usr/include
End of search list.
0  clang 0x08e49208
Stack dump:
0.      Program arguments: /usr/bin/clang -cc1 -triple i386-pc-linux-gnu -S -disable-free -disable-llvm-verifier -main-file-name hello.c -mrelocation-model static -mdisable-fp-elim -mconstructor-aliases -target-cpu pentium4 -v -resource-dir /usr/lib/clang/1.1 -fmessage-length 103 -fgnu-runtime -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/cc-qhA34V.s -x c hello.c
1.      <eof> parser at end of file
clang: error: compiler command failed due to signal 11 (use -v to see invocation)

Also, the CFLAGS in my emerge --info was not what I actually used to build clang.  My real CFLAGS is -march=amdfam10 -O3 -pipe -fomit-frame-pointer
Comment 4 David Ripton 2010-08-08 14:59:12 UTC
I upgraded to gcc 4.4.4-r1 and re-emerged llvm and clang.  Didn't help.

Then I switched from -O3 to -O2 in /etc/make.conf, and re-emerged llvm and clang.  Now clang works.

So I'm going to try to close this as INVALID since different optimization settings fixed it.