Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 408545 - sys-boot/grub-2.00_beta{1,2} don't build efi-64 on x86
Summary: sys-boot/grub-2.00_beta{1,2} don't build efi-64 on x86
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: x86 Linux
: Normal normal (vote)
Assignee: Mike Gilbert
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-17 03:09 UTC by Maxim Kammerer
Modified: 2012-07-02 14:00 UTC (History)
1 user (show)

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


Attachments
grub-1.99-r2 build log (sys-boot:grub-1.99-r2:20120317-033901.log.gz,78.14 KB, application/x-gzip)
2012-03-17 06:24 UTC, Maxim Kammerer
Details
grub-2.00_beta0 build log (sys-boot:grub-2.00_beta0:20120317-025827.log.gz,56.71 KB, application/x-gzip)
2012-03-17 06:26 UTC, Maxim Kammerer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Maxim Kammerer 2012-03-17 03:09:59 UTC
On x86, with GRUB_PLATFORMS="efi-32 efi-64" or GRUB_PLATFORMS="efi-64", only /usr/lib/grub/i386-efi is built in both cases.

beta0 builds both directories for GRUB_PLATFORMS="efi-32 efi-64", as expected (or just /usr/lib/grub/x86_64-efi in the second case).

USE-flags: nls.
Comment 1 Mike Gilbert gentoo-dev 2012-03-17 03:56:58 UTC
That was somewhat intentional: I get a configure error when I build grub-2.00_beta0 with GRUB_PLATFORMS=efi-64 on x86.

checking whether option -mcmodel=large works... no
configure: error: -mcmodel=large not supported. Upgrade your gcc.

How did you manage to get it to work?
Comment 2 Mike Gilbert gentoo-dev 2012-03-17 04:04:04 UTC
The full error from config.log:

configure:20366: checking whether option -mcmodel=large works
configure:20385: gcc -c  -Os -m64 -mcmodel=large  -Wall -W -I$(top_srcdir)/include -I$(top_builddir)/include  -DGRUB_MACHINE_EFI=1 -DGRUB_MACHINE=X86_64_EFI -DGRUB_TARGET_CPU_X86_64=1 conftest.c >&5
conftest.c:1:0: error: CPU you selected does not support x86-64 instruction set
configure:20385: $? = 1
Comment 3 Maxim Kammerer 2012-03-17 05:03:10 UTC
Well, I just didn't experience any problems building 2.00_beta0 or 1.99-r2 (which I am working with now, since I understand that it's the stable version).

Here is emerge --info grub (ignore the kernel version, it's a chroot with hardened-sources-3.2.2-r1):

Portage 2.1.10.44 (hardened/linux/x86, gcc-4.5.3, glibc-2.13-r4, 2.6.32-gentoo-r7 i686)
=================================================================
                         System Settings
=================================================================
System uname: Linux-2.6.32-gentoo-r7-i686-with-gentoo-2.0.3
Timestamp of tree: Fri, 16 Mar 2012 00:45:01 +0000
app-shells/bash:          4.2_p20
dev-java/java-config:     2.1.11-r3
dev-lang/python:          2.7.2-r3, 3.2.2
dev-util/cmake:           2.8.6-r4
dev-util/pkgconfig:       0.26
sys-apps/baselayout:      2.0.3
sys-apps/openrc:          0.9.8.4
sys-apps/sandbox:         2.5
sys-devel/autoconf:       2.68
sys-devel/automake:       1.9.6-r3, 1.11.1
sys-devel/binutils:       2.21.1-r1
sys-devel/gcc:            4.5.3-r2
sys-devel/gcc-config:     1.5-r2
sys-devel/libtool:        2.4-r1
sys-devel/make:           3.82-r1
sys-kernel/linux-headers: 3.1 (virtual/os-headers)
sys-libs/glibc:           2.13-r4
Repositories: gentoo liberte
ACCEPT_KEYWORDS="x86"
ACCEPT_LICENSE="@FREE freedist unRAR lha @BINARY-REDISTRIBUTABLE Atmel SIL-freeware amd-ucode Conexant-firmware Hauppauge-Firmware"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-Os -march=pentium3 -mtune=core2 -mfpmath=sse -fomit-frame-pointer -pipe"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc/locale.gen"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-Os -march=pentium3 -mtune=core2 -mfpmath=sse -fomit-frame-pointer -pipe"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--quiet-unmerge-warn --autounmask=n"
FEATURES="assume-digests binpkg-logs collision-protect compress-build-logs distlocks ebuild-locks fixlafiles news parallel-fetch protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync webrsync-gpg"
FFLAGS=""
GENTOO_MIRRORS="http://distfiles.gentoo.org                 http://mirrors.kernel.org/gentoo"
LANG="en_US.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-O,1,-z,combreloc"
LINGUAS="*"
MAKEOPTS="-j3"
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://disabled"
USE="X X509 aac acl acpi action_modeswitch alsa archive aspell bluetooth bs2b bzip2 cairo caps cdda cjk cli consolekit crypt cue dbus dhcp djvu dri eap-tls edd exif expat flac gconf gmp gpm grammar groupwise gtk hardened hires-icons hwdb hybrid-auth iconv id3tag idn iproute2 irda jbig jpeg jpeg2k keymap lcms libkms libnotify lzma m17n-lib mad madwifi mktemp mmx modules mp3 multicall ncurses networkmanager nls nptl nptlonly ntfsprogs ogg opengl openmp ots pam pax_kernel pcmcia pcre pcsc-lite pic pkcs11 png policykit pppd pth readline scsi silc smartcard smime sna sndfile speex spell sse startup-notification staticsocket svg symlink sysfs thesaurus threads tiff truetype unicode urandom usb v4l vorbis wavpack webgl wimax wmf x86 x86emu xattr xft xinerama xmp xorg xv zlib" ALSA_CARDS="sb16" 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" CALLIGRA_FEATURES="kexi words flow plan stage tables krita karbon braindump" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" GRUB_PLATFORMS="efi-32 efi-64" INPUT_DEVICES="evdev synaptics vmmouse joystick" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="*" LIRC_DEVICES="sir devinput bte mceusb hauppauge hauppauge_dvb" NGINX_MODULES_HTTP="access fastcgi gzip limit_req limit_zone map rewrite stub_status" PHP_TARGETS="php5-3" QEMU_SOFTMMU_TARGETS="x86_64" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="apm ark chips cirrus cyrix dummy fbdev glint i128 i740 intel mach64 mga neomagic nsc nv r128 radeon rendition s3 s3virge savage siliconmotion sis sisusb tdfx tga trident tseng v4l vesa via vmware virtualbox qxl" 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:  CPPFLAGS, CTARGET, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

=================================================================
                        Package Settings
=================================================================

sys-boot/grub-1.99-r2 was built with the following:
USE="nls -custom-cflags -debug -device-mapper -efiemu -sdl -static -truetype" GRUB_PLATFORMS="efi-32 efi-64 -coreboot -emu -ieee1275 -multiboot -pc -qemu -qemu-mips -yeeloong"
CFLAGS=""
LDFLAGS=""
Comment 4 Maxim Kammerer 2012-03-17 05:06:57 UTC
From sys-boot:grub-1.99-r2:20120317-033901.log:

checking whether option -mcmodel=large works... yes

Same in sys-boot:grub-2.00_beta0:20120317-025827.log.
Comment 5 Mike Gilbert gentoo-dev 2012-03-17 06:05:37 UTC
(In reply to comment #4)
> From sys-boot:grub-1.99-r2:20120317-033901.log:
> 
> checking whether option -mcmodel=large works... yes
> 
> Same in sys-boot:grub-2.00_beta0:20120317-025827.log.

Would you mind attaching those logs?

I would really like to figure out if I have something mis-configured in my x86 chroot.
Comment 6 Maxim Kammerer 2012-03-17 06:24:10 UTC
Created attachment 305669 [details]
grub-1.99-r2 build log
Comment 7 Maxim Kammerer 2012-03-17 06:26:35 UTC
Created attachment 305671 [details]
grub-2.00_beta0 build log
Comment 8 Maxim Kammerer 2012-03-17 06:27:28 UTC
I still didn't figure out how to prevent double compression of attachments -- sorry about that.
Comment 9 Mike Gilbert gentoo-dev 2012-03-17 06:46:52 UTC
Thanks.

The following lines are interesting:

checking for x86_64-gcc... x86_64-gcc
checking for x86_64-objcopy... x86_64-objcopy
checking for x86_64-strip... no
checking for strip... strip
checking for x86_64-nm... x86_64-nm

Compare that to mine:

checking for x86_64-gcc... no
checking for x86_64-egcs... no
checking for x86_64-cc... no
checking for gcc... gcc
checking for x86_64-objcopy... no
checking for objcopy... objcopy
checking for x86_64-strip... no
checking for strip... strip
checking for x86_64-nm... no
checking for nm... nm

Have you set up an x86_64 cross-compiler? That would explain the difference.
Comment 10 Maxim Kammerer 2012-03-17 07:19:58 UTC
(In reply to comment #9)
> Have you set up an x86_64 cross-compiler? That would explain the difference.

Amazing! Yes, I did -- for the totally unrelated purpose of cross-compiling an x86_64 kernel (ARCH=x86_64 CROSS_COMPILE=x86_64-).

----------
# ls -l /usr/local/bin/x86_64-*
lrwxrwxrwx 1 root root  12 Dec 27 02:27 /usr/local/bin/x86_64-ar -> ../../bin/ar
-rwxr-xr-x 1 root root 116 Dec 27 02:28 /usr/local/bin/x86_64-gcc
lrwxrwxrwx 1 root root  12 Dec 27 02:27 /usr/local/bin/x86_64-ld -> ../../bin/ld
lrwxrwxrwx 1 root root  12 Dec 27 02:27 /usr/local/bin/x86_64-nm -> ../../bin/nm
lrwxrwxrwx 1 root root  17 Dec 27 02:27 /usr/local/bin/x86_64-objcopy -> ../../bin/objcopy
----------

----------
# cat /usr/local/bin/x86_64-gcc 
#!/bin/sh

# Emulate x86_64 generic CPU (no corresponding -march switch)
exec gcc -m64 -march=nocona -mno-sse3 "$@"
----------

Can something similar be done inside the ebuild?
Comment 11 Maxim Kammerer 2012-03-17 07:26:10 UTC
> Can something similar be done inside the ebuild?

I guess that only the x86_64-gcc wrapper is necessary, as x86_64-objcopy and x86_64-nm will fall back to their non-prefixed counterparts, like x86_64-strip did?
Comment 12 Mike Gilbert gentoo-dev 2012-03-17 08:02:53 UTC
I think figured out how to make it work by playing with the TARGET_CC, TARGET_CFLAGS, and TARGET_CPPFLAGS variables. This avoids the need for a wrapper. It seems to work in my chroot.

I've committed it to CVS, so it should be available shortly. Please give it a try and let me know if it works for you.

+  17 Mar 2012; Mike Gilbert <floppym@gentoo.org> grub-2.00_beta2.ebuild:
+  Enable building x86_64-efi target on an x86 host. Bug 408545.
+
Comment 13 Mike Gilbert gentoo-dev 2012-03-18 02:57:47 UTC
I'm assuming it works.
Comment 14 Maxim Kammerer 2012-03-18 03:32:23 UTC
Hi, I was just waiting for the updates to appear in new portage snapshot.

Yes, it does work for me on x86 with GRUB_PLATFORMS="efi-32 efi-64" -- both with the cross-compiling wrappers and without them.

By the way, /usr/lib/grub/*/ directories have both .mod and .module files -- I assume that's intended (it doesn't happen with 1.99).
Comment 15 Maxim Kammerer 2012-03-18 03:42:29 UTC
Perhaps the following comparison will also be of interest.

grub-1.99-r2:
-rw-r--r-- 1 root root 399360 Mar 18 03:40 BOOTIA32.EFI
-rw-r--r-- 1 root root 676352 Mar 18 03:40 BOOTx64.EFI

grub-2.00_beta2:
-rw-r--r-- 1 root root 470528 Mar 18 03:31 BOOTIA32.EFI
-rw-r--r-- 1 root root 978432 Mar 18 03:31 BOOTx64.EFI

That's quite a difference in size.
Comment 16 Mike Gilbert gentoo-dev 2012-03-18 06:44:13 UTC
I'm not sure why upstream decided to start installing the module files along with the mod files.

I made an additional tweak to pass -Os in TARGET_CFLAGS when we set that for efi-64 on x86. That may help reduce the size of your BOOTx64.EFI image.