我们的系统支持使用三种不同的工具链(gcc、icc、diab)构建。我不确定在这种情况下使用 ccache 是否安全。我担心的是:如果我用 gcc 构建,然后用 diab 重建,如果文件及其依赖项相同,我会得到 ccache 命中吗?
在这种情况下,我不想命中,因为我希望使用 diab 重新编译文件。
您不会在不同的编译器之间获得 ccache 命中。编译器是散列的。此外,您可以更改环境变量 CCACHE_COMPILERCHECK 以以不同的方式检查编译器。如ccache 手册中所述:
For both modes, the following information is included in the hash:
the extension used by the compiler for a file with preprocessor output (normally .i for C code and .ii for C++ code)
the compiler’s size and modification time (or other compiler-specific information specified by CCACHE_COMPILERCHECK)
the name of the compiler
the current directory (if CCACHE_HASHDIR is set)
contents of files specified by CCACHE_EXTRAFILES (if any)