Cross Compiling with distcc

 

Introduction

This page describes a novel technique that eliminates some of the complexity of normal cross-compiling. A classic problem with cross-compiling software for Unix-like systems is that many of the build systems (particularly the GNU auto tools) run small test programs as part of the build system to check for specific features or bugs. Traditional cross-compilation environments do not allow these programs to run and the builds therefore fail.

 

Setup

After installing distcc and distccd. edit /etc/sysconfig/distccd. In my case, I set the following

DISTCCPATH="/opt/toolchain/bin"
OPTIONS="--nice 5 --jobs 5 --allow 192.168.0.0/24 --port 3632"

Masquerading the compilers

On the client side, I masqueraded the compilers so that distcc would be called. My compilers are located in /opt/toolchain/bin. So I did the following:

cd /opt/toolchain/bin
mkdir distcc
cd distcc
ln -s /usr/bin/distcc arm-linux-gcc
ln -s /usr/bin/distcc arm-linux-g++
ln -s /usr/bin/distcc arm-linux-c++

the PATH variable has to reflect this new change, and you need to create a pointer to the distcc path BEFORE the path of the original, as in

PATH="/opt/toolchain/bin/distcc:/opt/toolchain/bin"

On the client (Building) machine, you need to put DISTCC_HOSTS in /etc/profile. By default, the limit of 4 compiles on each machine is the default but can be changed with '/x' where x is the number of processes on the other hosts

 

export DISTCC_HOSTS="machine1/2 machine2/2 localhost/4"