[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

compiling grub2 on mac

From: Dmitrijs Ledkovs
Subject: compiling grub2 on mac
Date: Mon, 14 Jun 2010 09:32:24 +0100

I've installed automake, autoconf, gettext and freetype from macports.
Manual compiled objconv. I've also installed vanilla fsf-gcc44
toolchain from macports (note it uses system ld, as)

1) Compiling using Apple gcc toolchain

compiles, fails to strip, since cctools strip has quite different
command line options and I can't quite figure out exact parameters

Defining TARGET_NO_STRIP=yes finishes the build.

Should this be defined by default for apple detected toolchain?

2) Compiling using macports-gcc-44 (vanilla fsf)

Configure fails probably because ld,as are not fsf-binutils.

I see this multiple times in config.log and configure ultimately fails
"cannot compile for target"

configure:9891: checking whether target compiler is working
configure:9910: gcc -o conftest  -Os -DGRUB_MACHINE_EFI=1
-DMACHINE=I386_EFI -Wall -W -Wshadow -Wpointer-arith
-Wmissing-prototypes                -Wundef -Wstrict-prototypes -g
-falign-jumps=1 -falign-loops=1 -falign-functions=1 -mno-mmx -mno-sse
-mno-sse2 -mno-3dnow -fno-dwarf2-cfi-asm -m32 -fno-stack-protector
-mno-stack-arg-probe -Werror -nostdlib -Wl,--defsym,___main=0x8100
-m32 conftest.c  >&5
ld: unknown option: --defsym

I will try macports-gcc with macports occtools but I don't think it
will work either. I will attempt building gcc with fsf binutils, but
so far all hints on the internet say that this is not quite possible
(or doesn't produce working toolchain)

3) Running non-stripped apple-gc42 build grub2 i386-efi

$ ./grub-mkimage --verbose -d . -o grub.efi part_gpt hfsplus fat ext2
normal chain boot configfile linux -O i386-efi
<snip info: getting the size of *.mod>
./grub-mkimage: info: the total module size is 0x26fbc.
./grub-mkimage: info: getting the size of ./kernel.img.
./grub-mkimage: info: reading ./kernel.img.
./grub-mkimage: info: getting the size of ./kernel.img.
./grub-mkimage: error: invalid ELF header.

$ file kernel.img
kernel.img: Mach-O object i386

Well I did this (blindly simulating what is done during make):

$ objconv -felf32 -wd1106 -ew2030 -ew2050 -nu -nd kernel.img
$ mv kernel.img
$ ./grub-mkimage -d . -o grub.efi part_gpt hfsplus fat ext2 normal
chain boot configfile linux -O i386-efi

Horay =) it generates grub.efi

it doesn't boot via rEFIt though =(

I guess converting kernel.img to elf binary didn't go that well. Is
there anything else I can do to make it work?

I'm gonna try installing linux-elf cross toolchain via macports
compile grub2 modules/kernel.img and use those with mach-o
grub-mkimage and see if that will boot.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]