gentoo ~ # emerge grub Calculating dependencies ...done! >>> emerge (1 of 1) sys-boot/grub-0.95.20040823 to / >>> md5 files ;-) grub-0.95.20040823.ebuild >>> md5 files ;-) grub-0.93.20030118.ebuild >>> md5 files ;-) grub-0.92-r1.ebuild >>> md5 files ;-) grub-0.94-r1.ebuild >>> md5 files ;-) grub-0.94-r2.ebuild >>> md5 files ;-) ChangeLog >>> md5 files ;-) metadata.xml >>> md5 files ;-) files/grub-0.94-grub.conf.patch >>> md5 files ;-) files/digest-grub-0.95.20040823 >>> md5 files ;-) files/digest-grub-0.93.20030118 >>> md5 files ;-) files/digest-grub-0.92-r1 >>> md5 files ;-) files/grub-0.94-gcc3.4.patch >>> md5 files ;-) files/grub-0.93-gcc3.3.diff >>> md5 files ;-) files/splash.xpm.gz >>> md5 files ;-) files/digest-grub-0.94-r1 >>> md5 files ;-) files/digest-grub-0.94-r2 >>> md5 src_uri ;-) grub-0.95.20040823.tar.gz >>> md5 src_uri ;-) grub-0.95.20040823-splash.patch.bz2 >>> Unpacking source... >>> Unpacking grub-0.95.20040823.tar.gz to /var/tmp/portage/grub-0.95.20040823/work >>> Unpacking grub-0.95.20040823-splash.patch.bz2 to /var/tmp/portage/grub-0.95.20040823/work * Using GNU config files from /usr/share/libtool * Updating config.sub [ ok ] * Updating config.guess [ ok ] * Applying grub-0.95.20040823-splash.patch ... [ ok ] >>> Source unpacked. /usr/share/aclocal/pkg.m4:5: warning: underquoted definition of PKG_CHECK_MODULES run info '(automake)Extending aclocal' or see http://sources.redhat.com/automake/automake.html#Extending%20aclocal /usr/share/aclocal/libmcrypt.m4:17: warning: underquoted definition of AM_PATH_LIBMCRYPT /usr/share/aclocal/libIDL.m4:6: warning: underquoted definition of AM_PATH_LIBIDL /usr/share/aclocal/gtk.m4:7: warning: underquoted definition of AM_PATH_GTK /usr/share/aclocal/glib.m4:8: warning: underquoted definition of AM_PATH_GLIB /usr/share/aclocal/freetype2.m4:7: warning: underquoted definition of AC_CHECK_FT2 /usr/share/aclocal/ORBit.m4:4: warning: underquoted definition of AM_PATH_ORBIT ./configure --prefix=/usr --host=i686-pc-linux-gnu --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib --datadir=/usr/lib/grub --exec-prefix=/ --disable-auto-linux-mem-opt --enable-diskless --enable-3c503 --enable-3c507 --enable-3c509 --enable-3c529 --enable-3c595 --enable-3c90x --enable-cs89x0 --enable-davicom --enable-depca --enable-eepro --enable-eepro100 --enable-epic100 --enable-exos205 --enable-ni5210 --enable-lance --enable-ne2100 --enable-ni5010 --enable-ni6510 --enable-natsemi --enable-ne --enable-ns8390 --enable-wd --enable-otulip --enable-rtl8139 --enable-sis900 --enable-sk-g16 --enable-smc9000 --enable-tiara --enable-tulip --enable-via-rhine --enable-w89c840 configure: WARNING: If you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used. checking for a BSD-compatible install... /bin/install -c checking whether build environment is sane... yes checking for gawk... gawk checking whether make sets $(MAKE)... yes checking for i686-pc-linux-gnu-strip... no checking for strip... strip checking build system type... i686-pc-linux-gnu checking host system type... i686-pc-linux-gnu checking whether to enable maintainer-specific portions of Makefiles... no checking for i686-pc-linux-gnu-gcc... i686-pc-linux-gnu-gcc checking for i686-pc-linux-gnu-gcc... (cached) i686-pc-linux-gnu-gcc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether i686-pc-linux-gnu-gcc accepts -g... yes checking for i686-pc-linux-gnu-gcc option to accept ANSI C... none needed checking for style of include used by make... GNU checking dependency style of i686-pc-linux-gnu-gcc... gcc3 checking dependency style of i686-pc-linux-gnu-gcc... (cached) gcc3 checking for i686-pc-linux-gnu-ranlib... no checking for ranlib... ranlib checking whether optimization for size works... yes checking whether gcc has -fno-stack-protector... yes checking whether -Wundef works... yes checking whether -falign-loops works... yes checking for i686-pc-linux-gnu-objcopy... no checking for objcopy... objcopy checking if C symbols get an underscore after compilation... no checking whether objcopy works for absolute addresses... configure: error: i686-pc-linux-gnu-gcc cannot link at address 2000 !!! ERROR: sys-boot/grub-0.95.20040823 failed. !!! Function econf, Line 449, Exitcode 1 !!! econf failed !!! If you need support, post the topmost build error, NOT this status message. Reproducible: Always Steps to Reproduce: 1. emerge grub 2. 3. gentoo ~ # emerge info Portage 2.0.51-r2 (selinux/2004.1/x86, gcc-3.3.4, glibc-2.3.4.20041021-r0, 2.6.7-hardened-r9 i686) ================================================================= System uname: 2.6.7-hardened-r9 i686 AMD Athlon(TM) XP 2000+ Gentoo Base System version 1.6.4 ccache version 2.3 [enabled] Autoconf: sys-devel/autoconf-2.59-r5 Automake: sys-devel/automake-1.8.5-r1 Binutils: sys-devel/binutils-2.15.92.0.2-r1 Headers: sys-kernel/linux26-headers-2.6.8.1-r1 Libtools: sys-devel/libtool-1.5.2-r5 ACCEPT_KEYWORDS="x86 ~x86" AUTOCLEAN="yes" CFLAGS="-O2 -mcpu=i686 -fomit-frame-pointer -fforce-addr" CHOST="i686-pc-linux-gnu" COMPILER="" CONFIG_PROTECT="/etc /usr/X11R6/lib/X11/xkb /usr/kde/2/share/config /usr/kde/3/share/config /usr/share/config /var/qmail/control" CONFIG_PROTECT_MASK="/etc/gconf /etc/init.d /etc/security /etc/skel /etc/terminfo /etc/wget /etc/env.d" CXXFLAGS="-O2 -mcpu=i686 -fomit-frame-pointer -fforce-addr" DISTDIR="/usr/portage/distfiles" FEATURES="autoaddcvs ccache distlocks loadpolicy sandbox sfperms strict" MAKEOPTS="-j2" PKGDIR="/usr/portage/packages" PORTAGE_TMPDIR="/var/tmp" PORTDIR="/usr/portage" PORTDIR_OVERLAY="" SYNC="rsync://ftp.lzusiyu.org/gentoo-portage" USE="X berkdb crypt f77 gpm gtk hardened mysql ncurses nls opengl pam perl pic pie png python readline selinux ssl tcltk tcpd x86 xml2 zlib"
Can either the reporter or someone from the hardened team - or, preferably, both - please either confirm or deny that this may or may not be related to the fact that I haven't yet patched the grub ebuild to use $(tc-getCC) from toolchain-funcs.eclass?
I'm seeing the problem as well with 07:38:17 askwar@alturo:~ $ epm -qf /usr/lib/gcc/i686-pc-linux-gnu/3.4.3/../../../libc.a glibc-2.3.4.20041102 07:45:51 askwar@alturo:~ $ epm -qf /usr/i686-pc-linux-gnu/gcc-bin/3.4/gcc gcc-3.4.3 I'm also using a hardened toolchain. Can you provide a patch or clear instructions what to change?
No, not yet - I need a comment from someone on hardened before I can go anywhere at all with this. Right now I have no idea, as this isn't a grub problem, it's a hardened problem. Obviously grub is doing something wrong, but it's really a hardened bug.
this is an old bug which has returned for whatever reason. Way I recall it was simple. gurb must be ET_EXEC. That means that -nopie/fno-pi(c|e) should be auto passed. solution: filter-flags -fPIC If not filtered you will end up with a 2G stageX file from grub. ;/
Erm... does that fix things even if he doesn't have -fPIC in his CFLAGS/CXXFLAGS?
Yes it should. It's not the 'right' solution as it will prevent the grub (binary) itself from being compiled as a Position Independent Executable. The use flag hardened enables fPIC via the gcc specs file. Btw I'd class this is grub bug really. but one that only shows up when using hardened toolchain's or 4 or so other cases. I'll ask around and see if anybody has patches for grub itself. (desired over filtering hacks)
I can't get this to happen on x86 with grub-0.95.20040823
Hardened setup here, same thing - this one and DirectFB a failure to build have been here for some months *wink* :-)
I'm getting the same here on a hardened x86 box with grub-0.94-r1. I know it's a different version but I thought it better to post here than file a new bug. Adding filter-flags -fPIC to the ebuild does not fix the problem.
*** Bug 79119 has been marked as a duplicate of this bug. ***
probably the eclass that is supposed to take care of the "filter-flags" and inserts the appropriate statements for the hardened compiler to suppress PIE autobuilding is out of order.
notice the emake only exports CFLAGS= and not CC= Could be the cause for you guys that are having this problem.
FYI we have the same problem also with mysql in a hardened uclibc env. Same problem and same "solution" (filter-flags -fPIC)
It happens with me when trying to emerge either grub-0.94-r1 or grub-0.95.20040823 with hardened gcc (on amd64). When I use 'gcc-config 7' to change to the vanilla gcc, both compile without problem. Both segfault when trying to install into a RAID1 reiserfs partition though.
I've been posting filter hacks to #79734 for these, not realising two bugs for the same issue existed. re. 0.94-r1/2 - the netboot stuff just doesn't build (it's conditional on "use netboot" with 0.95). Should be conditional on 'use netboot' there as well, imo.
The ebuild tries to set the -fno-pic and -fnopie flags not by CFLAGS variable but by CC: ~$ sed -n 53,54p /usr/portage/sys-boot/grub/grub-0.94-r1.ebuild has_pie && CC="${CC} `test_flag -fno-pic` `test_flag -nopie`" has_ssp && CC="${CC} `test_flag -fno-stack-protector`" But at this point CC is not set at all (cp. http://bugs.gentoo.org/show_bug.cgi?id=69726#c12). Thus you can set the CC environment to gcc and grub will compile. In my case CC=i686-pc-linux-gnu-gcc emerge grub helped.
Created attachment 51951 [details, diff] patch to grub-0.94-r1.ebuild The problems with using ${CC} are also addressed in bug 70111. I managed to get grub to build on hardened using these changes, although only without netboot. Using netboot and the CFLAGS I get many unresolved references for __outw, __inw, __outb, __inb and the like. No idea where those come from.
Added to grub 0.96.