AI Summary 146.20562.2 ccache windows摘要 2026-10-10
ccache windows gcc/g++的c语言编译器缓存 高速缓存编译生成的信息 编译的特定部分使用高速缓存的信息,如头文件,节省通常使用 cpp 解析这些信息所需要的时间 如某头文件中包含对其他头文件的引用,ccache会用那个文件的 cpp-parsed版本来取代include声明,不是真正去读取、理解并解释其内容,

ccache windows

ccache works on Windows via official prebuilt binaries such as ccache‑4.14.1‑windows‑x86_64.zip

which you can download from the ccache releases page, extract, add to PATH, and optionally configure as a compiler launcher for GCC/Clang/MSVC

1. What ccache is

ccache is a compiler cache that speeds up C/C++ recompilation by reusing previous compilation results.

It supports GCC, Clang, and MSVC on Windows.

ccache

compiler cache

ccache 只是将最终的文本拷贝到文件中,立即被编译

ccache是以空间换取速度,ccache非常适合经常

make clean(或删除out目录)后重新编译的情况

ccache能做什么

项目工程 一次代码修改仅会改变极少量的源文件,使用ccache只会重新编译修改部分的代码相关的源文件

而未进行修改的源文件则可以直接使用缓存优化了编译时长

https://github.com/ccache/ccache/releases

2. Downloading ccache for Windows

https://github.com/ccache/ccache/releases/download/v4.14.1/ccache-4.14.1-windows-x86_64.zip

Official Windows binary: ccache‑4.14.1‑windows‑x86_64.zip from the ccache download page.

3. Installation Steps

Step 1 — Extract

Unzip the downloaded archive to a directory such as:

C:\c\ccache-4.14.1-windows-x86_64

Step 2 — Add to PATH

Add the directory to:

System Properties → Advanced → Environment Variables → PATH

Then verify

ccache --version

PS C:\c> ccache --version

ccache version 4.14.1

Features: avx2 crsh-storage file-storage http-storage redis+unix-storage redis-storage remote-storage

Copyright (C) 2002-2007 Andrew Tridgell

Copyright (C) 2009-2026 Joel Rosdahl and other contributors

See <https://ccache.dev/credits.html> for a complete list of contributors.

This program is free software; you can redistribute it and/or modify it under

the terms of the GNU General Public License as published by the Free Software

Foundation; either version 3 of the License, or (at your option) any later

version.

4. Integrating with Compilers

Option A — Symbolic links (recommended)

Create links so build systems automatically use ccache:

New-Item -ItemType SymbolicLink -Name "gcc.exe" -Target "ccache.exe"

New-Item -ItemType SymbolicLink -Name "g++.exe" -Target "ccache.exe"

Option B — Environment variables

set CC=ccache gcc

set CXX=ccache g++

(Effective only for the current shell.)

Option C — CMake integration

Add to CMake options:

-DCMAKE_C_COMPILER_LAUNCHER=ccache

-DCMAKE_CXX_COMPILER_LAUNCHER=ccache

5. Optional Configuration

Set cache directory:

ccache --set-config=cache_dir=D:\ccache_cache

Set max cache size:

ccache --set-config=max_size=10G

View stats:

ccache -s

6. Usage Notes

First build compiles normally; subsequent builds reuse cached results.

Works well for large C/C++ and AI framework builds (e.g., PaddlePaddle, PyTorch).

Supports direct and depend modes for faster hashing.

ccache on Windows provides the same caching benefits as on Linux,

enabling significantly faster rebuilds for C/C++ projects.