When I try to emerge dev-lang/ocaml-3.08.2 on ~amd64, the build segfaults when making stdlib/pervasives.cmi. Reproducible: Always Steps to Reproduce: 1. emerge =dev-lang/ocaml-3.08.2 Actual Results: gcc -O -DNDEBUG -fno-defer-pop -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT -O2 -pipe -fno-stack-protector -c -o skeleton.o skeleton.c gcc -O -DNDEBUG -fno-defer-pop -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT -O2 -pipe -fno-stack-protector -c -o symtab.o symtab.c gcc -O -DNDEBUG -fno-defer-pop -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT -O2 -pipe -fno-stack-protector -c -o verbose.o verbose.c gcc -O -DNDEBUG -fno-defer-pop -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT -O2 -pipe -fno-stack-protector -c -o warshall.o warshall.c gcc -O -DNDEBUG -fno-defer-pop -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT -O2 -pipe -fno-stack-protector -o ocamlyacc closure.o error.o lalr.o lr0.o main.o mkpar.o output.o reader.o skeleton.o symtab.o verbose.o warshall.o main.o(.text+0x64e): In function `create_file_names': : warning: the use of `mktemp' is dangerous, better use `mkstemp' make[1]: Leaving directory `/var/tmp/portage/ocaml-3.08.2/work/ocaml-3.08.2/yacc' cp yacc/ocamlyacc boot/ocamlyacc cd stdlib; make COMPILER=../boot/ocamlc all make[1]: Entering directory `/var/tmp/portage/ocaml-3.08.2/work/ocaml-3.08.2/stdlib' ../boot/ocamlrun ../boot/ocamlc -g -warn-error A -nostdlib `./Compflags pervasives.cmi` -c pervasives.mli make[1]: *** [pervasives.cmi] Segmentation fault make[1]: Leaving directory `/var/tmp/portage/ocaml-3.08.2/work/ocaml-3.08.2/stdlib' make: *** [coldstart] Error 2 !!! ERROR: dev-lang/ocaml-3.08.2 failed. !!! Function src_compile, Line 51, Exitcode 2 !!! (no error message) !!! If you need support, post the topmost build error, NOT this status message. Portage 2.0.51-r8 (gcc34-amd64-2004.1, gcc-hardenednossp, glibc-2.3.4.20041102-r0, 2.6.10-rc2-mm2 x86_64) ================================================================= System uname: 2.6.10-rc2-mm2 x86_64 AMD Athlon(tm) 64 Processor 3000+ Gentoo Base System version 1.6.6 Python: dev-lang/python-2.3.4 [2.3.4 (#1, Oct 14 2004, 17:10:16)] dev-lang/python: 2.3.4 sys-devel/autoconf: 2.59-r6, 2.13 sys-devel/automake: 1.8.5-r2, 1.5, 1.4_p6, 1.6.3, 1.7.9, 1.9.3 sys-devel/binutils: 2.15.92.0.2-r1 sys-devel/libtool: 1.5.10 virtual/os-headers: 2.6.8.1-r1 ACCEPT_KEYWORDS="amd64 ~amd64" AUTOCLEAN="yes" CFLAGS="-O3 -pipe" CHOST="x86_64-pc-linux-gnu" CONFIG_PROTECT="/etc /usr/X11R6/lib/X11/xkb /usr/kde/2/share/config /usr/kde/3/share/config /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 distlocks" GENTOO_MIRRORS="http://ftp.uni-erlangen.de/pub/mirrors/gentoo http://ftp.lug.ro/gentoo/ http://mirror.uni-c.dk/gentoo/ http://ftp.du.se/pub/os/gentoo" 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="amd64 X aac aalib accessibility acl acpi aim alsa apache2 ared aredmem async atlas auctex audiofile avi ba-completion bcmath bdf beep berkdb bidi bitmap-fonts blas bluetooth bonobo bzlib cairo camaelon cap caps cddb cdf cdparanoia cdr cdrom cgi chroot cjk client clisp cln cmucl crypt cscope cups curl dba dbase dbm dbx dga dillo dio divx4linux djbfft dlopen dnsdb doc droproot dts dv dvd dvdr dvdread edl eds emacs emacs-w3 encode erandom escreen estraier etwin exif f77 faac faad fam fastcgi fbcon festival ffmpeg fftw fla flac flatfile flexresp flood fluidsynth fmod fortran fpx freetts freetype frlargefiles ftp fusion gb gcj gcl gd gdbm geoip gif gimp gimpprint ginac gkrellm glade glep glgd gmp gmtfull gmthigh gmtsuppl gmttria gnomedb gnuplot gps graphviz gs gsl gstreamer gtk gtk2 guile hal iconv icq ieee1394 imap imlib imlib2 inifile intl ipv6 ithreads jbig jikes jp2 jpeg jpeg2k junit ladcca lapack latex lcms libsamplerate live lzo mad mailbox maildir maildrop mailwrapper makecheck maps matroska mbox mbrola mcal md5sum mdb mha mime ming mng motif mozdevelop moznocompose moznoirc moznomail mozsvg mozxmlterm mpeg mpeg4 mplayer msession msn multilib ncurses network nls nntp no-old-linux nptl nptlonly ntlm objc ocaml oggvorbis opengl oscar pam pcap pcmcia pcntl pcre pda pdf pdflib perl php pic pie plotutils png ppds pthreads python qt readline recode rtc ruby samba sbcl scanner sdl serial session slang slp smime snmp soap sockets speex spell spl ssl svg sysvipc szip t1lib tcltk tcpmd5 tcsim tetex tga theora threads thumbnail tidy tiff tokenizer tpctlir transcode translator truetype unicode usb userlocales v4l v4l2 vim vnc wifi wxwin wxwindows xface xml2 xosd xpm xprint xrandr xsl xv xvid xvmc yahoo yaz yv12 zlib zvbi"
According to the ewarn in the ebuild I tried emerging with CFLAGS="-O0 -fPIC", CFLAGS="-fPIC" and CFLAGS="-O0", and it always failed with the same log.
I was having the same problem. It seems to stem from an incorrectly set GCC_SPECS variable. My GCC_SPECS in /etc/env.d/05gcc was pointing to a hardened gcc (which doesn't compile the bytecode interpreter correctly) even though I'd selected an "unhardened" gcc profile with gcc-config. Upgrading to sys-devel/gcc-config-1.3.7-r5 fixed it for me.
Does bardur's fix work for you guys ?
I had the same problem with a hardened gcc causing a segfault in dev-lang/ocaml-3.08. Ocaml compiles nicely after changing to a vanilla gcc with gcc-config.
I've noticed that the compiler generally doesn't work when hardened-gcc is enabled. I've tried to compile the application "monotone-viz", for example, but only managed after switching to a vanilla-gcc profile. Passing "-nopie -fno-stack-protector-all -fno-stack-protector" through "-ccopts" doesn't seem to make any difference. This situation is somewhat unfortunate. Is there a solution for this problem visible on the horizon?
I don't think there is. Ocaml uses hand-tuned assembler (to implement the garbage collector efficiently for example) which does not play nicely with things such as PIE and SPP.