问题描述
我使用cmake来创建makefile。 cmake创建包含绝对路径的gcc行。
为了加速编译,我使用ccache。
从不同位置创建相同的代码(例如,几个开发人员编译相同的代码,每个在其主目录下)导致ccache cach miss。
$
如上面的注释中所提到的,一个问题是预处理器行指令中的任何绝对路径都由ccache进行哈希处理,如果使用编译器选项 -g
,编译器会将源代码文件的绝对路径作为好。另一个类似的问题是,如果源代码文件的路径在命令行中是绝对路径,那么如果代码具有 __ FILE __
宏的扩展,则该路径将被哈希。 / p>
解决方案是升级到几天前发布的ccache 3.0。它有可选的支持重写绝对路径到相对路径,以增加命中率。请参阅手册中的。
I use cmake to create a makefiles. cmake creates gcc line containing absolute pathes.To speed up compilation I use ccache.
Building same code from different locations (e.g. several developers compile the same code, each under its home directory) causes ccache cach miss.
Googled it, but not found a good answer.
As mentioned in a comment above, one problem is that any absolute paths in the preprocessor line directives are hashed by ccache, and if the compiler option -g
is used, the compiler emits an absolute path to the source code file as well. Another similar problem is that if the path to the source code file is absolute on the command line, that path will be hashed if the code has an expansion of the __FILE__
macro.
The solution is to upgrade to ccache 3.0, which was released some days ago. It has optional support for rewriting absolute paths to relative paths in order to increase hit rate. See Compiling in different directories in the manual.
这篇关于ccache和绝对路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!