Summary: | ghc won't work with gcc 3.3.1 | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | Peter Simons <simons> |
Component: | New packages | Assignee: | Alexander Gabert (RETIRED) <pappy> |
Status: | RESOLVED TEST-REQUEST | ||
Severity: | normal | CC: | kosmikus |
Priority: | High | ||
Version: | unspecified | ||
Hardware: | All | ||
OS: | Linux | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- |
Description
Peter Simons
2003-10-09 14:58:52 UTC
Peter, could you please include the output of a "emerge info" and "ld -v" okay, confirmed here: ==fptools== make boot -wr; in /var/tmp/portage/ghc-5.04.3-r1/work/stage1-build/ghc/includes ------------------------------------------------------------------------ Creating config.h... Done. gcc -O -c mkDerivedConstants.c -o mkDerivedConstants.o gcc -o mkDerivedConstantsHdr -O mkDerivedConstants.o ./mkDerivedConstantsHdr >DerivedConstants.h gcc -O -c mkNativeHdr.c -o mkNativeHdr.o gcc -o mkNativeHdr -O mkNativeHdr.o ./mkNativeHdr >NativeDefs.h ../../glafp-utils/mkdependC/mkdependC -f .depend -- -O -- mkDerivedConstants.c mkNativeHdr.c ------------------------------------------------------------------------ ==fptools== make boot -wr; in /var/tmp/portage/ghc-5.04.3-r1/work/stage1-build/ghc/utils ------------------------------------------------------------------------ ------------------------------------------------------------------------ ===fptools== Recursively making `boot' in hasktags ghc-pkg hp2ps hsc2hs parallel stat2resid prof unlit genprimopcode ... PWD = /var/tmp/portage/ghc-5.04.3-r1/work/stage1-build/ghc/utils ------------------------------------------------------------------------ ------------------------------------------------------------------------ ==fptools== make boot - --no-print-directory -r; in /var/tmp/portage/ghc-5.04.3-r1/work/stage1-build/ghc/utils/hasktags ------------------------------------------------------------------------ /opt/ghc/bin/ghc -M -optdep-f -optdep.depend -osuf o -ldl -O HaskTags.hs ------------------------------------------------------------------------ ==fptools== make boot - --no-print-directory -r; in /var/tmp/portage/ghc-5.04.3-r1/work/stage1-build/ghc/utils/ghc-pkg ------------------------------------------------------------------------ /opt/ghc/bin/ghc -M -optdep-f -optdep.depend -osuf o -ldl -cpp -DPKG_TOOL -DWANT_PRETTY -package lang -package util -package text -O Main.hs Package.hs ParsePkgConfLite.hs make all /opt/ghc/bin/ghc -ldl -cpp -DPKG_TOOL -DWANT_PRETTY -package lang -package util -package text -O -c Package.hs -o Package.o Prologue junk?: .globl __stginit_Package __stginit_Package: call .L3 .L3: popl %ebx addl $_GLOBAL_OFFSET_TABLE_+[.-.L3], %ebx make[4]: *** [Package.o] Error 1 make[3]: *** [boot] Error 2 make[2]: *** [boot] Error 1 make[1]: *** [boot] Error 1 make[1]: Leaving directory `/var/tmp/portage/ghc-5.04.3-r1/work/stage1-build/ghc' make: *** [all] Error 1 !!! ERROR: dev-lang/ghc-5.04.3-r1 failed. !!! Function src_compile, Line 141, Exitcode 2 !!! intermediate stage make failed 23:24:28 [/usr/local/chroots/chroot001:943.pty-s4.epoch] epoch ~ # i will put CC=CC -yet_exec into it for testing and report back thanks, Alex 00:38:36 <@pappy-> if has_version "sys-devel/hardened-gcc" 00:38:36 <@pappy-> then 00:38:36 <@pappy-> PATH="${GHCPATH}" ./configure \ 00:38:36 <@pappy-> -host="${CHOST}" \ 00:38:36 <@pappy-> --prefix="${STAGE1_D}/usr" \ 00:38:36 <@pappy-> --with-ghc="${GHC}" \ 00:38:36 <@pappy-> --with-gcc="gcc -yet_exec -yno_propolice" \ fixed in cvs, please update cvs or wait 8 hours for reemerging ghc the long story: ghc uses gcc which automatically introduces PICness into the output assembler, which messes up the ghc-asm which mourns about it: you can see it if you enter the directory after bombing it and adding -v to the ghc command line that failed this brings you in the mood with ghc-asm spitting out the error ghc-6.0 -H16m -O -cpp -fglasgow-exts -package lang -O -c AbsSyn.lhs -o -v changes to /usr/portage/dev-lang/ghc/ghc-5.04.3-r1.ebuild this will automatically introduce proper nonPICness with the eclass adding -yet_exec and also adding the current system wide CFLAGS if has_version "sys-devel/hardened-gcc" then filter-flags "-fPIC" pushd "${STAGE1_B}" || die PATH="${GHCPATH}" ./configure \ -host="${CHOST}" \ --prefix="${STAGE1_D}/usr" \ --with-ghc="${GHC}" \ --with-gcc="gcc ${CFLAGS}" \ --without-happy || die "intermediate stage configure failed" else pushd "${STAGE1_B}" || die PATH="${GHCPATH}" ./configure \ -host="${CHOST}" \ --prefix="${STAGE1_D}/usr" \ --with-ghc="${GHC}" \ --without-happy || die "intermediate stage configure failed" fi can you confirm if this is a bug related to hardened-gcc? it died after some 1-2 hours compiling: ... unrecognized option `-p' unrecognized option `-y' unrecognized option `-e' unrecognized option `-O' unrecognized option `-3' unrecognized option `-m' unrecognized option `-f' unrecognized option `-u' unrecognized option `-n' unrecognized option `-r' unrecognized option `-p' unrecognized option `-y' unrecognized option `-e' Usage: hsc2hs-bin [OPTIONS] INPUT.hsc [...] -t FILE --template=FILE template file -c PROG --cc=PROG C compiler to use -l PROG --ld=PROG linker to use -C FLAG --cflag=FLAG flag to pass to the C compiler -I DIR passed to the C compiler -L FLAG --lflag=FLAG flag to pass to the linker -i FILE --include=FILE as if placed in the source -D NAME[=VALUE] --define=NAME[=VALUE] as if placed in the source -o FILE --output=FILE name of main output file --help display this help and exit -v --verbose dump commands to stderr --version output version information and exit --no-compile stop after writing *_hsc_make.c make[2]: *** [System/CPUTime.hs] Error 1 make[1]: *** [boot] Error 1 make[1]: Leaving directory `/var/tmp/portage/ghc-5.04.3-r1/work/stage1-build/libraries' make: *** [all] Error 1 !!! ERROR: dev-lang/ghc-5.04.3-r1 failed. !!! Function src_compile, Line 154, Exitcode 2 !!! intermediate stage make failed Reopen bug Here is the "emerge info" output: Portage 2.0.49-r10 (selinux-x86-1.4, gcc-3.3.1, glibc-2.3.2-r1, 2.4.21-hardened) ================================================================= System uname: 2.4.21-hardened i686 AMD Athlon(tm) Processor Gentoo Base System version 1.4.3.10p1 ACCEPT_KEYWORDS="x86 ~x86" AUTOCLEAN="yes" CFLAGS="-mcpu=athlon -O3 -pipe" CHOST="i686-pc-linux-gnu" COMPILER="gcc3" CONFIG_PROTECT="/etc /var/qmail/control /usr/share/config /usr/kde/2/share/config /usr/kde/3/share/config /var/bind /usr/X11R6/lib/X11/xkb" CONFIG_PROTECT_MASK="/etc/gconf /etc/env.d" CXXFLAGS="-mcpu=athlon -O3 -pipe" DISTDIR="/usr/portage/distfiles" FEATURES="ccache autoaddcvs sandbox userpriv notitles" GENTOO_MIRRORS="http://gentoo.oregonstate.edu http://distro.ibiblio.org/pub/Linux/distributions/gentoo" MAKEOPTS="-j1" PKGDIR="/usr/portage/packages" PORTAGE_TMPDIR="/var/tmp" PORTDIR="/usr/portage" PORTDIR_OVERLAY="" SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage" USE="x86 crypt ncurses selinux zlib gdbm berkdb readline pam ssl perl opengl mozilla altcolors curl dga doc dvd emacs ethereal leim mbox moznocompose moznoirc moznomail moznoxft rage128 Xaw3d -arts -cups -gpm -java -kde -motif -nls -qt -svga -xmms -tcpd -python -esd -spell -slang X png gtk gif tiff mmx xml xml2 truetype oss tetex jpeg avi oggvobis" And here comes "ld -v": GNU ld version 2.14.90.0.6 20030820 By the way, the ghc-bin-6.0 package won't work with PaX. I had to add the file "/opt/ghc/lib/ghc-6.0/ghc-6.0" to _all_ sections in /etc/conf/chpax before it worked. Maybe this should be incorporated into the ebuild in some way? Also, of course the ghc-bin packages have the same problems with hardened-gcc. Is there any way to fix that? Or does this mean that ghc-bin package simply shouldn't be used except for bootstrapping? Alright, the binary packages _can_ be used with hardened-gcc. All it takes is to add the following flag: -pgmc 'gcc -yet_exec -yno_propolice' Since /opt/ghc/bin/ghc-6.0 is a shell script already, this would be trivial to add here. Oh, and by the way: It would be GREAT if Gentoo could introduce a HCFLAGS environment variable, which contains flags automatically passed to ghc. I guess, it's also just a matter of adding the variable to the commandline in ghc-6.0. I'd like to use this to specify system-wide library paths etc., but I did't want to edit the files installed by portage ... OK, I've tried to compile GHC with all hardened-features completely disabled and I still have the same problems. Thus, this is clearly not a problem with "hardened-gcc" but with gcc 3.3.1! I have asked on the GHC mailing list, whether there is any know cure for this problem. I'll post it here, once I find out something. It's strange: The boostrapping process works, but once stage1 is built, the build fails. It appears that the inplace-ghc doesn't do anything, not even produce an error. OK, good news. I was able to compile ghc-current with hardened-gcc successfully after I added the following lines into mk/build.mk: SRC_CC_OPTS+=-yet_exec -yno_propolice SRC_HC_OPTS+=-optc-yet_exec -optc-yno_propolice Curiously enough, these flags didn't help when I passed them to the build through the appropriate ./configure flags. Don't ask me why. :-) What's the status here? Can someone summarize all changes that still need to be done? At the moment, ghc-5.04.3-r1 is changed in CVS, but ghc-6* is unchanged. I guess the same changes work/are needed for ghc-6? pappy, could you either do it or contact me by mail/on IRC to discuss what needs to be done here? ==fptools== make boot - --no-print-directory -r; in /var/tmp/portage/ghc-5.04.3-r1/work/stage1-build/ghc/utils/ghc-pkg ------------------------------------------------------------------------ /opt/ghc/bin/ghc -M -optdep-f -optdep.depend -osuf o -ldl -cpp -DPKG_TOOL -DWANT_PRETTY -package lang -package util -package text -O Main.hs Package.hs ParsePkgConfLite.hs make all /opt/ghc/bin/ghc -ldl -cpp -DPKG_TOOL -DWANT_PRETTY -package lang -package util -package text -O -c Package.hs -o Package.o Prologue junk?: .globl __stginit_Package __stginit_Package: call .L3 .L3: popl %ebx addl $_GLOBAL_OFFSET_TABLE_+[.-.L3], %ebx make[4]: *** [Package.o] Error 1 make[3]: *** [boot] Error 2 make[2]: *** [boot] Error 1 make[1]: *** [boot] Error 1 make[1]: Leaving directory `/var/tmp/portage/ghc-5.04.3-r1/work/stage1-build/ghc' make: *** [all] Error 1 !!! ERROR: dev-lang/ghc-5.04.3-r1 failed. !!! Function src_compile, Line 160, Exitcode 2 !!! intermediate stage make failed 10:18:26 [KW:][BOOTSYS] [hcc-2.4.5-x86] camille ~ # ------------------------------------------------------------------------ ==fptools== make boot - --no-print-directory -r; in /var/tmp/portage/ghc-5.04.3-r1/work/stage1-build/ghc/utils/ghc-pkg ------------------------------------------------------------------------ /opt/ghc/bin/ghc -M -optdep-f -optdep.depend -osuf o -ldl -cpp -DPKG_TOOL -DWANT_PRETTY -package lang -package util -package text -O Main.hs Package.hs ParsePkgConfLite.hs make all /opt/ghc/bin/ghc -ldl -cpp -DPKG_TOOL -DWANT_PRETTY -package lang -package util -package text -O -c Package.hs -o Package.o Prologue junk?: .globl __stginit_Package __stginit_Package: call .L3 .L3: popl %ebx addl $_GLOBAL_OFFSET_TABLE_+[.-.L3], %ebx make[4]: *** [Package.o] Error 1 make[3]: *** [boot] Error 2 make[2]: *** [boot] Error 1 make[1]: *** [boot] Error 1 make[1]: Leaving directory `/var/tmp/portage/ghc-5.04.3-r1/work/stage1-build/ghc' make: *** [all] Error 1 !!! ERROR: dev-lang/ghc-5.04.3-r1 failed. !!! Function src_compile, Line 160, Exitcode 2 !!! intermediate stage make failed 09:37:03 [/usr/local/chroots/chroot001:5224.pty-s0.epoch] epoch ~ # failed at the exact same moment for both hardened-gcc-2.4.5 systems ;-( 09:34:33 <pappy-> Prologue junk?: .globl __stginit_Package 09:34:33 <pappy-> __stginit_Package: 09:34:33 <pappy-> call .L3 09:34:33 <pappy-> .L3: 09:34:33 <pappy-> popl %ebx 09:34:34 <pappy-> addl $_GLOBAL_OFFSET_TABLE_+[.-.L3], %ebx 09:35:09 <pappy-> this so called "prologue junk" is caused by ghc using the normal gcc but this normal gcc is tricked into automatically building PIC code which is what the ghc considers as junk. 09:36:23 <pappy-> this what we are seeing here is a typical PIC "pull yourself out of the mud pulling your own hair" trick: it calls the next function, so the address on the stack popped long into ebx is holding the current address where it is... this is the way PIC code inserts the address of the global offset table... 09:36:53 <pappy-> Peter Simons wrote: after I added the following lines into mk/build.mk: 09:36:53 <pappy-> SRC_CC_OPTS+=-yet_exec -yno_propolice 09:36:54 <pappy-> SRC_HC_OPTS+=-optc-yet_exec -optc-yno_propolice 09:37:12 <pappy-> this is what he did to make the problem go away, essentially making ghc call the gcc with the etdyn disable args I will edit the ebuilds and test it, Alex Please note that you'll also have to disable PaX in order to make GHCi work. On my system, I added the following to "/etc/conf.d/chpax": PAGEEXEC_EXEMPT="/opt/ghc/lib/ghc-6.0/ghc-6.0" TRAMPOLINE_EXEMPT="/opt/ghc/lib/ghc-6.0/ghc-6.0" MPROTECT_EXEMPT="/opt/ghc/lib/ghc-6.0/ghc-6.0" MMAP_EXEMPT="/opt/ghc/lib/ghc-6.0/ghc-6.0" SEGEXEC_EXEMPT="/opt/ghc/lib/ghc-6.0/ghc-6.0" RANDEXEC_EXEMPT="/opt/ghc/lib/ghc-6.0/ghc-6.0" I'm pretty sure, not all those features have to be disabled. But I was a bit unnerved at the time I added them. :-) http://dev.gentoo.org/~pappy/tmp/ghc2.txt from the stable ebuild: echo '>>> Creating stage 2 build dir' mkdir ${STAGE2_B} || die ${LNDIR} ${S} ${STAGE2_B} || die # disable the automatic PIC building which is considered as Prologue Junk by the Haskell Compiler if has_version "sys-devel/hardened-gcc" then # fix proposed by Peter simons according to bug #30789 echo "SRC_CC_OPTS+=-yet_exec -yno_propolice" >> ${STAGE1_B}/mk/build.mk echo "SRC_HC_OPTS+=-optc-yet_exec -optc-yno_propolice" >> ${STAGE1_B}/mk/build.mk echo "SRC_CC_OPTS+=-yet_exec -yno_propolice" >> ${STAGE2_B}/mk/build.mk echo "SRC_HC_OPTS+=-optc-yet_exec -optc-yno_propolice" >> ${STAGE2_B}/mk/build.mk fi use opengl && myconf="--enable-hopengl" || myconf="--disable-hopengl" emerging of 6.0.1 is underway and tested also with this fix thanks, Alex added the bugfix proposed by Peter simons to both ebuilds in cvs the stable one already works here with this workaround |