free hit counter

Thursday, April 19, 2012

cmake and distcc on x86


Lately builds have been taking in excess of 4 minutes on my 3 year old Core2-DUO laptop, but I finally I got around to figuring out how to use distcc with cmake.

Now those 4 minute builds are taking about 50 seconds thanks to distcc. If I ssh into the build server and run the locally, they take 45s.   That's a huge productivity increase for me, but I still need to set it up to do arm cross compiling.

Here's how I did it:

setup on the build server 

install and configure distcc daemon:
sudo apt-get install distcc sudo dpkg-reconfigure distcc

Answer the prompts during reconfigure. Important answers

  • start on startup
  • Allowed client networks: 127.0.0.1 developer-1 developer-2
  • Listen Interfaces: inet address of your internal facing network card
  • Maximum number of concurrent jobs: 2x number of cores for dedicated build machine, 1x for shared workstations



setup on the developer machines

install distcc
sudo apt-get install distcc sudo dpkg-reconfigure distcc

In this case, only allow clients from localhost, and to keep the local host humming I like to set the max number of jobs to .5x the number of cores.

running a build on a developer machine

export DISTCC_HOSTS='build-server-1 localhost'
distccmon-gnome &
CC="distcc gcc" CXX="distcc g++" cmake ../src
make -j8