NAME
distcc - distributed C/C++/ObjC compiler
SYNOPSIS
ddiissttcccc
[COMPILER OPTIONS] ddiissttcccc [COMPILER OPTIONS]
<
> [COMPILER OPTIONS] DESCRIPTION
distcc distributes compilation of C code across several machines on a
network. distcc should always generate the same results as a local
compile, is simple to install and use, and is often much faster than a local compile.distcc sends the complete preprocessed source code and compiler argu-
ments across the network for each job, so the machines do not need to share a filesystem, have the same headers or libraries installed, or have synchronized clocks. Compilation is driven by a "client" machine, which is typically thedeveloper's workstation or laptop. The distcc client runs on this
machine, as does make, the preprocessor, the linker, and other stages of the build process. Any number of "volunteer" machines help theclient to build the program, by running the ddiissttccccdd((11)) daemon, C com-
piler 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 vol-
unteers must run the distccd(1) daemon either directly or from inetd.
For SSH connections distccd must be installed but should nnoott be listen-
ing for connections. TCP connections should only be used on secure networks because there is no user authentication or protection of source or object code. SSHconnections 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 -jj option, which runs
several compiler processes concurrently. distcc spreads the jobs
across both local and remote CPUs. Because distcc is able to distrib-
ute most of the work across the network a higher concurrency level canbe used than for local builds. The -jj value should normally be set to
about twice the total number of available CPUs, to allow for some tasksbeing blocked waiting for disk or network IO. distcc can also work
with other build control tools such as SCons. 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. QQUUIICCKKSSTTAARRTT1 For each machine, download distcc, unpack, and install.
2 On each of the servers, run ddiissttccccdd --ddaaeemmoonn optionally with
--aallllooww options to restrict access.
3 Put the names of the servers in your environment:$ export DISTCCHOSTS='localhost red green blue'
4 Build!$ make -j8 CC=distcc
HHOOWW IITT WWOORRKKSSdistcc only ever runs the compiler and assembler remotely. The pre-
processor must always run locally because it needs to access various header files on the local machine which may not be present, or may not be the same, on the volunteer. The linker similarly needs to examine libraries and object files, and so must run locally.The compiler and assembler take only a single input file (the prepro-
cessed source) and produce a single output (the object file). distcc
ships these two files across the network and can therefore run the com-
piler/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. OOPPTTIIOONN SSUUMMMMAARRYYMost options passed to distcc are interpreted as compiler options. Two
options are understood by distcc itself:
--hheellpp Displays summary instructions.
--vveerrssiioonn
Displays the distcc client version.
IINNSSTTAALLLLIINNGG DDIISSTTCCCCThere are three different ways to call distcc, to suit different cir-
cumstances: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 sourcetrees, 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 oflibtool 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/orCXX, or modify the makefile(s) to call distcc explicitly.
MMAASSQQUUEERRAADDIINNGG The basic idea is to create a "masquerade directory" which containslinks from the name of the real compiler to the distcc binary. This
directory is inserted early on the PATH, so that calls to the compilerare intercepted and distcc is run instead. distcc then removes itself
from the PATH to find the real compiler. For example:# mkdir /usr/lib/distcc/bin
# cd /usr/lib/distcc/bin
# ln -s ../../../bin/distcc gcc
# ln -s ../../../bin/distcc cc
# ln -s ../../../bin/distcc g++
# ln -s ../../../bin/distcc c++
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
DISTCCHOSTS 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 masqueradedirectory 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, whichmeans that distcc is somehow finding itself again, not the real com-
piler. This can indicate that you have two masquerade directories onthe PATH, possibly because of having two distcc installations in dif-
ferent locations. It can also indicate that you're trying to mix "mas-
queraded" and "explicit" operation. UUSSIINNGG DDIISSTTCCCC WWIITTHH CCCCAACCHHEE ccache is a program that speeds software builds by caching the resultsof compilations. ccache is normally called before distcc, so that
results are retrieved from a normal cache. Some experimentation may be required for idiosyncratic makefiles to make everything work together. The most reliable method is to set CCCCAACCHHEEPPRREEFFIIXX==""ddiissttcccc""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 set-
ting CCCC==""ccccaacchhee ggcccc"" As of version 2.2, ccache does not cache compilation from preprocessedsource 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. HHOOSSTT SSPPEECCIIFFIICCAATTIIOONNSSA "host list" tells distcc which machines to use for compilation. In
order, distcc looks in the $$DDIISSTTCCCCHHOOSSTTSS environment variable, the
user's $$DDIISSTTCCCCDDIIRR//hhoossttss file, and the system-wide host file. If no
host list can be found, distcc emits a warning and compiles locally.
The host list is a simple whitespace separated list of host specifica-
tions. The simplest and most common form is a host names, such as llooccaallhhoosstt rreedd ggrreeeenn bblluueedistcc 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.Placing localhost at the right point in the list is important to get-
ting good performance. Because overhead for running jobs locally is low, localhost should normally be first. However, it is important thatthe 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 list. Performance depends on the details of the source and makefiles used for the project, and the machine and network speeds. Experimenting withdifferent settings for the host list and -j factor may improve perfor-
mance. The syntax is DISTCCHOSTS = HOSTSPEC ... HOSTSPEC = LOCALHOST | SSHHOST | TCPHOST | OLDSTYLETCPHOST LOCALHOST = localhost[/LIMIT]SSHHOST = [USER]@HOSTID[/LIMIT][:COMMAND][OPTIONS]
TCPHOST = HOSTID[:PORT][/LIMIT][OPTIONS]
OLDSTYLETCPHOST = HOSTID[/LIMIT][:PORT][OPTIONS]
HOSTID = HOSTNAME | IPV4
OPTIONS = ,OPTION[OPTIONS]
OPTION = lzo
Here are some individual examples of the syntax: llooccaallhhoosstt The literal word "localhost" is interpreted specially to cause compilations to be directly executed, rather than passed to a daemon on the local machine. If you do want to connect to a daemon on the local machine for testing, then give the machine's IP address or real hostname. (This will be slower.) IIPPVV44 A literal IPv4 address, such as 1100..00..00..11HOSTNAME
A hostname to be looked up using the resolver. ::PPOORRTT Connect to a specified decimal port number, rather than the default of 3632. @@HHOOSSTTIIDD Connect to the host over SSH, rather than TCP. Options for the SSH connection can be set in ~~//..sssshh//ccoonnffiigg UUSSEERR@@ Connect to the host over SSH as a specified username. ::CCOOMMMMAANNDDConnect over SSH, and use a specified path to find the distccd
server. This is normally only needed if for some reason youcan't install distccd into a directory on the default PATH for
SSH connections. Use this if you get errors like "distccd: com-
mand not found" in SSH mode. //LLIIMMIITT A decimal limit can be added to any host specification to restrict the number of jobs that this client will send to themachine. The limit defaults to four per host (two for local-
host), but may be further restricted by the server. You shouldonly need to increase this for servers with more than two pro-
cessors. ,,llzzoo Enables LZO compression for this TCP or SSH host. Here is an example demonstrating some possibilities: llooccaallhhoosstt//22 @@bbiiggmmaann//1166:://oopptt//bbiinn//ddiissttccccdd oollddmmaacchhiinnee::44220000//11## ccaarrttmmaann iiss ddoowwnn
ddiissttaanntt//33,,llzzoo Comments are allowed in host specifications. Comments start with ahash/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. CCOOMMPPRREESSSSIIOONN The llzzoo host option specifies that LZO compression should be used for data transfer, including preprocessed source, object code and error messages. Compression is usually economical on networks slower than 100Mbps, but results may vary depending on the network, processors and source tree.Enabling compression makes the distcc client and server use more CPU
time, but less network traffic. 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 leastrelease 2.9 of distcc. No server configuration is required: the server
always responds with compressed replies to compressed requests. SSEEAARRCCHH PPAATTHHSS If the compiler name is an absolute path, it is passed verbatim to the server and the compiler is run from that directory. For example:ddiissttcccc //uussrr//llooccaall//bbiinn//ggcccc-33..11441155 -cc hheelllloo..cc
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. TTIIMMEEOOUUTTSSBoth 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 serveris disconnected while in use. If a client-side timeout expires, the
job will be re-run locally.
The timeouts are not configurable at present. DIAGNOSTICS Error messages or warnings from local or remote compilers are passed through to diagnostic output on the client.distcc can supply extensive debugging information when the verbose
option is used. This is controlled by the DDIISSTTCCCCVVEERRBBOOSSEE environmentvariable on the client, and the --vveerrbboossee option on the server. For
troubleshooting, examine both the client and server error messages. EEXXIITT CCOODDEESSThe exit code of distcc is normally that of the compiler: zero for suc-
cessful compilation and non-zero otherwise.
distcc distinguishes between "genuine" errors such as a syntax error in
the source, and "accidental" errors such as a networking problem con-
necting to a volunteer. In the case of accidental errors, distcc will
retry the compilation locally unless the DISTCCFALLBACK 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. In par-
ticular100 General distcc failure.
105 Out of memory. 110 Compiler not found.111 Recursive call to distcc.
116 No hosts defined and fallbacks disabled. (Others are listed in exitcode.h.) FILESIf $DISTCCHOSTS is not set, distcc reads a host list from either
$$DDIISSTTCCCCDDIIRR//hhoossttss or a system-wide configuration file set at compile
time. The file locations are shown in the output from ddiissttcccc --hheellpp
distcc creates a number of temporary and lock files underneath the tem-
porary directory. ENVIRONMENT VARIABLESdistcc's behaviour is controlled by a number of environment variables.
For most cases nothing need be set if the host list is stored in a file. DDIISSTTCCCCHHOOSSTTSSSpace-separated list of volunteer host specifications.
DDIISSTTCCCCVVEERRBBOOSSEEIf set to 1, distcc produces explanatory messages on the stan-
dard error stream or in the log file. This can be helpful in debugging problems. Bug reports should include verbose output. DDIISSTTCCCCLLOOGGLog file to receive messages from distcc itself, rather than
stderr. DDIISSTTCCCCFFAALLLLBBAACCKKBy default distcc will compile locally if it fails to distribute
a job to the intended machine, or if no host list can be found. If this variable is set to 0 then fallbacks are disabled and those compilations will simply fail. Note that this does not affect jobs which must always be local such as linking. DDIISSTTCCCCSSAAVVEETTEEMMPPSS If set to 1, temporary files are not deleted after use. Good for debugging, or if your disks are too empty. DDIISSTTCCCCTTCCPPCCOORRKK If set to 0, disable use of "TCP corks", even if they're present on this system. Using corks normally helps pack requests into fewer packets and aids performance. This should normally be left enabled. DDIISSTTCCCCSSSSHH Specifies the command used for opening SSH connections.Defaults to "ssh" but may be set to a different connection com-
mand such as "lsh" or "tsocks-ssh" that accepts a similar com-
mand line. The command is not split into words and is not exe-
cuted through the shell. DDIISSTTCCCCDDIIRRPer-user configuration directory to store lock files and state
files. By default //vvaarr//ttmmpp//ddiissttcccc..{{UUIIDD}}// is used. TTMMPPDDIIRR Directory for temporary files such as preprocessor output. Bydefault /tmp/distcc is used.
UUNNCCAACCHHEEDDEERRRRFFDDIf set and if DISTCCLOG is not set, distcc errors are written
to the file descriptor identified by this variable. This vari-
able is intended mainly for automatic use by ccache, which sets it to avoid caching transient errors such as network problems. CCRROOSSSS CCOOMMPPIILLIINNGG Cross compilation means building programs to run on a machine with a different processor, architecture, or operating system to where theywere compiled. distcc supports cross compilation, including teams of
mixed-architecture machines, although some changes to the compilation
commands may be required.The compilation command passed to distcc must be one that will execute
properly on every volunteer machine to produce an object file of theappropriate type. If the machines have different processors, then sim-
ply using ddiissttcccc cccc will probably not work, because that will normally invoke the volunteer's native compiler.Machines with the same CPU but different operating systems may not nec-
essarily 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 --pprroo-
ggrraamm-ssuuffffiixx ccoonnffiigguurraattiioonn options to cause it to be installed with a
name that encodes the gcc version and the target platform.The recommended convention for the gcc name is TARGET-gcc-VERSION such
as ii668866-lliinnuuxx-ggcccc-33..22 . 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.BUGS
If you think you have found a distcc bug, please see the file report-
ing-bugs.txt in the documentation directory for information on how to
report it. 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 commoncause 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 chang-
ing the version number. distcc does not protect against using incom-
patible versions. Compiler errors about link problems or declarations in system header files are usually due to mismatched or incorrectly installed compilers. Due to limitations in gcc, gdb may not be able to automatically findthe source files for programs built using distcc in some circumstances.
The gdb ddiirreeccttoorryy command can be used. This should be fixed in gcc 3.4.gcc's -MMDD option can produce output in the wrong directory if the
source and object files are in different directories and the -MMFF option
is not used. There is no perfect solution because of incompatible changes between gcc versions. Explicitly specifying the dependencyoutput file with -MMFF will fix the problem.
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 nnoossuubbttrreeeecchheecckk option to allow reliable renames between directories. The compiler can be invoked with a command line ggcccc hheelllloo..cc to bothcompile and link. distcc doesn't split this into separate parts, but
rather runs the whole thing locally.Other known bugs may be documented on http://distcc.samba.org/
AUTHORdistcc was written by Martin Pool
, with the co- operation of many scholars including Wayne Davison, Frerich Raabe, Dim-
itri Papadopoulos and others noted in the NEWS file. Please reportbugs to
LLIICCEENNCCEE. You are free to use distcc. distcc (including this manual) may be
copied, modified or distributed only under the terms of the GNU GeneralPublic Licence version 2 or later. distcc comes with absolutely no
warrany. A copy of the GPL is included in the file COPYING.SEE ALSO
distccd(1), ccache(1), gcc(1), make(1) http://distcc.samba.org/
http://ccache.samba.org/28 July 2004 distcc(1)