Skip to content

Instantly share code, notes, and snippets.

@JDevlieghere
Last active November 13, 2017 10:27
Show Gist options
  • Save JDevlieghere/e03a904b83414674d2c40ef3d67845e2 to your computer and use it in GitHub Desktop.
Save JDevlieghere/e03a904b83414674d2c40ef3d67845e2 to your computer and use it in GitHub Desktop.

Distributed Builds

Start by installing distcc using homebrew on your local machine and all the machines you want to use for distributed builds.

brew install distcc

The only requirement for the build machines is that they run the same operating system and generate compatible object files. The source files are preprocessed on your local machines before being dispatched. This is different when using "pump" mode but unless you have a lot of builders it is not really relevant.

Local Machine Configuration

On your local machine, create the following file:

~/.distcc/hosts

For every build machine, add its IP followed by its number of cores, separated by a slash. You can specify lzo compression for every machine as well. An example of the file is given below.

--localslots_cpp=32
--randomize
192.168.1.1/8,lzo
192.168.1.2/8,lzo
192.168.1.3/8,lzo
192.168.1.4/8,lzo

The first directive (--localslots_cpp=32) tells distcc to use 32 threads for preprocessing the files. You'll want to tweak this based on the amount of CPUs and RAM you have available on your host machine.

The next directive (--randomize) says to randomize between the builders. If you want to include your local machine, you should specify it above this, so that works is assigned to your local machine first.

Next, tell ccache to prefix every invocation with distcc if the previously created file exists.

if test -e ~/.distcc/hosts
  if type -p distcc >/dev/null 2>&1
    set -x CCACHE_PREFIX "distcc"
  end
end

Finally, run the distcc deamon locally. You'll need this regardless of whether you're compiling locally, because it is responsible for actually dispatching work to the builders.

distccd --daemon --allow 127.0.0.1

Build Machine Configuration

Setting up a builder is extremely easy. All you have to do is start the deamon and tell it to accept connections from a certain range of IP-addresses.

distccd --daemon --allow 192.168.0.0/16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment