XMLTagsEditHistoryDiscussion

The following instructions are for Debian and they might work for Ubuntu as well.

Motivation

Some theory

You might want to use ccache and distcc all the time, even if you compile only from a single machine. This way, you can add nodes to the cluster anytime and the cache will be valid when you compile with a single processor some other time.

This is especially useful if you have a laptop.

Installing

In the front-end machine:

 aptitude install ccache distcc gcc g++

In the nodes:

 aptitude install distgcc gcc g++

Configuring ccache

The first thing to set is the maximum cache size. The more, the better. For me a few gigabytes are more than enough. If need to cache a few kernel compilations, it will be enough.

$ ccache --max-size 5G

You can check statistics anytime you like with ccache -s.

$ ccache -s
cache directory                     /home/galactus/.ccache
cache hit                              0
cache miss                             0
files in cache                     43454
cache size                         265.9 Mbytes
max cache size                       3.0 Gbytes

Configuring distcc

In the compilation nodes, make sure that your computer is allowed to use distcc. To configure it use:

dpkg-reconfigure distcc

The environment

In the front-end machine, you might want to use something like the following environment:

# When You're alone
# export DISTCC_HOSTS=localhost

# When you use the cluster
# Faster machines first.
export DISTCC_HOSTS="192.168.1.2 192.168.1.3 192.168.1.4 localhost"
export CCACHE_PREFIX="distcc"
#If you don't want to cache the compilation results
#export  CCACHE_DISABLE.  

An example

This is an example of what you would need to do to use ccache with the Linux kernel.

--- Makefile.old        2007-05-30 10:07:00.000000000 -0500
+++ Makefile    2007-05-30 10:07:49.000000000 -0500
@@ -195,8 +195,8 @@
          else if [ -x /bin/bash ]; then echo /bin/bash; \
          else echo sh; fi ; fi)
 
-HOSTCC       = gcc
-HOSTCXX      = g++
+HOSTCC       = ccache gcc
+HOSTCXX      = ccache g++
 HOSTCFLAGS   = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
 HOSTCXXFLAGS = -O2
 
@@ -281,7 +281,7 @@
 
 AS             = $(CROSS_COMPILE)as
 LD             = $(CROSS_COMPILE)ld
-CC             = $(CROSS_COMPILE)gcc
+CC             = ccache $(CROSS_COMPILE)gcc
 CPP            = $(CC) -E
 AR             = $(CROSS_COMPILE)ar
 NM             = $(CROSS_COMPILE)nm

In this example, we used cross-compiler.

In order to use all the nodes in the cluster, you need to call make with the "-j" flag. For instance:

crossmake -j5 vmlinux

Last update: 2007-06-03 (Rev 308)

svnwiki $Rev: 12966 $