Linux package cross-compilation

1.1k views Asked by At

I am building a non-visual surveillance (sonar) platform using a single-board computer (Pandaboard), running Arch Linux. The problem is that when I need to add a feature to my installation the make and make install processes take forever on the low-power computer. I would like someone with similar experience to point me to a solution for compiling the packages on another linux box (also running Arch) and then porting them to the SBC.

1

There are 1 answers

0
starfry On

do you read or have access to Linux Format magazine? There is an article on this very subject in issue 166. The target is the Raspberry Pi but the process is the same.

Basically, you need to install a cross compiler on your x86 box. Try this:

yaourt -S arm-linux-gnueabi-gcc

before you go any further, test that toolchain with a simple hello,world that you can compile on x86, copy to the device and execute.

/* hello.c */
#include <stdio.h>
int main ()
{
   printf("Hello, World!\n");
   return 0;
}

The compile command will be something like

arm-linux-gnueabi-gcc -o gello hello.c

With that in place you can cross compile a kernel:

git clone --depth 1 git://github.com/raspberrypi/linux.git
cd linux
ssh root@alarmpi zcat /proc/config.gz > .config
make -j 8 ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- menuconfig -k

You can use distcc to perform builds on the pandaboard but have it delegate comppilation to your x86 box which will use your cross compiler toolchain to compile for arm. On both arm and x86:

pacman -S distcc

The arm side is the client. Edit its config, /etc/makepkg.conf to tell it about the server (your x86 box):

BUILDENV=(fakeroot distcc color !ccache)
DISTCC_HOSTS="myx86host"
MAKEFLAGS="-j8"

The j8 tells it to utilize all cores on an i7. Adjust appropriately.

On the server, you need to configure distccd /etc/conf.d/distccd to allow the client to connect and then start the distccd daemon. You then launch your builds from the client.

The makepkg tool for building Arch packages takes care of the distcc linkage. If you're building your own packages I suggest you wrap them in a PKGBUILD so that work is done for you.

(you may need to tweak some of the above for hard-float if your board uses it)