Saturday, April 25, 2015

Cross-Compiling for the Raspberry Pi: distributed compilation

So far I've been trying different cross-compiling techniques: QEmu, Scratchbox and Raspberry Pi tools. But I should say, they didn't work for me. Just try to build something as big as GStreamer and you will get what I'm saying.

The new approach that I'm heavily using right now is distributed compilation. It allows you by just launching the make command, having your remote PC working instead of your Pi, and a few seconds later having your program/library compiled just as if everything happened on the Pi itself.

1. Configure slaves: install distcc and configure it. Figure out how many processors you have available on the machine(s) and how many of those you would like to share. Start slave as follows (or configure it as a daemon):
$ distccd --user nobody --jobs 8 --allow 192.168.1.133 --verbose --log-stderr
2. Configure Raspbian master: install distcc and configure it. Edit /etc/distcc/hosts and comment out the line with +zeroconf. Add space-delimited list of slaves on your network.

3. Compile it! Edit PATH so it uses distcc instead of the local compiler:
$ export PATH=/usr/lib/distcc:$PATH
$ which gcc
Start compilation process.

UPDATE: very important thing that I forgot to mention. Before running distcc on your slave machine you will need to install Raspberry Pi tools and update PATH as follows:
$ export PATH=$RPI_TOOLS/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin:$PATH

No comments:

Post a Comment