Main Page | See live article | Alphabetical index

DistCC

distcc is a program to distribute builds of C, C++, Objective C or Objective C++ code across several machines on a network. distcc should always generate the same results as a local build, is simple to install and use, and is often two or more times faster than a local compile.

distcc does not require all machines to share a filesystem, have synchronized clocks, or to have the same libraries or header files installed. They can even have different processors or operating systems, if cross-compilers are installed.

For speeding up our builds we use and recommend distcc to allow us to distribute compilation across two or more machines (i.e. a laptop and a desktop). distcc can be set up in no time and if like us you're continuously and repeatedly building lots of code it'll save you hours if not days of waiting around for compiles to finish. Also check out ccache. — The Rosegarden music software developers. 30-second instructions:

" class="external">http://distcc.samba.org/distccmon-gnome-2003-09-23-01.png

For each machine, download distcc, unpack, and do ./configure && make && sudo make install

On each of the servers, run distccd --daemon, with --allow options to restrict access.

Put the names of the servers in your environment: export DISTCC_HOSTS='localhost red green blue'

Build! cd ~/work/linux-2.4.19; make -j8 CC=distcc

distcc is developed on GNU/Linux, but has been reported to work on other systems including FreeBSD, NetBSD, Darwin, Solaris, HP-UX, IRIX, Cygwin and BSD/OS. distcc is not supported on any SCO operating system.

distcc sends the complete preprocessed source code across the network for each job, so all it requires of the volunteer machines is that they be running the distccd daemon, and that they have an appropriate compiler installed.

distcc is not itself a compiler, but rather a front-end to the GNU C/C++ compiler (gcc). (There is preliminary support for some other compilers but the main focus is gcc.) Almost all gcc options and features work as normal.

distcc is designed to be used with the -j parallel-build feature in GNU Make or SCons, or other build tools. Shipping files across the network takes time, but few cycles on the client machine. Any files that can be built remotely are essentially "for free" in terms of client CPU.

distcc has been under development since early 2002. It reliably and successfully compiles large, complex free and proprietary software systems. Programs known to build correctly with distcc include the Linux kernel, rsync, KDE, GNOME (via GARNOME), Samba and Ethereal.

distcc is nearly linearly scalable for small numbers of machines: Building Linux 2.4.19 on a single 1700MHz Pentium IV machine with distcc 0.15 takes 6 minutes, 45 seconds. Using distcc across three such machines on a 100Mbps switch takes only 2 minutes, 30 seconds: 2.6x faster. The (unreachable) theoretical maximum speedup is 3.0x, so in this case distcc scales with 89% efficiency.

You don't need a lot of machines to benefit: a laptop and a single desktop is much faster than a laptop alone.

You might like to also look at Andrew Tridgell's ccache compiler cache, which can avoid running the compiler altogether if the object file is cached from a previous identical run. This is great if you work in several similar source trees. Of course it works well with distcc.

distcc is distributed under the GNU General Public Licence v2.