When I try to compile current QEMU (current cvs) with sys-devel/gcc-3.4.0-r2 on amd64, gcc segfaults while compiling target-i386/op.c in i386-user. I'm submitting the preprocessed source as requested by the message. You can trigger the bug easily by running gcc -c op.c -O. Reproducible: Always Steps to Reproduce: 1. ./configure --target-list=i386-user 2. make Actual Results: First an error telling me about the segfault than a message requesting me to submit a bug here. Expected Results: Successful compilation without a segfault. gebner@schnecke2 i386-user $ emerge info Portage 2.0.50-r6 (default-amd64-2004.0, gcc-3.4.0, glibc-2.3.3_pre20040420-r0, 2.6.6-mm2) ================================================================= System uname: 2.6.6-mm2 x86_64 4 Gentoo Base System version 1.4.12 Autoconf: sys-devel/autoconf-2.59-r3 Automake: sys-devel/automake-1.8.3 ACCEPT_KEYWORDS="amd64 ~amd64" AUTOCLEAN="yes" CFLAGS="-O3 -pipe" CHOST="x86_64-pc-linux-gnu" COMPILER="gcc3" CONFIG_PROTECT="/etc /usr/X11R6/lib/X11/xkb /usr/kde/2/share/config /usr/kde/3.2/share/config /usr/kde/3/share/config /usr/lib/mozilla/defaults/pref /usr/share/config /usr/share/texmf/dvipdfm/config/ /usr/share/texmf/dvips/config/ /usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/config/ /usr/share/texmf/xdvi/ /var/qmail/control" CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d" CXXFLAGS="-O3 -pipe" DISTDIR="/usr/portage/distfiles" FEATURES="autoaddcvs ccache sandbox" GENTOO_MIRRORS="http://gentoo.inode.at/ http://linux.rz.ruhr-uni-bochum.de/download/gentoo-mirror/" MAKEOPTS="-j2" PKGDIR="/usr/portage/packages" PORTAGE_TMPDIR="/var/tmp" PORTDIR="/usr/portage" PORTDIR_OVERLAY="/usr/local/portage" SYNC="rsync://rsync.de.gentoo.org/gentoo-portage" USE="X X509 Xaw3d aac aalib accounting acl acpi ada alsa amd64 apache2 ardour-ksi async athena audiofile avantgo avi berkdb bidi bluetooth bonobo cap caps cddb cdf cdr cgi cjk clisp cmucl crypt cscope cups dga dillo dnd dnsdb doc dv dvd dvdr encode escreen ethereal evo expat f77 faad fam fastcgi fax fbcon fbdev ffmpeg fftw flac foomaticdb fs gcl gd gdbm geoip gif gimpprint ginac glade glgd gmp gmtfull gmthigh gmtsuppl gmttria gnomedb gpm gps gsl gstreamer gtk gtk2 gtkhtml guile hbci hdf hdf5 idea idl ieee1394 imagemagick imlib ipcs ipv6 irda irmc jack jpeg kde kerberos ladcca lcd lcms leim lesstif libdsk libg libgda libsamplerate libwww linguas_de lirc lua mad maildir matroska mbox mcal md5sum mikmod mng monkey mono motif mozilla moznocompose moznoirc moznomail mpeg mpeg4 mule nas ncurses nls nptl nviz objc ocaml ofx oggvorbis openal opengl opie oskit-profiling pam pcmcia pcre pda pdflib perl php pic plotutils png pnp ppds pthreads python qhull qt quicktime radeon readline ruby samba scanner sdk sdl serial slang slp snmp sox speedo speex spell sqlite ssl stroke svg t1lib tcltk tetex theora threads tiff transcode transparent-proxy truetype type1 uml unicode usb v4l v4l2 wifi wmf wxwin wxwindows xml xml2 xosd xv xvid yaz zlib zvbi"
Created attachment 31535 [details] op.c, which causes trouble when compiled with -O?. I tried every option where the gcc man page says that it's enabled with -O2. No luck. Just -O? gave me a segfault, even just -O.
What about -O0 and -Os? I've had problems before with other packages which are solved by compiling with one of the above - I think there's a bug in a macro enabled by a -O option, not an optimization flag.
Robert, you're right. That doesn't happen when compiling -O0. It (gcc segfaulting) happens only with -Os, -O, -O1, -O2, -O3, -O4, ... However if I supply all the options gcc(1) states that are enables with -O3, then there's no segfault: gcc -c op.c -fdefer-pop -fmerge-constants -fthread-jumps -floop-optimize -fif-conversion -fif-conversion2 -fdelayed-branch -fguess-branch-probability -fcprop-registers -fomit-frame-pointer -fforce-mem -foptimize-sibling-calls -fstrength-reduce -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop -frerun-loop-opt -fgcse -fgcse-lm -fgcse-sm -fgcse-las -fdelete-null-pointer-checks -fexpensive-optimizations -fregmove -fschedule-insns -fschedule-insns2 -fsched-interblock -fsched-spec -fcaller-saves -fpeephole2 -freorder-blocks -freorder-functions -fstrict-aliasing -funit-at-a-time -falign-functions -falign-jumps -falign-loops -falign-labels -fcrossjumping -finline-functions -fweb -frename-registers
Created attachment 31755 [details] helper.c, another file which causes trouble when compiled with -O? helper.c shows exactly the same problem as op.c. gcc doesn't segfault when compiled with no optimizations, but it segfaults with -Os, -O1, -O2, -O3, though it doesn't segfault when expanding the shortcuts manually with the optimizations given in gcc(1).
I've upgraded to gcc-3.4.0-r4 and it still segfaults.
gcc-3.4.0-r6 is the same: schnecke2 root # gcc -O1 -c helper.c In file included from /home/gebner/tmp/qemu/target-i386/helper.c:20: /home/gebner/tmp/qemu/target-i386/exec.h:312: warning: conflicting types for built-in function 'lrintl' /home/gebner/tmp/qemu/target-i386/helper.c: In function `get_seg_base': /home/gebner/tmp/qemu/target-i386/helper.c:171: warning: cast to pointer from integer of different size /home/gebner/tmp/qemu/target-i386/helper.c: In function `load_seg_vm': /home/gebner/tmp/qemu/target-i386/helper.c:186: warning: cast to pointer from integer of different size /home/gebner/tmp/qemu/target-i386/helper.c: In function `do_interrupt_real': /home/gebner/tmp/qemu/target-i386/helper.c:820: warning: cast to pointer from integer of different size /home/gebner/tmp/qemu/target-i386/helper.c:822: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://bugs.gentoo.org/> for instructions. Preprocessed source stored into /tmp/ccNurZXB.out file, please attach this to your bugreport. schnecke2 root # gcc -O1 -c op.c In file included from /home/gebner/tmp/qemu/target-i386/op.c:28: /home/gebner/tmp/qemu/target-i386/exec.h:312: warning: conflicting types for built-in function 'lrintl' /home/gebner/tmp/qemu/target-i386/op.c: In function `op_divw_AX_T0': /home/gebner/tmp/qemu/target-i386/op.c:307: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://bugs.gentoo.org/> for instructions. Preprocessed source stored into /tmp/cc47sTMp.out file, please attach this to your bugreport.
this still happens with 3.4.1... have you reported this problem upstream to the gcc devs themselves?
[Sorry for the delay; I was a few hundred kilometers away from my gentoo box on holiday with a debian x86 laptop.] Your wish is my order: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16702
Reported upstream. See URL above.