distcc [COMPILER OPTIONS]
<compiler> [COMPILER OPTIONS]
distcc [DISTCC OPTIONS]
This version incorporates plain distcc as well as an enhancement
called pump mode or distcc-pump.
For each job, distcc in plain mode sends the complete preprocessed
source code and compiler arguments across the network from the
client to a compilation server. In pump mode, distcc sends the
source code and recursively included header files (excluding those
from the default system header directories), so that both preprocessing
and compilation can take place on the compilation servers. This
speeds up the delivery of compilations by up to an order of magnitude
over plain distcc.
Compilation is driven by a client machine, which is typically
the developer's workstation or laptop. The distcc client runs
on this machine, as does make, the preprocessor (if distcc's pump
mode is not used), the linker, and other stages of the build process.
Any number of volunteer machines act as compilation servers and
help the client to build the program, by running the distccd(1)
daemon, C compiler and assembler as required.
distcc can run across either TCP sockets (on port 3632 by default),
or through a tunnel command such as ssh(1). For TCP connections
the volunteers must run the distccd(1) daemon either directly
or from inetd. For SSH connections distccd must be installed but
should not be listening for connections.
TCP connections should only be used on secure networks because
there is no user authentication or protection of source or object
code. SSH connections are typically 25% slower because of processor
overhead for encryption, although this can vary greatly depending
on CPUs, network and the program being built.
distcc is intended to be used with GNU Make's -j option,
which runs several compiler processes concurrently. distcc spreads
the jobs across both local and remote CPUs. Because distcc is
able to distribute most of the work across the network, a higher
concurrency level can be used than for local builds. As a rule
of thumb, the -j value should be set to about twice the
total number of available server CPUs but subject to client limitations.
This setting allows for maximal interleaving of tasks being blocked
waiting for disk or network IO. Note that distcc can also work
with other build control tools, such as SCons, where similar concurrency
settings must be adjusted.
The -j setting, especially for large values of -j,
must take into account the CPU load on the client. Additional
measures may be needed to curtail the client load. For example,
concurrent linking should be severely curtailed using auxiliary
locks. The effect of other build activity, such as Java compilation
when building mixed code, should be considered. The --localslots_cpp
parameter is by default set to 16. This limits the number of concurrent
processes that do preprocessing in plain distcc (non-pump) mode.
Therefore, larger -j values than 16 may be used without
overloading a single-CPU client due to preprocessing. Such large
values may speed up parts of the build that do not involve C compilations,
but they may not be useful to distcc efficiency in plain mode.
In contrast, using pump mode and say 40 servers, a setting of
-j80 or larger may be appropriate even for single-CPU clients.
It is strongly recommended that you install the same compiler
version on all machines participating in a build. Incompatible
compilers may cause mysterious compile or link failures.
The compiler and assembler take only a single input file (the
preprocessed source) and produce a single output (the object file).
distcc ships these two files across the network and can therefore
run the compiler/assembler remotely.
Fortunately, for most programs running the preprocessor is relatively
cheap, and the linker is called relatively infrequent, so most
of the work can be distributed.
distcc examines its command line to determine which of these phases
are being invoked, and whether the job can be distributed.
In distcc-pump mode, the server unpacks the set of all source
files in a temporary directory, which contains a directory tree
that mirrors the part of the file system that is relevant to preprocessing,
including symbolic links.
The compiler is then run from the path in the temporary directory
that corresponds to the current working directory on the client.
To find and transmit the many hundreds of files that are often
part of a single compilation, pump mode uses an incremental include
analysis algorithm. The include server is a Python program that
implements this algorithm. The pump command starts the include
server so that throughout the build it can answer include queries
by distcc commands.
The include server uses static analysis of the macro language
to deal with conditional compilation and computed includes. It
uses the property that when a given header file has already been
analyzed for includes, it is not necessary to do so again if all
the include options (-I's) are unchanged (along with other conditions).
For large builds, header files are included, on average, hundreds
of times each. With distcc-pump mode each such file is analyzed
only a few times, perhaps just once, instead of being preprocessed
hundreds of times. Also, each source or header file is now compressed
only once, because the include server memoizes the compressed
files. As a result, the time used for preparing compilations
may drop by up to an order of magnitude over the preprocessing
of plain distcc.
Because distcc in pump mode is able to push out files up to about
ten times faster, build speed may increase 3X or more for large
builds compared to plain distcc mode.
The incremental include analysis of distc-pump mode rests on the
fundamental assumption that source and header files do not change
during the build process. A few complex build systems, such as
that for Linux kernel 2.6, do not quite satisfy this requirement.
To overcome such issues, and other corner cases such as absolute
filepaths in includes, see the include_server(1) man page.
Another important assumption is that the include configuration
of all machines must be identical. Thus the headers under the
default system path must be the same on all servers and all clients.
If a standard GNU compiler installation is used, then this requirement
applies to all libraries whose header files are installed under
/usr/include or /usr/local/include/. Note that installing software
packages often lead to additional headers files being placed in
subdirectories of either.
If this assumption does not hold, then it is possible to break
builds with distcc-pump mode, or worse, to get wrong results without
warning. Presently this condition is not verified, and it is
on our TODO list to address this issue.
An easy way to guarantee that the include configurations are identical
is to use a cross-compiler that defines a default system search
path restricted to directories of the compiler installation.
See the include_server(1) manual for more information on
symptoms and causes of violations of distcc-pump mode assumptions.
distcc can be installed under the name of the real compiler, to
intercept calls to it and run them remotely. This "masqueraded"
compiler has the widest compatibility with existing source trees,
and is convenient when you want to use distcc for all compilation.
The fact that distcc is being used is transparent to the makefiles.
distcc can be prepended to compiler command lines, such as "distcc
cc -c hello.c" or CC="distcc gcc". This is convenient
when you want to use distcc for only some compilations or to try
it out, but can cause trouble with some makefiles or versions
of libtool that assume $CC does not contain a space.
Finally, distcc can be used directly as a compiler. "cc"
is always used as the name of the real compiler in this "implicit"
mode. This can be convenient for interactive use when "explicit"
mode does not work but is not really recommended for new use.
Remember that you should not use two methods for calling distcc
at the same time. If you are using a masquerade directory, don't
change CC and/or CXX, just put the directory early on your PATH.
If you're not using a masquerade directory, you'll need to either
change CC and/or CXX, or modify the makefile(s) to call distcc
Then, to use distcc, a user just needs to put the directory /usr/lib/distcc/bin
early in the PATH, and have set a host list in DISTCC_HOSTS or
a file. distcc will handle the rest.
Note that this masquerade directory must occur on the PATH earlier
than the directory that contains the actual compilers of the same
names, and that any auxiliary programs that these compilers call
(such as as or ld) must also be found on the PATH in a directory
after the masquerade directory since distcc calls out to the real
compiler with a PATH value that has all directory up to and including
the masquerade directory trimmed off.
It is possible to get a "recursion error" in masquerade
mode, which means that distcc is somehow finding itself again,
not the real compiler. This can indicate that you have two masquerade
directories on the PATH, possibly because of having two distcc
installations in different locations. It can also indicate that
you're trying to mix "masqueraded" and "explicit"
Recursion errors can be avoided by using shell scripts instead
of links. For example, in /usr/lib/distcc/bin create a file cc
In this way, we are not dependent on distcc having to locate the
real gcc by investigating the PATH variable. Instead, the compiler
location is explicitly provided.
The most reliable method is to set
This tells ccache to run distcc as a wrapper around the real compiler.
ccache still uses the real compiler to detect compiler upgrades.
ccache can then be run using either a masquerade directory
or by setting
As of version 2.2, ccache does not cache compilation from preprocessed
source and so will never get a cache hit if it is run from distccd
or distcc. It must be run only on the client side and before
distcc to be any use.
distcc's pump mode is not compatible with ccache.
The host list is a simple whitespace separated list of host specifications.
The simplest and most common form is a host names, such as
distcc prefers hosts towards the start of the list, so machines
should be listed in descending order of speed. In particular,
when only a single compilation can be run (such as from a configure
script), the first machine listed is used (but see --randomize
Placing localhost at the right point in the list is important
to getting good performance. Because overhead for running jobs
locally is low, localhost should normally be first. However,
it is important that the client have enough cycles free to run
the local jobs and the distcc client. If the client is slower
than the volunteers, or if there are many volunteers, then the
client should be put later in the list or not at all. As a general
rule, if the aggregate CPU speed of the client is less than one
fifth of the total, then the client should be left out of the
If you have a large shared build cluster and a single shared hosts
file, the above rules would cause the first few machines in the
hosts file to be tried first even though they are likely to be
busier than machines later in the list. To avoid this, place
the keyword --randomize into the host list. This will
cause the host list to be randomized, which should improve performance
slightly for large build clusters.
There are two special host names --localslots and
--localslots_cpp which are useful for adjusting load on the
local machine. The --localslots host specifies how many
jobs that cannot be run remotely that can be run concurrently
on the local machine, while --localslots_cpp controls
how many preprocessors will run in parallel on the local machine.
Tuning these values can improve performance. Linking on large
projects can take large amounts of memory. Running parallel linkers,
which cannot be executed remotely, may force the machine to swap,
which reduces performance over just running the jobs in sequence
without swapping. Getting the number of parallel preprocessors
just right allows you to use larger parallel factors with make,
since the local machine now has some mechanism for measuring local
Finally there is the host entry
Performance depends on the details of the source and makefiles
used for the project, and the machine and network speeds. Experimenting
with different settings for the host list and -j factor
may improve performance.
The syntax is
DISTCC_HOSTS = HOSTSPEC ...
HOSTSPEC = LOCAL_HOST | SSH_HOST | TCP_HOST | OLDSTYLE_TCP_HOST
LOCAL_HOST = localhost[/LIMIT]
SSH_HOST = [USER]@HOSTID[/LIMIT][:COMMAND][OPTIONS]
TCP_HOST = HOSTID[:PORT][/LIMIT][OPTIONS]
OLDSTYLE_TCP_HOST = HOSTID[/LIMIT][:PORT][OPTIONS]
HOSTID = HOSTNAME | IPV4 | IPV6
OPTIONS = ,OPTION[OPTIONS]
OPTION = lzo | cpp | auth
GLOBAL_OPTION = --randomize
ZEROCONF = +zeroconf
Here are some individual examples of the syntax:
Here is an example demonstrating some possibilities:
Comments are allowed in host specifications. Comments start with
a hash/pound sign (#) and run to the end of the line.
If a host in the list is not reachable distcc will emit a warning
and ignore that host for about one minute.
Enabling compression makes the distcc client and server use more
CPU time, but less network traffic. The added CPU time is insignificant
for pump mode. The compression ratio is typically 4:1 for source
and 2:1 for object code.
Using compression requires both client and server to use at least
release 2.9 of distcc. No server configuration is required: the
server always responds with compressed replies to compressed requests.
Pump mode requires the servers to have the lzo host option on.
If the compiler name is an absolute path, it is passed verbatim
to the server and the compiler is run from that directory. For
If the compiler name is not absolute, or not fully qualified,
distccd's PATH is searched. When distcc is run from a masquerade
directory, only the base name of the compiler is used. The client's
PATH is used only to run the preprocessor and has no effect on
the server's path.
Both the distcc client and server impose timeouts on transfer
of data across the network. This is intended to detect hosts
which are down or unreachable, and to prevent compiles hanging
indefinitely if a server is disconnected while in use. If a client-side
timeout expires, the job will be re-run locally.
The timeouts are not configurable at present.
distcc can supply extensive debugging information when the verbose
option is used. This is controlled by the DISTCC_VERBOSE
environment variable on the client, and the --verbose
option on the server. For troubleshooting, examine both the client
and server error messages.
distcc distinguishes between "genuine" errors such as
a syntax error in the source, and "accidental" errors
such as a networking problem connecting to a volunteer. In the
case of accidental errors, distcc will retry the compilation locally
unless the DISTCC_FALLBACK option has been disabled.
If the compiler exits with a signal, distcc returns an exit code
of 128 plus the signal number.
distcc internal errors cause an exit code between 100 and 127.
distcc creates a number of temporary and lock files underneath
the temporary directory.
The compilation command passed to distcc must be one that will
execute properly on every volunteer machine to produce an object
file of the appropriate type. If the machines have different
processors, then simply using distcc cc will probably
not work, because that will normally invoke the volunteer's native
Machines with the same CPU but different operating systems may
not necessarily generate compatible .o files.
Several different gcc configurations can be installed side-by-side
on any machine. If you build gcc from source, you should use
the --program-suffix configuration options to cause it
to be installed with a name that encodes the gcc version and the
The recommended convention for the gcc name is TARGET-gcc-VERSION
such as i686-linux-gcc-3.2 . GCC 3.3 will install itself
under this name, in addition to TARGET-gcc and, if it's
native, gcc-VERSION and gcc .
The compiler must be installed under the same name on the client
and on every volunteer machine.
Some makefiles have missing or extra dependencies that cause incorrect
or slow parallel builds. Recursive make is inefficient and can
leave processors unnecessarily idle for long periods. (See
Recursive Make Considered Harmful by Peter Miller.) Makefile
bugs are the most common cause of trees failing to build under
distcc. Alternatives to Make such as SCons can give much
faster builds for some projects.
Using different versions of gcc can cause confusing build problems
because the header files and binary interfaces have changed over
time, and some distributors have included incompatible patches
without changing the version number. distcc does not protect
against using incompatible versions. Compiler errors about link
problems or declarations in system header files are usually due
to mismatched or incorrectly installed compilers.
gcc's -MD option can produce output in the wrong directory
if the source and object files are in different directories and
the -MF option is not used. There is no perfect solution
because of incompatible changes between gcc versions. Explicitly
specifying the dependency output file with -MF will fix
TCP mode connections should only be used on trusted networks.
Including slow machines in the list of volunteer hosts can slow
the build down.
When distcc or ccache is used on NFS, the filesystem must be exported
with the no_subtree_check option to allow reliable renames
The compiler can be invoked with a command line gcc hello.c
to both compile and link. distcc doesn't split this into separate
parts, but rather runs the whole thing locally.
distcc-pump mode reverts to plain distcc mode for source files
that contain includes with absolute paths (either directly or
in an included file).
Due to limitations in gcc, gdb may not be able to automatically
find the source files for programs built using distcc in some
circumstances. The gdb directory command can be used.
For distcc's plain (non-pump) mode, this is fixed in gcc 3.4 and
later. For pump mode, the fix in gcc 3.4 does not suffice; we've
worked around the gcc limitation by rewriting the object files
that gcc produces, but this is only done for ELF object files,
but not for other object file formats.
The .o files produced by discc in pump mode will be different
from those produced locally: for non-ELF files, the debug information
will specify compile directories of the server. The code itself
should be identical.
For the ELF-format, distcc rewrites the .o files to correct compile
directory path information. While the resulting .o files are
not bytewise identical to what would have been produced by compiling
on the local client (due to different padding, etc), they should
be functionally identical.
In distcc-pump mode, the include server is unable to handle certain
very complicated computed includes as found in parts of the Boost
library. The include server will time out and distcc will revert
to plain mode.
In distcc-pump mode, certain assumptions are made that source
and header files do not change during the build. See discussion
in section DISTCC DISCREPANCY SYMPTOMS of include_server(1().
Other known bugs may be documented on http://code.google.com/p/distcc/