Linux kernel cross compiling reference...

Michael Neuling mikey at
Mon Dec 19 18:15:08 EST 2005


I've been playing around with getting ccontrol to cross compile the
Linux kernel.  I wanted to compile 64bit POWERPC kernels on my x86
laptop.  I managed to get it working so I though I'd quickly post my
adventures here as a reference for others.

You still need a local arch specific linker, preprocessor, etc,so
firstly I installed the 64bit POWERPC cross compiler on my laptop
using crosstool.  Crosstool installed the utils in:
eg gcc was

Then my ccontrol config looked like this:

1 [/*linux*powerpc*]
2 	add make = ARCH=powerpc
3 	add make = CROSS_COMPILE=/usr/local/crosstool/gcc-3.4.2-glibc-2.3.3/powerpc64-unknown-linux-gnu/bin/powerpc64-unknown-linux-gnu-
4	add make = LD=ccontrol --section=cross-powerpc ld 
5	add make = CC=ccontrol --section=cross-powerpc cc 
6 [cross-powerpc]
7	distcc-hosts = big.fat.powerpc.compiler.server another.big.fat.powerpc.compiler.server 
8	ld = /usr/local/crosstool/gcc-3.4.2-glibc-2.3.3/powerpc64-unknown-linux-gnu/bin/powerpc64-unknown-linux-gnu-ld
9	cc = /usr/local/bin/powerpc64-unknown-linux-gnu-gcc-3.4

Lines 2 and 3 are are standard kbuild options required when you want
cross compile the linux kernel
Lines 4 and 5 tell us which ld and cc to use but ensure they are still
run under via ccontrol.  
Line 6 starts a section to match lines 4 and 5.  
Line 7 simply specifies the distcc hosts
Line 8 and 9 specify location of the POWERPC compiler tools.

Each of the machines specified in the distcc-hosts needs to have the
command specified in line 9.  We simply created the created the
required sym links.  We had the additional problem that one of the
machines had gcc setup to default to 32bits, so we wrote a quick
wrapper which did something like the following

  if echo "$@" | fgrep -q -- -m32; then
	  exec /usr/bin/gcc-3.4 "$@"
	  exec /usr/bin/gcc-3.4 -m64 "$@"

(prom.c in the Linux kernel needs to be compiled in 32bit mode
so we still needed to support than when asked to)

Many thanks to Rusty who did all the hard work to actually get this
config to work.


More information about the ccontrol mailing list