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

Minor fix in gold

Speeding up build times


gold is a linker for ELF files present in binutils. gold was developed by Ian Lance Taylor and a small team at Google. The motivation for writing gold was to make a linker that is faster than the GNU linker bfd, especially for large applications coded in C++.

gold is faster and uses less RAM memory than bfd. It is used to link WebKit and its dependencies by many WebKit hackers in a daily basis.

However, have into account that gold is a new linker and that means that you may find into some problems using it every now and then. Specific bugs for gold have already been reported and fixed in WebKit before, like in [94285]. If you get into troubles with the linker when using gold, don't forget to check this list of possible compilation issues and solutions.

  • For using it, install it in your distro of choice:
    • debian / ubuntu:
      $ sudo apt-get install binutils-gold
    • Fedora:
      $ sudo yum install binutils-gold

You may want to check that the default ld binary in the system is the one provided by gold:

$ ls -l /usr/bin/ld
lrwxrwxrwx 1 root root 7 Sep 25  2012 /usr/bin/ld ->


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


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.
    • For example, it has been checked that using distcc through a VPN (OpenVPN) doesn't pay off.
  • 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.