Linux command
ccache 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Show cache statistics
ccache -s
Show verbose cache statistics
ccache -sv
Clear the cache
ccache -C
Set maximum cache size
ccache -M [5G]
Show current configuration
ccache -p
Zero statistics counters
ccache -z
Run compiler through ccache
ccache [gcc] -c [file.c]
Set a configuration value
ccache -o [max_size=10G]
Show the cache directory path
ccache -k cache_dir
说明
ccache is a compiler cache that speeds up recompilation by caching previous compilations. When the same compilation is detected, it returns the cached result instead of recompiling. Supports GCC, Clang, MSVC and similar compilers for C, C++, Objective-C, CUDA, and assembler.
参数
- -s, --show-stats
- Show cache statistics summary.
- -sv
- Show verbose statistics including hit/miss details.
- -z, --zero-stats
- Zero statistics counters.
- -C, --clear
- Clear entire cache.
- -M, --max-size _size_
- Set maximum cache size (e.g., 5G, 500M).
- -F, --max-files _count_
- Set maximum number of files in the cache.
- -p, --show-config
- Show current configuration with origins.
- -k, --get-config _key_
- Get a single configuration value.
- -o, --set-config _key=value_
- Set a configuration value persistently.
- -d, --directory _path_
- Operate on specified cache directory instead of the default.
- --cleanup
- Clean up cache to stay within size limit.
- --evict-older-than _age_
- Remove files older than given age (e.g., 30d, 24h).
- -V, --version
- Show version.
FAQ
What is the ccache command used for?
ccache is a compiler cache that speeds up recompilation by caching previous compilations. When the same compilation is detected, it returns the cached result instead of recompiling. Supports GCC, Clang, MSVC and similar compilers for C, C++, Objective-C, CUDA, and assembler.
How do I run a basic ccache example?
Run `ccache -s` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -s, --show-stats do in ccache?
Show cache statistics summary.