Version 10 (modified by 11 years ago) ( diff ) | ,
---|
Speeding up build times
gold
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 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
- debian / ubuntu:
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 -> ld.gold
Or you can configure update-alternatives
:
$ update-alternatives --install "/usr/bin/ld" "ld" "/usr/bin/ld.gold" 20 $ update-alternatives --install "/usr/bin/ld" "ld" "/usr/bin/ld.bfd" 10
Then choose the preferred one with the following command:
$ update-alternatives --config ld
Be aware that colorgcc might cause linking issues when using ld.gold.
ccache
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
- debian / ubuntu:
- Make sure it provides wrappers for gcc/g++:
$ which gcc /usr/lib/ccache/gcc $ which g++ /usr/lib/ccache/g++
- If that's not the case you can prepend
/usr/lib/ccache/
to PATH:$ export PATH=/usr/lib/ccache/:$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
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
- debian / ubuntu server:
- Run the server with something like this (will run on port 3632 by default):
$ distccd --daemon --allow 127.0.0.1 --allow 192.168.10.0/24 --listen 192.168.10.107 --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 192.168.10.107:3632 0.0.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
- debian / ubuntu server:
- 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 127.0.0.1 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
- debian / ubuntu:
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:
+zeroconf localhost
That will instruct distcc to search for distccd servers using avahi.
icecc
Icecream was created by SUSE based on distcc. Like distcc, Icecream takes compile jobs from a build and distributes it among remote machines allowing a parallel build. But unlike distcc, Icecream uses a central server that dynamically schedules the compile jobs to the fastest free server. This advantage pays off mostly for shared computers, if you're the only user on x machines, you have full control over them.
icecc scheduler
- Install it:
$ sudo apt-get install icecc
- Configure scheduler to start by default (see
/usr/share/doc/icecc/README.Debian
):$ sudo update-rc.d icecc-scheduler enable
Some considerations:
- You should have only one scheduler in your network.
- The scheduler and one of the daemons can be in the same host.
icecc daemon(s)
- Install it:
$ sudo apt-get install icecc
- You can install icecc monitor too:
$ sudo apt-get install icecc-monitor
- Make sure you integrate it seamlessly with ccache by defining the CCACHE_PREFIX variable:
$ export CCACHE_PREFIX=icecc
- Make sure you have your PATH properly configured:
$ export PATH=/usr/lib/ccache:$PATH
- You can increase the number of jobs setting the MAKE variable:
$ export MAKE="make -j12"
- Then compile WebKit normally:
$ Tools/Scripts/build-webkit --gtk