Speeding up compilation times for Libreoffice / C++ projects
But, there was one problem: LibreOffice is huge, and takes a long time to compile (especially for the first time). It took ~40 minutes to build on the best workstation I have access to (a 24 core intel server). It would take more than a day to build on my laptop, and I wanted to be able to build and iterate on my laptop.
The How to Build wiki had a few pointers, and I decided to look into them.
As noted on their website, ccache is a compiler cache, and speeds up compilation by storing stuff, and reusing them on recompilation. This won't decrease the first compile time (in fact, it might increase it), but future compilations would be faster.
To use ccache, I made an exports file (see below) which I source before doing any LibreOffice related stuff. Programs like ondir can help automate this. I decided on a max cache size of 8GB, and set it with:
Icecream enables distributing the compiling load to multiple machines, like distcc. I decided to go with icecream because support for it is built into LibreOffice's autogen.sh.
Using icecream turned out to be as simple as installing and starting services on the build machines, doing
./autogen.sh --enable-icecream, followed by
make. For projects that don't have such icecream flags, its enough to add icecream's bin directory to the beginning of
$PATH, and everything works.
Icecream can do a distributed build even if the machines in the cluster are of different types. This section of their readme gives more information about that.
Building LibreOffice on my laptop using icecream took about 50 minutes (for a clean build).