# Cross Compile FreeBSD Kernel



## dinnerblaster (Feb 5, 2013)

Hi Guys! I want to ask you if it is possible to compile the FreeBSD Kernel from another platform and OS (e.g. OSX)

Thank you in advance

;-)


----------



## dinnerblaster (Feb 6, 2013)

In NetBSD this is possible by obtaining the kernel sources and then building the cross-compiler toolchain..


----------



## dinnerblaster (Feb 7, 2013)

Nobody can help me?


----------



## Beeblebrox (Feb 7, 2013)

http://forums.freebsd.org/showthread.php?t=23136


----------



## dinnerblaster (Feb 8, 2013)

Beeblebrox said:
			
		

> http://forums.freebsd.org/showthread.php?t=23136



Thank you very much, this is surely interesting but if i want to compile it from a Linux Distribution or OS X ?


----------



## Beeblebrox (Feb 8, 2013)

Download sources using svn into $wherever, chroot (target shell: sh) into $wherever and buildworld?


----------



## dinnerblaster (Feb 10, 2013)

Beeblebrox said:
			
		

> Download sources using svn into $wherever, chroot (target shell: sh) into $wherever and buildworld?



Thank you for the reply, anyway i'm a noob in these things, could you be more specific?

Thank you again!


----------



## roddierod (Feb 10, 2013)

dinnerblaster said:
			
		

> Thank you for the reply, anyway i'm a noob in these things, could you be more specific?
> 
> Thank you again!



The short answer is you can't.

What your asking is not cross compiling like NetBSD does. If you notice NetBSD stuff is just compiling NetBSD on one architecture and running it on another but it's still all NetBSD.  

What you want is something like the Debian project that uses the FreeBSD kernel with Linux userland. It's not as simple as just recompiling the kernel. Go take a look at what that project did/is doing.  You'd never be able to do it with OSX since the parts you probably want to utilizes of OSX are closed source...namely the GUI.


----------



## dinnerblaster (Feb 11, 2013)

roddierod said:
			
		

> The short answer is you can't.
> 
> What your asking is not cross compiling like NetBSD does. If you notice NetBSD stuff is just compiling NetBSD on one architecture and running it on another but it's still all NetBSD.
> 
> What you want is something like the Debian project that uses the FreeBSD kernel with Linux userland. It's not as simple as just recompiling the kernel. Go take a look at what that project did/is doing.  You'd never be able to do it with OSX since the parts you probably want to utilizes of OSX are closed source...namely the GUI.



Uhm, i think that i didn't explain myself well, what i want to do is exactly the same as compiling the NetBSD kernel in OSX, only with FreeBSD in place of NetBSD..

Thank you

(Also sorry for my bad english)


----------



## wblock@ (Feb 11, 2013)

Most readers will not have cross-compiled the NetBSD kernel on OSX, so expanding on that could be helpful.

What do you plan to do with the compiled kernel?  If it's for something like an emulator or just an experiment to get cross-compiling working, sure.  It would not be a usable replacement for the OSX kernel, though.


----------



## SirDice (Feb 11, 2013)

To add to that, you're going to need a system to test it on anyway. So you might as well set up a VM with a full FreeBSD install on it.


----------



## dinnerblaster (Feb 11, 2013)

The situation is like this: I have an old PIII machine with FreeBSD installed, but if i try to compile the FreeBSD kernel from that machine it would take hours, if instead of that PIII processor i use the 4 core Intel processor of my Mac i assume that it would take less time.

For NetBSD all i have to do is download the kernel sources, setting up the cross-compiler environment, and use the script "build.sh" for building the kernel image.

LINK


----------



## dinnerblaster (Feb 11, 2013)

If there isn't an alternative i will go with the VM.

Thank you for your support and for your help!


----------



## SirDice (Feb 12, 2013)

Simple solution, install FreeBSD in a VM. Build your kernel and world there. NFS export /usr/src/ and /usr/obj/. Mount them on the slow machine and you only have to installworld, installkernel and mergemaster(8) on it.

You can do the same for building packages. Create a /usr/ports/packages/ and they will appear there. NFS mount or otherwise move them to the slow machine and simply pkg_add(1) them there.


----------

