LinuxCommandLibrary

distcc

Distribute C/C++/Obj-C compilation over network

TLDR

Compile a source file using a compiler like gcc

$ distcc [gcc] -c [path/to/source.c] -o [path/to/output.o]
copy

Set remote hosts to distribute compilation
$ export DISTCC_HOSTS="localhost [ip1 ip2 ...]"
copy

Compile a project with make using distcc
$ make [[-j|--jobs]] [parallel_jobs] CC="distcc [gcc]"
copy

Show the list of current distcc hosts
$ distcc --show-hosts
copy

Display help
$ distcc --help
copy

Display version
$ distcc --version
copy

SYNOPSIS

distcc [OPTION]... [--] COMPILER [args]...

PARAMETERS

-j N, --jobs N
    Maximum concurrent jobs (default unlimited)

-b HOST, --host HOST
    Add compilation server HOST (comma-separated list)

--daemon [--pidfile FILE] [--user USER] [--log-file FILE] [--port PORT]
    Run as server daemon (use distccd)

--listen ADDR
    Listen on ADDR (IPv4/IPv6) for client connections

--port PORT
    Use PORT for server communication (default 3632)

--allow CIDR
    Permit clients matching CIDR (e.g., 192.168.1.0/24)

--deny CIDR
    Deny clients matching CIDR

--user USER
    Daemon runs as USER (no setuid on client)

--enable-transparent-encryption
    Use Curve25519 encryption (requires distccd 3.3+)

--md5, --hash
    Enable preprocessing hash checks

--no-hash
    Disable hash checks (faster, less safe)

--randomize
    Randomize host selection

--scan-excludes FILE
    Exclude FILE from preprocessing scan

--c++
    Deprecated: assume C++ compiler

--keep
    Do not delete temp files (for debugging)

--verbose
    Print extra diagnostic info

--stats
    Show job statistics

-v, --version
    Display version info

--help
    Show usage summary

DESCRIPTION

Distcc is a fast, free distributed compiler frontend for C, C++, and Objective-C. It dramatically speeds up compilation by outsourcing tasks to idle machines on a network, providing near-linear scaling with additional hosts.

Invoked as a drop-in replacement for gcc or clang (e.g., distcc gcc -c foo.c), distcc parses arguments, selects a remote server, ships preprocessed source code over TCP/IP, compiles remotely with an identical toolchain, and returns the object file. Servers run as the distccd daemon.

Key benefits include massive build acceleration for large projects like the Linux kernel. It requires homogeneous environments (same OS, compiler versions, library paths), a fast LAN (latency <20ms ideal), and NFS/shared storage for headers/objects. Supports up to hundreds of jobs/hosts.

Common usage: prefix PATH with distcc's bin, set DISTCC_HOSTS env var (e.g., localhost/4,host2/2), run make -jN. Integrates with ccache for caching.

CAVEATS

Requires identical compilers/paths across hosts; sensitive to network latency/jitter; no native support for LTO/link-time optimization (use distcc-pump); precompiled headers (.pch/.gch) often fail remotely; security risks if --allow misconfigured; IPv6 support partial.

ENVIRONMENT VARIABLES

DISTCC_HOSTS: Comma-separated servers (e.g., localhost/8,host2/4).
DISTCC_DIR: Working dir (default ~/.distcc).
DISTCC_TMPDIR: Temp files location.
CCACHE_PREFIX=distcc: Integrate with ccache.

SERVER SETUP

Install distcc, run distccd --daemon --user distcc --allow 192.168.1.0/24 --listen 0.0.0.0. Add to init/systemd. Firewall TCP/3632.

PUMP MODE

For distributed linking: PUMP_MODE=1 make CC=distcc gcc .... Requires distcc-pump server; accelerates final link step.

HISTORY

Created by Martin Pool in 2001 as a Python prototype; first C release 2.0 in 2003. Gained popularity for kernel builds. Version 3.0 (2011) added IPv6, compression. Now at 3.4.0 (2023), maintained by distcc community with pump-mode linking enhancements.

SEE ALSO

distccd(1), ccache(1), icecc(1), gcc(1), make(1)

Copied to clipboard