view · edit · print · history

From the homepage at http://distcc.samba.org/, "distcc is a program to distribute builds of C, C++, Objective C or Objective C++ code across several machines on a network. distcc should always generate the same results as a local build, is simple to install and use, and is usually much faster than a local compile."

In theory, distcc should allow you to speed up native builds on the slug dramatically by using other machines on your network. In practice, its use is a bit finicky unless it's set up just right.

  1. CompileCrossTool on all machines you intend to distribute builds to using distcc (I'll call these the servers)
  2. Ensure the cross compiler is in your path on the servers
  3. Download and install distcc (http://distcc.samba.org/binaries.html) on the servers
  4. Build the NativeNSLU2Toolchain on the slug -- this will take a while
  5. Download the make, m4, patch, and distcc ipks (ipkg install make;ipkg install m4;ipkg install patch;ipkg install distcc) to the slug
  6. On the slug, make sure you've got a symlink from gcc to cc in your path (e.g. ln -s /opt/usr/bin/gcc /opt/usr/bin/cc)
  7. Start distcc on each of the servers and the slug (distccd --daemon --allow will restrict compilation to the 192.168.1 network)
  8. On the servers and the slug, export DISTCC_HOSTS='localhost red green blue' where red, green, and blue are the names of the servers. The order in which you place the host names is the order in which distcc will attempt to distribute the load. I would recommend putting the fastest machine first in the list.

In order to make using distcc, you need to feed the -j <#> and CC=distcc options to make. The -j switch takes the number of processes to spawn. If you have four machines as in the above example, -j 4 should work just fine. For example, if you've got a Makefile in /src, you can

  • cd /src
  • make -j 4 CC=distcc

That should be it! As always, correct with wiki if you find any tricks or pitfalls to this process.

On my PC, with optware/nslu2/toolchain built, I did the following:

$ cd ~/slug/optware/nslu2/toolchain/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/armv5b-softfloat-linux/bin
$ ln -s gcc cc
$ cd ~/slug/optware/nslu2
$ mkdir distcc && cd distcc
$ vi distccd.sh
PATH=$NSLU2_HOME/toolchain/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/armv5b-softfloat-linux/bin:$PATH \
    distccd --daemon --allow --log-file=$NSLU2_HOME/distcc/distccd.log
$ chmod +x distccd.sh
$ ./distccd.sh

On my slug, I can then do

$ DISTCC_HOSTS=pc-ip-address make HOSTCC=distcc TARGET_CC=distcc TARGET_CXX='"distcc g++"' target

On my PC, with slugosbe toolchain built (see SlugosbeDevel), I did the following:

$ cd ~/slug/slugosbe/tmp/cross/armeb-linux/bin && ln -s gcc cc
$ cd ~/slug/optware/slugosbe
$ mkdir -p distcc && cd distcc
$ vi distccd.sh
PATH=~/slug/slugosbe/tmp/cross/armeb-linux/bin:$PATH \
    distccd --daemon -p 3633 --allow --log-file=~/slug/optware/slugosbe/distcc/distccd.log
$ chmod +x distccd.sh
$ ./distccd.sh

On my slugosbe slug, I can then do

$ DISTCC_HOSTS=pc-ip-address:3633 make HOSTCC=distcc TARGET_CC=distcc TARGET_CXX='"distcc g++"' target

view · edit · print · history · Last edited by BrianZhou.
Based on work by BrianZhou and bzhou.
Originally by jeremyeglen.
Page last modified on May 15, 2007, at 09:35 PM