Skip to contentSkip to conversation

Mac OSX Ports

DISCUSSION Yves BLUSSEAU 2 participants 2 messages Jun 30, 2009

lore
Share & tools
lore
#0 lore raw

Hi,

i'm currently trying to ports grub2 to Mac OSX (leopard).
I can compil and build the code with XCode.
I have add the necessary functions and calls to support OSX (like getting block counts of a block device with ioctl calls).

The only problem is the hook nested functions. XCode disable nested functions by defaut.
So i enabled it with the gcc option -fnested-functions: all compil and build right but i have exceptions at runtime. If i put nested functions outside (putting also inner variables outside) i fix the problem and all work well.

So do you know if it exists a gcc option or a linker option to fix this nested functions problem ?

Also where or at who i can sent my OSX patchs for incorporating into the main trunk ?

Thanks in advance,
Yves Blusseau

#1 lore raw

Hello. I'm happy that my effort to make grub2 compile with Apple's CC paid off. I personally don't care much about whether it compiles under OSX but the idea was to attract new developpers by doing so. If you came it means the effort paid off

Quoted 7 lines · Yves BLUSSEAU

Hi,

i'm currently trying to ports grub2 to Mac OSX (leopard).
I can compil and build the code with XCode.
I have add the necessary functions and calls to support OSX (like getting block counts of a block device with ioctl calls).

I don't see why do you need XCode. You can compile grub2 with Apple's cc in console with ./configure && make. It's better then using xcodebuild because of maintainaibility. Current build system is already a hell because you have to add same file to multiple lists sometimes. Robert Milan is working on it. But especially don't add a new location which must stay at sync. In short I'm opposed to using XCode building system unless you make it a wrapper to current one, otherwise it's simply unmaintainable

Quoted 10 lines

The only problem is the  hook nested functions. XCode disable  nested functions by defaut.
So i enabled it with the gcc option -fnested-functions: all compil and build right but i have exceptions at runtime.
If i put nested functions outside  (putting also inner variables outside) i fix the problem and all work well.

So do you know if it exists a gcc option or a linker option to fix this nested functions problem ?

The problem is the stack protection and trampolines.
http://grub.enbug.org/NestedFunctions
I personally think stack protection is a junk security for placebo effect and to be sold out. It's pity grub can't work on such systems even if this "security engineering" is braindeath. Just moving functions outside isn't a good approach IMO. You need to add a way to pass parameters to hooks. It was already discussed on this list how to do it but nobody did.
Alternatively you can disable stack protection (-fno-stack-protector or -fstack-protector may help or you can disable it through sysctl, idr how exactly)
This issue doesn't affect the ability to use grub - it compiles fine and grub-mkimage generates a correct executable which you can use. But it does affect the ability of developping since you can't use grub-emu. But it's not a big deal of disabling stack protection through sysctl for developpement

Quoted 3 lines

Also where or at who  i can sent my OSX patchs for incorporating into the main trunk ?

Send it here. We'll review it. If they're copyright-significant we'll need a copyright assignment from you. You can also contact me through jabber (this email as id) or IRC (at freenode.net#grub) if you want a small summary of what needs to be done.

Quoted 9 lines

Thanks in advance,
Yves Blusseau

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

Signature · 4 lines
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git