News
- 2024-07-22: Version 4.10.2 has been released
- 2024-06-30: Version 4.10.1 has been released
- 2024-05-29: Version 4.10 has been released
- 2024-02-05: Version 4.9.1 has been released
- 2023-12-30: Version 4.9 has been released
- 2023-08-29: Version 4.8.3 has been released
- 2023-06-12: Version 4.8.2 has been released
- 2023-05-19: Version 4.8.1 has been released
- 2023-03-20: Version 4.7.5 has been released
- 2023-03-12: Version 4.8 has been released
- All news
About
Ccache is a compiler cache. It speeds up recompilation by caching previous compilations and detecting when the same compilation is being done again. Ccache is free software, released under the GNU General Public License version 3 or later. See also the license page.
Latest release: version 4.10.2
Features
- Supports GCC, Clang, MSVC (Microsoft Visual C++) and other similar compilers[1]. (details)
- Works on Linux, macOS, other Unix-like operating systems[1] and Windows[1]. (details)
- Understands C, C++, assembler, CUDA, Objective-C[1] and Objective-C++[1]. (details)
- Supports remote caching over HTTP (e.g. using Nginx or Google Cloud Storage), Redis or NFS, optionally sharding data onto a server cluster. (details)
- Supports fast "direct" and "depend" modes that don't rely on using the preprocessor. (details)
- Uses an inode cache to avoid having to hash the same header files repeatedly during a build (on supported OSes and file systems). (details)
- Supports compression using Zstandard.
- Checksums cache content using XXH3 to detect data corruption.
- Keeps statistics on hits/misses. (details)
- Automatic cache size management. (details)
- Easy installation. (details)
- Low overhead. (details)
- Support for rewriting absolute paths to relative in order to increase the cache hit ratio. (details)
- Optionally uses file cloning (AKA “reflinks”) where possible to avoid copies.
- Optionally uses hard links where possible to avoid copies.
[1] Might have limited support — see supported platforms, compilers and languages.
Limitations
- Only knows how to cache the compilation of a single file. Other types of compilations (multi-file compilation, linking, etc) will silently fall back to running the real compiler.
- Some compiler flags are not supported. If such a flag is detected, ccache will silently fall back to running the real compiler.
- The fastest mode (the "direct mode") has a corner case which can result in false positive cache hits. This and other minor limitations are listed under caveats in the manual.
Why bother?
If you ever run make clean; make
, you can probably benefit from
ccache. It is common for developers to do a clean build of a project for a
whole host of reasons, and this throws away all the information from your
previous compilations. By using ccache, recompilation goes much faster.
Another reason to use ccache is that the same cache is used for builds in different directories. If you have several versions or branches of a software stored in different directories, many of the object files in a build directory can probably be taken from the cache even if they were compiled for another version or branch.
A third scenario is using ccache to speed up clean builds performed by servers or build farms that regularly check that the code is buildable.
You can also share the cache between users, which can be very useful on shared compilation servers.
Is it safe?
The most important aspect of a compiler cache is to always produce exactly the same output that the real compiler would produce. This includes providing exactly the same object files and exactly the same compiler warnings that would be produced if you use the real compiler. The only way you should be able to tell that you are using ccache is the speed.
Ccache of course tries to provide these guarantees. However:
- Compilers are moving targets. Newer compiler versions may, and often do, introduce features that ccache can't foresee. In some cases it's also very hard for ccache to handle the compiler behaviors in a good way, especially in a way that is backward compatible with legacy compilers.
- The fastest mode (the "direct mode") has a corner case which can result in false positive cache hits. This and other minor limitations are listed under caveats in the manual.
If you experience any bugs or undocumented limitations, please report them.