Version 1 (modified by Andres Gomez, 11 years ago) (diff)

Initial editing

Speeding up build times


With ccache, you can speed up your compilations by having a way to reuse object files when they do not change across different compilations, thanks to its cache system.

  • Install it in your distro of choice:
    • debian / ubuntu:
      $ sudo apt-get install ccache
  • Fedora:
    $ sudo yum install ccache
  • Make sure it provides wrappers for gcc/g++:
    $ which gcc
    $ which g++
  • If that's not the case you can just create symlinks in a bin directory with precedence over all the other ones, like ~/bin:
    $ mkdir ~/bin
    $ ln -s /usr/bin/ccache gcc
    $ ln -s /usr/bin/ccache g++
    $ export PATH=$(HOME)/bin:$PATH

I personally would recommend to set ccache's cache size to something between 4GB and 8GB:

$ ccache --max-size=8G

Check ccache's stats:

$ ccache -s
cache directory                     /home/user/.ccache
cache hit (direct)                     5
cache hit (preprocessed)               0
cache miss                          3637
called for link                      100
called for preprocessing              14
compile failed                         2
bad compiler arguments                 5
autoconf compile/link                 14
no input file                         12
files in cache                     10880
cache size                         426.5 Mbytes
max cache size                       8.0 Gbytes

distcc (WIP)

With distcc, you can offload your machine from building some files and let distribute the work among other (hopefully more powerful) machines in your local network. Ideally, you should be connected with a wired connection for maximum awesomeness.

To make it work, you need to install the distcc client in your local machine and the distcc server in all the machines that you want to use as remote nodes for your "build farm".

distcc server(s)

You need to install and configure it in every remote machine you want to use from your local machine (the client):

  • Install it in your distro of choice:
    • debian / ubuntu server:
      $ sudo apt-get install distcc
  • Fedora server:
    $ sudo yum install distcc-server
  • Run the server with something like this (will run on port 3632 by default):
    $ distccd --daemon --allow --allow --listen --nice 10 --jobs 12

(You can also configure it to start on boot. Check distcc documentation)

  • Check it's running and listening:
    $ # netstat -nuta | grep LISTEN
       tcp        0      0*               LISTEN     

distcc client

You need to install and configure it in your work local machine:

  • Install it in your distro of choice:
    • debian / ubuntu server:
      $ sudo apt-get install distcc
  • Fedora server:
    $ sudo yum install distcc
  • Make sure you integrate it seamlessly with ccache by defining the CCACHE_PREFIX variable:
    $ export CCACHE_PREFIX=distcc
  • Define the list of hosts (see also "Using a dynamic set of hosts") you want to compile in (order is important, first ones are always preferred):
    $ export DISTCC_HOSTS='remote-powerful-machine localhost'  # DON'T USE but 'localhost' instead!!!
  • Now you just build webkit specifying an "interesting" number in '-j' (typically -j2N, where N is the number of available cores):
    $ Tools/Scripts/build-webkit --makeargs=-j24 --gtk

Some considerations:

  • By default distcc only sends at most *four* jobs per host. If a distcc server can handle more processes you can increase the number like this: DISTCC_HOST='remote-powerful-machine/8'.
  • If the connection to the distcc server is slow you can compress the data: DISTCC_HOST='remote-powerful-machine/8,lzo'. Depending on your case this can actually make things slower, so try first to see if it's worth it in your case.
  • Versions of gcc/g++ should *match* in the client and the servers. Otherwise remote compilation would probably fail, falling back to building locally instead.
  • You need to perform a full rebuild before having distccpower available in webkit. So, you rm -rf WebKitBuild/Release (or Debug) first.
  • It's interesting to have distccmon-gnome installed to check if it's properly distributing the work among the servers.
    • debian / ubuntu:
      $ sudo apt-get install distccmon-gnome
    • Fedora: already included in the distcc package

Using a dynamic set of hosts

This is very useful if you're not working always at the same location. distcc comes with avahi support (at least in Debian) which means that it can automatically discover distccd servers. So instead of defining the DISTCC_HOSTS variable just edit your ~/.distcc/hosts (or /etc/distcc hosts if you want system wide changes) and add something like this:


That will instruct distcc to search for distccd servers using avahi.