Wednesday, January 04, 2006

Debian Kernel with distcc

Debian with distccUsing distcc with debian

distcc is a program to distribute builds of C, C++, Objective C or Objective C++ code across several machines on a network. distcc is often two or more times faster than a local compile which makes it excellent for performing compiling kernels and other things on slow machines.

distcc however is a little harder than normal to get working with debian's kernel-package tool.

The purpose of this howto is to guide someone though the process of getting distcc to work with make-kpkg on a debian system.

Getting distcc for debian

This is rather trivial.

apt-get install distcc

There are also a graphical distcc monitoring tool which can be installed as follows:

apt-get install distccmon-gnome

Preparing your debian for using make-kpkg with distcc

You need to set up what the distcc man page refers to as a "masquerade directory" which contains symlinks from the name of the real compiler to the distcc binary. This directory is inserted early on the PATH, so that calls to the compiler are intercepted and distcc is run instead. distcc then removes itself from the PATH to find the real compiler.

What do these variables do?

CONCURRENCY_LEVEL=40

This tells make-kpkg how many jobs to send off to the compiler (distcc)

DISTCC_HOSTS="localhost tokra sokar alkesh osiris"

Tells distcc which machines to use for distributing jobs to. The host list is a simple whitespace separated list of hostnames. distcc prefers hosts towards the start of the list, so machines should be listed in descending order of speed. It is important that you place localhost at the right point in the list to get the best performance.

If your machine is slower than the other hosts in the list then you place it later in the list or not at all as it will slow the distribution of the jobs to the faster hosts. If however your machine is faster than the volunteers, you should place localhost towards the beginning of the list

PATH="/usr/local/distcc:${PATH}"

This places /usr/local/distcc/bin early in the PATH so that the calls to the compiler are intercepted by the symlinks to distcc instead of the compiler itself. distcc will then distribute jobs to the host listed in DISTCC_HOSTS= and compiled using the real compilers.