distcc(1)

๐Ÿ“ฆ
version 3.4 ยท 2 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, epel 10, epel 9, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0

๐Ÿ’… distcc(1) ๐Ÿ’…

okay so this is the page for distcc(1) โ€” straight out of the General Commands Manual section, bestie. buckle up, it's a long one but it's literally so worth it ๐Ÿซถ


โœจ NAME โœจ

distcc โ€” distributed C/C++/ObjC compiler with distcc-pump extensions ๐ŸŒˆ


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

distcc <compiler> [COMPILER OPTIONS]

distcc [COMPILER OPTIONS]

<compiler> [COMPILER OPTIONS]

distcc [DISTCC OPTIONS]

๐Ÿ’– DESCRIPTION ๐Ÿ’–

okay so here's the whole vibe: distcc distributes compilation of C code across several machines on a network. and like, it should always generate the same results as a local compile โ€” that's the whole promise, no cap. it's simple to install and use, and it's often much faster than a local compile. slay.

this version incorporates plain distcc as well as an enhancement called pump mode or distcc-pump. two eras, one icon ๐Ÿ’…

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. icon behaviour, fr fr ๐Ÿ”ฅ

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. it's giving group project but everyone actually pulls their weight ๐Ÿ’œ

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. different setups, same energy โœจ

โš ๏ธ 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 slower. like, yes, slower โ€” but at least nobody's reading your source code for fun ๐Ÿ™ˆ

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. multitasking queen ๐Ÿ‘‘

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 8. this limits the number of concurrent processes that do preprocessing in plain distcc (non-pump) mode. therefore, larger -j values than 8 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. main character -j values need main character boundaries, bestie ๐Ÿ’€

in contrast, using pump mode and say 40 servers, a setting of -j80 or larger may be appropriate even for single-CPU clients. she's efficient like that ๐ŸŒธ

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. and "mysterious" is code for "you will cry and not know why" ๐Ÿ˜ญ so like, please, matching versions. it's the bare minimum ๐Ÿซถ


โญ QUICKSTART โญ

  1. for each machine, download distcc, unpack, and install. ๐ŸŽ€
  2. on each of the servers, run distccd --daemon with --allow options to restrict access. keep it exclusive, iykyk ๐Ÿ”ฅ
  3. put the names of the servers in your environment:
$ export DISTCC_HOSTS='localhost red green blue'
  1. build! ๐Ÿ’…
$ make -j8 CC=distcc

๐Ÿฆ‹ QUICKSTART FOR DISTCC-PUMP MODE ๐Ÿฆ‹

proceed as above, but in Step 3, specify that the remote hosts are to carry the burden of preprocessing and that the files sent over the network should be compressed. she's got a whole skincare routine and it's compression โœจ

$ export DISTCC_HOSTS='--randomize localhost red,cpp,lzo
green,cpp,lzo blue,cpp,lzo'

the --randomize option enforces a uniform usage of compile servers. while you will get some benefit from distcc's pump mode with only a few servers, you get increasing benefit with more server CPUs (up to the hundreds!). the way that returns just keep stacking ๐Ÿ‘‘

wrap your build inside the pump command, here assuming 10 servers:

$ pump make -j20 CC=distcc

๐Ÿ’œ QUICKSTART FOR DISTCC-GSSAPI MODE ๐Ÿ’œ

proceed as per the QUICKSTART but in Step 3, specify that the remote hosts are to mutually authenticate with the client. trust issues? solved ๐Ÿซถ

$ export DISTCC_HOSTS='--randomize localhost red,auth green,auth
blue,auth'

if distccd runs under a specific principal name then execute the following command prior to step 4:

export DISTCC_PRINICIPAL=<name>

(that's DISTCC_PRINICIPAL spelled exactly like that โ€” copy it verbatim, don't "fix" it, bestie ๐Ÿ˜ญ)


๐ŸŒธ HOW PLAIN (NON-PUMP) DISTCC WORKS ๐ŸŒธ

distcc only ever runs the compiler and assembler remotely. with plain distcc, the preprocessor 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. everyone stays in their lane โœจ

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. minimal luggage, maximum slay ๐Ÿ’…

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. we love a favourable ratio ๐Ÿ’–

distcc examines its command line to determine which of these phases are being invoked, and whether the job can be distributed. she read the room and made a decision ๐ŸŽ€


๐Ÿ”ฅ HOW DISTCC-PUMP MODE WORKS ๐Ÿ”ฅ

in pump mode, distcc runs the preprocessor remotely too. to do so, the preprocessor must have access to all the files that it would have accessed if had been running locally. in pump mode, therefore, distcc gathers all of the recursively included headers, except the ones that are default system headers, and sends them along with the source file to the compilation server. packing the whole friend group for the trip ๐Ÿงณ

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. a little mini world, a little mirrorverse ๐ŸŒˆ

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. she's answering questions all build long, iconic behaviour honestly ๐Ÿ‘‘

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). memoization! we stan a girl who remembers ๐Ÿ’œ

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. literally ate and left no crumbs ๐Ÿ”ฅ

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. THREE X. bestie. ๐Ÿ˜ญ๐Ÿ’–


๐ŸŽ€ RESTRICTIONS FOR PUMP MODE ๐ŸŽ€

using pump mode requires both client and servers to use release 3.0 or later of distcc and distccd (respectively). no mixing eras, both sides upgrade ๐Ÿ’…

the incremental include analysis of distcc-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. some build systems are just chaotic like that ๐Ÿ™ˆ

โš ๏ธ 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. that's the scary one, fr fr โ€” wrong results with no warning is not the vibe ๐Ÿ˜ญ

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. tidy, contained, no surprises โœจ

see the include_server(1) manual for more information on symptoms and causes of violations of distcc-pump mode assumptions. there's a whole lore drop over there ๐Ÿฆ‹


โญ HOW DISTCC-GSSAPI MODE WORKS โญ

in this mode distcc will use the GSS-API framework to access the currently configured security mechanism and perform mutual authentication with the daemon. mutual. authentication. both parties said yes ๐Ÿซถ๐Ÿ’…


๐Ÿ’… OPTION SUMMARY ๐Ÿ’…

Okay bestie, here's the tea: most options passed to distcc are interpreted as compiler options. The following ones are understood by distcc itself. And real talk: if any of these options are specified, distcc will not invoke the compiler. Periodt. ๐Ÿ’…

  • --help โ€” displays summary instructions. Your lil rescue map. ๐Ÿซถ
  • --version โ€” displays the distcc client version. โœจ
  • --show-hosts โ€” displays the host list that distcc would use. See the Host Specifications section. ๐Ÿ‘€
  • --scan-includes โ€” displays the list of files that distcc would send to the remote machine, as computed by the include server. This is a conservative (over-)approximation of the files that would be read by the C compiler. This option only works in pump mode. See the "How Distcc-pump Mode Works" section for details on how this is computed.

The list output by distcc --scan-includes will contain one entry per line. Each line contains a category followed by a path. The category is one of FILE, SYMLINK, DIRECTORY, or SYSTEMDIR:

  • FILE indicates a source file or header file that would be sent to the distcc server host.
  • SYMLINK indicates a symbolic link that would be sent to the distcc server host.
  • DIRECTORY indicates a directory that may be needed in order to compile the source file. For example, a directory "foo" may be needed because of an include of the form #include "foo/../bar.h". Such directories would be created on the distcc server host.
  • SYSTEMDIR indicates a system include directory, i.e. a directory which is on the compiler's default include path, such as "/usr/include"; such directories are assumed to be present on the distcc server host, and so would not be sent to the distcc server host.
  • -j โ€” displays distcc's concurrency level, as calculated from the host list; it is the maximum number of outstanding jobs issued by this client to all servers. By default this will be four times the number of hosts in the host list, unless the /LIMIT option was used in the host list. See the Host Specifications section. ๐Ÿ”ฅ
  • --show-principal โ€” displays the name of the distccd security principal extracted from the environment. This option is only available if distcc was compiled with the --with-auth configure option. ๐Ÿ”

๐Ÿ› ๏ธ INSTALLING DISTCC ๐Ÿ› ๏ธ

There are three different ways to call distcc, to suit different circumstances. Pick your fighter, bestie:

  1. 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. โœจ
  2. 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. ๐Ÿ˜ฌ
  3. 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 explicitly. No cap. ๐Ÿซถ


๐ŸŽญ MASQUERADING ๐ŸŽญ

The basic idea is to create a "masquerade directory" which contains links 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. Iconic behaviour, honestly. ๐Ÿ’…

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 DISTCC_HOSTS or a file. distcc will handle the rest. Slay. โœจ

To automatically discover compilers and create masquerade links run the provided update-distcc-symlinks script. ๐Ÿงš

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. Big detail, but important. ๐Ÿ‘‘

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" operation. ๐Ÿ’€

Recursion errors can be avoided by using shell scripts instead of links. For example, in /usr/lib/distcc/bin create a file cc which contains:

#!/bin/sh
distcc /usr/bin/gcc "$@"

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. Obsessed with the clarity. ๐ŸŽ€


๐Ÿงธ USING DISTCC WITH CCACHE ๐Ÿงธ

ccache is a program that speeds software builds by caching the results of 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

CCACHE_PREFIX="distcc"

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

CC="ccache gcc"

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. No shortcuts, bestie. ๐Ÿ˜ญ

๐Ÿšจ distcc's pump mode is not compatible with ccache. That incompatibility is real โ€” no cap. ๐Ÿ’€

๐ŸŽ€ HOST SPECIFICATIONS ๐ŸŽ€

Okay so bestie, a "host list" is literally just the list that tells distcc which machines to use for compilation, periodt. And the order distcc checks things is very specific: first $DISTCC_HOSTS environment variable, then the user's $DISTCC_DIR/hosts file, then the system-wide host file. If it can't find a host list anywhere, distcc emits a warning and compiles locally. No drama, it just does it itself. ๐Ÿ’…

The host list is a simple whitespace separated list of host specifications. The simplest and most common form is just host names, like this:

localhost red green blue

distcc prefers hosts towards the start of the list, so you should list machines in descending order of speed. Like, fastest first, bestie. 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 below).

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. BUT โ€” and this is important โ€” the client needs 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. Not me doing math but the math is mathing. ๐Ÿงฎ

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. Slay. ๐Ÿ”ฅ

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 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 resource usage. It's giving resource management icon behavior. ๐Ÿ‘‘

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
                      | GLOBAL_OPTION
                      | ZEROCONF
LOCAL_HOST = localhost[/LIMIT]
           | --localslots=<int>
           | --localslots_cpp=<int>
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[=AUTH_NAME]
GLOBAL_OPTION = --randomize
ZEROCONF = +zeroconf

Here are some individual examples of the syntax:

  • localhost โ€” 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.) Fr fr, just a heads up.
  • IPV6 โ€” A literal IPv6 address enclosed in square brackets, such as [::1].
  • IPV4 โ€” A literal IPv4 address, such as 10.0.0.1.
  • HOSTNAME โ€” A hostname to be looked up using the resolver.
  • :PORT โ€” Connect to a specified decimal port number, rather than the default of 3632.
  • @HOSTID โ€” Connect to the host over SSH, rather than TCP. Options for the SSH connection can be set in ~/.ssh/config.
  • USER@ โ€” Connect to the host over SSH as a specified username.
  • :COMMAND โ€” Connect over SSH, and use a specified path to find the distccd server. This is normally only needed if for some reason you can't install distccd into a directory on the default PATH for SSH connections. Use this if you get errors like "distccd: command not found" in SSH mode. Been there ๐Ÿ˜ญ
  • /LIMIT โ€” A decimal limit can be added to any host specification to restrict the number of jobs that this client will send to the machine. The limit defaults to four per host (two for localhost), but may be further restricted by the server. You should only need to increase this for servers with more than two processors.
  • ,lzo โ€” Enables LZO compression for this TCP or SSH host.
  • ,cpp โ€” Enables distcc-pump mode for this host. Note: the build command must be wrapped in the pump script in order to start the include server. Don't forget, bestie!
  • ,auth โ€” Enables GSSAPI-based mutual authentication for this host.
  • AUTH_NAME โ€” The "canonical" name to use for the service principal name instead of HOSTNAME (or its corresponding fqdn). This option is useful in case of accessing an authenticated server via ssh port forwarding, in which case the HOSTNAME is 127.0.0.1. Very specific little edge case, but she's iconic for it. โœจ
  • --randomize โ€” Randomize the order of the host list before execution.
  • +zeroconf โ€” This option is only available if distcc was compiled with Avahi support enabled at configure time. When this special entry is present in the hosts list, distcc will use Avahi Zeroconf DNS Service Discovery (DNS-SD) to locate any available distccd servers on the local network. This avoids the need to explicitly list the host names or IP addresses of the distcc server machines. The distccd servers must have been started with the "--zeroconf" option to distccd. An important caveat is that in the current implementation, pump mode (",cpp") and compression (",lzo") will never be used for hosts located via zeroconf. ๐Ÿซถ

Here is an example demonstrating some possibilities:

localhost/2 @bigman/16:/opt/bin/distccd oldmachine:4200/1
# cartman is down
distant/3,lzo

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. One minute of silence, she's processing. ๐Ÿ’€


๐ŸŒธ COMPRESSION ๐ŸŒธ

The lzo 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 added CPU time is insignificant for pump mode. The compression ratio is typically 4:1 for source and 2:1 for object code. Numbers! We love a ratio. ๐Ÿ“

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.


๐Ÿฆ‹ SEARCH PATHS ๐Ÿฆ‹

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:

distcc /usr/local/bin/gcc-3.1415 -c hello.c

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. Two completely separate worlds, bestie, don't mix them up. ๐ŸŒˆ


โฐ TIMEOUTS โฐ

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. She's self-sufficient like that. ๐Ÿ’…

The transfer timeout is not configurable at present. The timeout that detects stale distributed job is configurable via DISTCC_IO_TIMEOUT environment variable.


๐Ÿ” 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 DISTCC_VERBOSE environment variable on the client, and the --verbose option on the server. For troubleshooting, examine both the client and server error messages. Both sides, bestie, always both. ๐Ÿ™ˆ


๐Ÿ’€ EXIT CODES ๐Ÿ’€

The exit code of distcc is normally that of the compiler: zero for successful 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 connecting to a volunteer. In the case of accidental errors, distcc will retry the compilation locally unless the DISTCC_FALLBACK option has been disabled. She's forgiving, but only if you let her be.

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 particular:

  • 100 โ€” General distcc failure.
  • 101 โ€” Bad arguments.
  • 102 โ€” Bind failed.
  • 103 โ€” Connect failed.
  • 104 โ€” Compiler crashed.
  • 105 โ€” Out of memory.
  • 106 โ€” Bad Host SPEC
  • 107 โ€” I/O Error
  • 108 โ€” Truncated.
  • 109 โ€” Protocol Error.
  • 110 โ€” The given compiler was not found on the remote host. Check that $CC is set appropriately and that it's installed in a directory on the search path for distccd.
  • 111 โ€” Recursive call to distcc.
  • 112 โ€” Failed to discard privileges.
  • 113 โ€” Network access denied.
  • 114 โ€” In use by another process.
  • 115 โ€” No such file.
  • 116 โ€” No hosts defined and fallbacks disabled.
  • 118 โ€” Timeout.
  • 119 โ€” GSS-API - Catchall error code for GSS-API related errors.
  • 120 โ€” Called for preprocessing, which needs to be done locally.

๐ŸŽ€ FILES ๐ŸŽ€

If $DISTCC_HOSTS is not set, distcc reads a host list from either $DISTCC_DIR/hosts or a system-wide configuration file set at compile time. The file locations are shown in the output from distcc --help. Yes bestie, --help is your bestie here. ๐Ÿซถ

distcc creates a number of temporary and lock files underneath the temporary directory.

๐ŸŒธ ENVIRONMENT VARIABLES ๐ŸŒธ

okay so distcc's whole personality is controlled by a bunch of environment variables, bestie. For most cases literally nothing needs to be set if the host list is chilling in a file. Slay.

  • DISTCC_HOSTS โ€” a space-separated list of volunteer host specifications. That's it, that's the list. ๐Ÿ’…
  • DISTCC_VERBOSE โ€” set it to 1 and distcc starts producing explanatory messages on the standard error stream or in the log file. So helpful for debugging, fr fr. Bug reports should include verbose output, no cap. ๐Ÿ›
  • DISTCC_LOG โ€” the log file that receives messages from distcc itself, instead of stderr. Give your errors somewhere cute to live.
  • DISTCC_FALLBACK โ€” by 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. > heads up: this does not affect jobs which must always be local, such as linking. ๐Ÿ’€
  • DISTCC_NO_CROSS_REWRITE โ€” by default distcc will rewrite calls gcc to use fully qualified names (like x86_64-linux-gnu-gcc), and clang to use the -target option. Setting this turns that off. Bye bye rewrite โœจ
  • DISTCC_BACKOFF_PERIOD โ€” how long (in seconds) distcc will avoid trying to use a particular compilation server after that server yields a compile failure. Default is 60 seconds. Want zero backoff energy? Set it to 0 and the whole behavior is disabled. ๐Ÿ™ˆ
  • DISTCC_IO_TIMEOUT โ€” how long (in seconds) distcc will wait before deciding a distributed job has timed out. If a distributed job is expected to take a long time, consider increasing this value so the job doesn't time out and fallback to a local compile. Default is 300 seconds. โณ
  • DISTCC_PAUSE_TIME_MSEC โ€” how long (in milliseconds) distcc will pause when all compilation servers are in use. Default is 1000 milliseconds (1 second). Setting this to a smaller value (e.g. 10 milliseconds) may improve throughput for some configurations โ€” at the expense of increased CPU load on the distcc client machine. Tradeoffs, bestie, tradeoffs. ๐Ÿ”ฅ
  • DISTCC_SAVE_TEMPS โ€” if set to 1, temporary files are not deleted after use. Good for debugging, or if your disks are too empty. ๐Ÿ˜ญ (imagine having that problem)
  • DISTCC_TCP_CORK โ€” 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. Left. Enabled. ๐Ÿซถ
  • DISTCC_SSH โ€” the command used for opening SSH connections. Defaults to ssh, but may be set to a different connection command such as lsh or tsocks-ssh that accepts a similar command line. The command is not split into words and is not executed through the shell. So don't get cute with it. โœจ
  • DISTCC_SKIP_LOCAL_RETRY โ€” if set, when a remote compile fails, distcc will no longer try to recompile that file locally. No second chances, periodt.
  • DISTCC_DIR โ€” the per-user configuration directory to store lock files and state files. By default ~/.distcc/ is used. ๐ŸŽ€
  • TMPDIR โ€” directory for temporary files such as preprocessor output. By default /tmp/ is used.
  • UNCACHED_ERR_FD โ€” if set and if DISTCC_LOG is not set, distcc errors are written to the file descriptor identified by this variable. This variable is intended mainly for automatic use by ccache, which sets it to avoid caching transient errors such as network problems. iykyk ๐Ÿงš
  • DISTCC_ENABLE_DISCREPANCY_EMAIL โ€” if set, distcc sends an email when a compilation failed remotely, but succeeded locally. Built-in heuristics prevent some such discrepancy email from being sent if the problem is that a local file changed between the failing remote compilation and the succeeding local compilation. It's like, self-aware. ๐Ÿ’œ
  • DISTCC_MAX_DISCREPANCY โ€” the maximum number of remote compilation failures allowed in pump mode before distcc switches to plain distcc mode. By default set to 1.
  • DCC_EMAILLOG_WHOM_TO_BLAME โ€” the email address for discrepancy email; the default is distcc-pump-errors. Blame email, iconic. ๐Ÿ‘‘
  • DISTCC_PRINCIPAL โ€” if set, specifies the name of the principal that distccd runs under, and is used to authenticate the server to the client. This environment variable is only used if distcc was compiled with the --with-auth configure option and the ,auth per host option is specified. ๐Ÿฆ‹

๐ŸŒˆ CROSS COMPILING ๐ŸŒˆ

Cross compilation means building programs to run on a machine with a different processor, architecture, or operating system to where they were compiled. distcc supports cross compilation, including teams of mixed-architecture machines โ€” although some changes to the compilation commands may be required. So yeah, a little homework. ๐Ÿ“š

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 compiler. And like, native compiler on the wrong machine? not the vibe. ๐Ÿ˜ญ

Machines with the same CPU but different operating systems may not necessarily generate compatible .o files. ngl that's just how it is.

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 target platform. Slay, encoded names.

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. Same name, same energy, no exceptions. ๐Ÿ’…


๐Ÿ’€ BUGS ๐Ÿ’€

If you think you have found a distcc bug, please see the file reporting-bugs.txt in the documentation directory for information on how to report it. Do it right, bestie. ๐Ÿ›

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. Like, Make is not always the main character. ๐Ÿ™ˆ

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. So check that first before you spiral. ๐Ÿ˜ญ

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 the problem. ๐Ÿซถ

TCP mode connections should only be used on trusted networks. Fr fr. Do not be out here trusting random networks with your compiles. ๐Ÿšจ

Including slow machines in the list of volunteer hosts can slow the build down. Yes, the one slow friend slows down the whole group chat. ๐Ÿ’€

When distcc or ccache is used on NFS, the filesystem must be exported with the no_subtree_check option to allow reliable renames between directories.

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. It's giving "I'll do it myself." ๐Ÿ’…

distcc-pump mode reverts to plain distcc mode for source files that contain includes with absolute paths (either directly or in an included file). Bye pump mode, hello plain mode.

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, and not for other object file formats. ๐ŸŒธ

The .o files produced by distcc 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. Codes identical, paths not, that's the deal. ๐ŸŽ€

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. Functionally identical is literally the goal, bestie. โœจ

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. Boost said "not today" and honestly? fair. ๐Ÿ˜ญ

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/. Go look, it's all there. ๐Ÿ”ฅ


๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

distcc was written by Martin Pool <mbp@sourcefrog.net>, with the co-operation of many scholars including Wayne Davison, Frerich Raabe, Dimitri Papadopoulos and others noted in the NEWS file. Please report bugs to <distcc@lists.samba.org>. See pump(1) for the authors of pump mode. Shoutout the whole squad, we stan. ๐Ÿซถ


๐ŸŽ€ LICENCE ๐ŸŽ€

You are free to use distcc. distcc (including this manual) may be copied, modified or distributed only under the terms of the GNU General Public Licence version 2 or later. distcc comes with absolutely no warranty. A copy of the GPL is included in the file COPYING. Read it, it's good for you. ๐Ÿ’œ


๐Ÿฆ‹ SEE ALSO ๐Ÿฆ‹


okay that's the entire page, bestie, we did it ๐ŸŽ‰ This was distcc(1) โ€” the source/version is literally just distcc(1), and the date on this whole masterpiece is 9 June 2008. Go compile something iconic. ๐Ÿ’…โœจ๐ŸŒธ