Distcc - Distributed Compilation Tool for Developers

Learn how to install and use Distcc for distributed compilation. Optimize your build process with this powerful tool for developers.

Distcc - Distributed Compilation Tool

Distcc is a tool that allows you to distribute your C/C++ compilation jobs across multiple machines on a network. This can significantly speed up build times, especially for large projects. This page provides essential commands for installing and using Distcc effectively.

Distcc Installation and Configuration

To get started with Distcc, you need to configure it on your build server(s). This involves editing the /etc/default/distcc file to set up crucial variables.

# INSTALL
# ==============================================================================
# Edit /etc/default/distcc and set theses vars
# STARTDISTCC="true"
# ALLOWEDNETS="127.0.0.1 192.168.1.0/24"# Your computer and local computers
# #LISTENER="127.0.0.1"# Comment it
# ZEROCONF="true"# Auto configuration

# REMEMBER 1:
# Start/Restart your distccd servers before using one of these commands.
# service distccd start

# REMEMBER 2:
# Do not forget to install on each machine DISTCC.
# No need to install libs ! Only main host need libs !

Distcc Usage Examples

Once Distcc is installed and configured, you can leverage its power in your build processes. Here are common usage scenarios for distributed compilation.

Using Distcc with ZeroConf

This command demonstrates how to run make with 4 threads using Distcc in an auto-configuration mode (ZeroConf). It's ideal for networks where hosts can be discovered automatically.

# USAGE
# ==============================================================================

# Run make with 4 thread (a cross network) in auto configuration.
# Note: for gcc, Replace CXX by CC and g++ by gcc
ZEROCONF='+zeroconf' make -j4 CXX='distcc g++'

Using Distcc with Static Host Configuration

For a more controlled setup, you can specify the hosts explicitly. This example shows how to run make with 4 threads using Distcc with a static list of IP addresses.

# Run make with 4 thread (a cross network) in static configuration (2 ip)
# Note: for gcc, Replace CXX by CC and g++ by gcc
DISTCC_HOSTS='127.0.0.1 192.168.1.69' make -j4 CXX='distcc g++'

Showing Available Distcc Hosts

To verify which hosts are available for distributed compilation, you can use the --show-hosts command.

# Show hosts aviables
ZEROCONF='+zeroconf' distcc --show-hosts

Benefits of Distributed Compilation

Employing tools like Distcc for distributed compilation offers several advantages:

  • Faster Build Times: Distributes the workload across multiple machines, reducing the overall compilation duration.
  • Resource Optimization: Utilizes idle CPU resources on other machines in the network.
  • Scalability: Easily scale your build infrastructure by adding more machines to the compilation pool.

For more in-depth information on Distcc and its advanced configurations, refer to the official documentation.

External Resources: