distcc works well with the ccache tool for caching compilation results. To use the two of them together, simply set
CC='ccache distcc'
distcc works quite well with autoconf.
DISTCC_VERBOSE
can give autoconf trouble because
autoconf tries to parse error messages from the compiler.
If you redirect distcc's diagnostics using
DISTCC_LOG
then it seems to be fine.
Some autoconf-based systems "freeze" the compiler name
used for configure into their Makefiles. To make them use
distcc, you must either set $CC
when running
./configure
, and/or override $CC
on the
right-hand-side of the Make command line.
Some poorly-written shell scripts may assume that
$CC
is a single word. At the moment the best fix
is to use a shell script that calls distcc
.
Some versions of libtool seem not to cope well when CC is
set to more than one word, such as "distcc gcc"
.
Setting CC=distcc
, which is supported in 0.10 and
later, seems to work well.
Gentoo is a "ports"-based free software distribution, in which packages are always built from source on installation. distcc works well with Gentoo to speed installation.
You can install distcc either using the upstream tarball
from distcc.samba.org
(which may be newer), or
using emerge distcc
to get the Gentoo port, which
may be better integrated. You can also get ccache with
emerge ccache
.
After installing distcc, starting servers and setting
DISTCC_HOSTS
, use a command like this to build
addition packages using distcc:
MAKEOPTS="-j9" CC=distcc CXX=distcc emerge
packagename
The -j9
is only an example; set it appropriately
for the number of processors available.
To use distcc for all compilations, edit
/etc/make.conf
to include something like these
lines, appropriately adjusted for your systems:
CC="distcc"
CXX="distcc g++"
MAKEOPTS="-j4"
DISTCC_HOSTS="host1 host2 localhost"
gcc has the ability to produce information about header dependencies as a side-effect of preprocessing. These can be included in Makefiles in various ways to make sure that files are up-to-date.
This feature is enabled using -MD
, -M
and related options.
Unfortunately, gcc changed the behaviour of this feature between gcc 2.95 and 3.x in such a way that it seems properly for distcc to generally support it. The difficulty is that the filename to which dependencies are written depends in a very complicated way on the gcc command line. distcc needs to change the command line to run the preprocessor locally and the compiler remotely, and this can sometimes cause problems. (This also causes problems for Makefiles that are supposed to work with both versions of the compiler.)
-M
causes gcc to produce dependency information
instead of compiling. distcc understands this and passes
the option straight through to gcc. It should work correctly.
With gcc 2.95, -MD
always writes dependencies
into the preprocessor's working directory. distcc should
work fine.
With gcc 3.2, -MD
writes the output into either
the source directory or output directory, depending on the
presence of the -o
option. However, gcc 3.2
also has a -MF
option that can be used to
explicitly set the dependency output file, and this works
well with distcc.
In summary: for gcc 2.95, no changes are required. For
gcc 3.2, -MF
should be used to specify the file
to write dependencies to.