Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to speed up recompilation with ccache

📅 2016-Mar-08 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ ccache, cpp, gcc ⬩ 📚 Archive

C++ compilation of large projects takes forever. One trick to speed it up is to cache previous compilations. When a compilation unit and its compilation options exactly match an earlier one, the result from the cache can be used directly. Such a compilation cache can reduce compilation times enormously (by orders of magnitude) on a machine where you build several times a day. CCache is an implementation of such a compilation cache for C and C++ compilation using GCC compilers.

$ sudo apt install ccache
$ ccache --show-stats
$ ccache --clear

CCache is so easy to use and its benefits are so bountiful that I highly recommend using it if you are a C or C++ programmer.

(Thanks to this post for introducing me to ccache and you can also find some speedup metrics of using ccache in it.)

Tried with: CCache 3.1.9 and Ubuntu 14.04