Skip to contentSkip to conversation

GRUB2 Build on Mac OS X

DISCUSSION [email protected] 3 participants 5 messages Dec 8, 2005 – Dec 9, 2005

lore
Share & tools
lore
#0 lore raw

The Mac OS X GCC compiler will not build GRUB2, due static linking at address 0x2000; this error can be confirmed during the configure process. If I could build GRUB2 using the Mac OS X GCC, I would be able to build GRUB2 images from Mac OS X.

The binary I attempted the build using the cross compiler tool chain powerpc-elf, would have executed on PowerPC Linux, but I would not build due to the nested function support being disabled in the Apple GCC.

Since the GRUB2 tools built using a Linux GCC compiler will suffice at the moment, I can see why the team is not overly concerned with this issue. If GRUB2 is going to be portable(Mac OS X), then some changes will be needed to accomplish this goal.

If stack execution support is disabled in future releases of other operating systems, it will become an issue of nested functions implemented with stack execution, and less of an Apple GCC compiler issue.

I do agree that more arguments will be needed on function calls if nested functions are not going to be used, if the list is willing to accept patches to address this issue.

As far as the GRUB2 tools, binaries executed on the PowerPC platform only need to be pure ELF. I am not sure if creating Mach-O boot binaries will yield any benefits for bringing up a kernel. If GRUB2 is to be used on the Mac OS X operating system, the tools need to be Mach-O based.

Andre

Quoted 63 lines

-----Original Message-----
From: Andrei Warkentin [mailto:[email protected]]
Sent: Thursday, December 8, 2005 08:10 PM
To: 'The development of GRUB 2'
Subject: Re: GRUB2 Build on Mac OS X

I understand (still had my mind on GRUB 1 :)) - then looks like two GCC installations will be
required to construct GRUB2 on OS X - one to generate OS X-hosted GRUB utilities (which will
be Mach-O files), and one to generate ELF files that will be used in the booting process.

Quoted 36 lines · Marco Gerards

Andrei Warkentin <[email protected]> writes:

Hi Andrei,

Quoted 5 lines

There is another issue with GRUB2 on OS X which I am not sure has been brought up yet.
Right now, AFAIK (but I haven't tested it), GRUB2 (the part that runs from OpenFrimware) can be built
with a bootstrap powerpc-elf-targetted GCC hosted on OS X. However,

Quoted 8 lines

the local GRUB2 binary (one that can run
from OS X and perform installation and some such) needs to be compiled with the OS X compiler. Why? OS X doesn't use ELF - it uses Mach-O. If you want to be able to build GRUB2 in OS X with purely the OS X GCC, then the build procedure must take into account the Mach-O
output format. AFAIK, new OpenFirmware versions (3.x) can boot Mach-O binaries but I haven't had a chance to experiment with this yet.

You mean the utilities like grub-setup, grub-mkimage, grub-emu, etc? They should be able to run on macos, right? Of perhaps I am missing your point.

If those utilities can be build in a better way so nothing breaks and it will work on macos, I am quite interested in hearing how to solve that.

Mach-O binaries for booting is a different subject. We rely on ELF files, grub-mkimage even creates ELF files and uses ELF load segments. Without it GRUB just won't work, unless grub-mkimage is changed intensively. So it seems easier just to use ELFs in any case.

--
Marco

Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

#1 lore raw
Quoted 1 line · On Dec 8, 2005, at 4:01 PM, [email protected] wrote:

The Mac OS X GCC compiler will not build GRUB2, due static linking at address 0x2000; this error can be confirmed during the configure process. If I could build GRUB2 using the Mac OS X GCC, I would be able to build GRUB2 images from Mac OS X.

The OS X ld is not the GNU linker - so sure it can't link at 0x2000, it doesn't know what -T means. You would probably use some permutation of the -segaddr option. Moreover, OS X uses the Mach-O binary format, not ELF...

Quoted 2 lines

The binary I attempted the build using the cross compiler tool chain powerpc-elf, would have executed on PowerPC Linux, but I would not build due to the nested function support being disabled in the Apple GCC

I don't think I understand - you can build a bootstrap GCC targetted at powerpc-linux, from the sources obtained via official GNU ftp. There would not be any restrictions there... This would allow you to build powerpc-elf binaries needed by OF.

Quoted 2 lines

Since the GRUB2 tools built using a Linux GCC compiler will suffice at the moment, I can see why the team is not overly concerned with this issue. If GRUB2 is going to be portable(Mac OS X), then some changes will be needed to accomplish this goal.

I think it would be an interesting idea to allow the use of different toolsets to produce the boot-time files and the system utilities. This way, the boot-time stuff can be build as powerpc-elf, while the OS X system utilities can be built as Mach-O (well, not 'can' - should, there is no other way here).

Quoted 80 lines

If stack execution support is disabled in future releases of other operating systems, it will become an issue of nested functions implemented with stack execution, and less of an Apple GCC compiler issue.

I do agree that more arguments will be needed on function calls if nested functions are not going to be used, if the list is willing to accept patches to address this issue.

As far as the GRUB2 tools, binaries executed on the PowerPC platform only need to be pure ELF. I am not sure if creating Mach-O boot binaries will yield any benefits for bringing up a kernel. If GRUB2 is to be used on the Mac OS X operating system, the tools need to be Mach-O based.

Andre

Quoted 58 lines

-----Original Message-----
From: Andrei Warkentin [mailto:[email protected]]
Sent: Thursday, December 8, 2005 08:10 PM
To: 'The development of GRUB 2'
Subject: Re: GRUB2 Build on Mac OS X

I understand (still had my mind on GRUB 1 :)) - then looks like two GCC installations will be
required to construct GRUB2 on OS X - one to generate OS X-hosted GRUB utilities (which will
be Mach-O files), and one to generate ELF files that will be used in the booting process.

Quoted 36 lines · Marco Gerards

Andrei Warkentin <[email protected]> writes:

Hi Andrei,

Quoted 5 lines

There is another issue with GRUB2 on OS X which I am not sure has been brought up yet.
Right now, AFAIK (but I haven't tested it), GRUB2 (the part that runs from OpenFrimware) can be built
with a bootstrap powerpc-elf-targetted GCC hosted on OS X. However,

Quoted 8 lines

the local GRUB2 binary (one that can run
from OS X and perform installation and some such) needs to be compiled with the OS X compiler. Why? OS X doesn't use ELF - it uses Mach-O. If you want to be able to build GRUB2 in OS X with purely the OS X GCC, then the build procedure must take into account the Mach-O
output format. AFAIK, new OpenFirmware versions (3.x) can boot Mach-O binaries but I haven't had a chance to experiment with this yet.

You mean the utilities like grub-setup, grub-mkimage, grub-emu, etc? They should be able to run on macos, right? Of perhaps I am missing your point.

If those utilities can be build in a better way so nothing breaks and it will work on macos, I am quite interested in hearing how to solve that.

Mach-O binaries for booting is a different subject. We rely on ELF files, grub-mkimage even creates ELF files and uses ELF load segments. Without it GRUB just won't work, unless grub-mkimage is changed intensively. So it seems easier just to use ELFs in any case.

--
Marco

Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Quoted 5 lines

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

#3 lore raw
In reply to [email protected]

Aside from compiling/linking issues, there is another thing to keep in mind should there ever be a port of bootable GRUB2 parts to OF/Mach-O. OS X uses a different calling convention, so any assembly bits would have to be properly adjusted.

I still think the best solution here would be to compile the bootable parts with a crosscompiler as PowerPC ELF, while compiling the system utilities with the stock Apple GCC and native LD (and associate frameworks) as Mach-O.

#2 lore raw
In reply to Andrei Warkentin
Quoted 11 lines · Andrei Warkentin
Quoted 4 lines · On Dec 8, 2005, at 4:01 PM, [email protected] wrote:

The Mac OS X GCC compiler will not build GRUB2, due static linking at address 0x2000; this error can be confirmed during the configure process. If I could build GRUB2 using the Mac OS X GCC, I would be able to build GRUB2 images from Mac OS X.

The OS X ld is not the GNU linker - so sure it can't link at 0x2000, it doesn't know what -T means. You would probably use some permutation of the -segaddr option. Moreover, OS X uses the Mach-O binary format, not ELF...

As I explained before only ELF can be used.

Quoted 16 lines
Quoted 4 lines

The binary I attempted the build using the cross compiler tool chain powerpc-elf, would have executed on PowerPC Linux, but I would not build due to the nested function support being disabled in the Apple GCC

I don't think I understand - you can build a bootstrap GCC targetted at powerpc-linux, from the sources obtained via official GNU ftp. There would not be any restrictions there... This would allow you to build powerpc-elf binaries needed by OF.

Quoted 5 lines

Since the GRUB2 tools built using a Linux GCC compiler will suffice at the moment, I can see why the team is not overly concerned with this issue. If GRUB2 is going to be portable(Mac OS X), then some changes will be needed to accomplish this goal.

Quoted 5 lines

I think it would be an interesting idea to allow the use of different toolsets to produce the boot-time files and the system utilities. This way, the boot-time stuff can be build as powerpc-elf, while the OS X system utilities can be built as Mach-O (well, not 'can' - should, there is no other way here).

This is possible already. For example when I crosscompile GRUB on my x86 I get grub-mkimage as x86 tools and grubof as a PPC ELF. Perhaps it doesn't build Mach-O yet, but that is something that can be fixed.

--
Marco

#4 lore raw
In reply to [email protected]
Quoted 4 lines · [email protected] writes:

Since the GRUB2 tools built using a Linux GCC compiler will suffice at the moment, I can see why the team is not overly concerned with this issue. If GRUB2 is going to be portable(Mac OS X), then some changes will be needed to accomplish this goal.

GCC is a GNU project, not a Linux project...

Hopefully you understand we can't always fix things other people deliberately break. And what is more important to me is that we need a solid and stable codebase first, one that most regular contributors are happy with.

Quoted 4 lines

If stack execution support is disabled in future releases of other operating systems, it will become an issue of nested functions implemented with stack execution, and less of an Apple GCC compiler issue.

In that case we should figure out how to fix this. But apple didn't just disable the execution on the stack, they fucked up the compiler.

--
Marco