在不同目录中使用已编译文件的绝对路径时,如何进行ccache缓存编译? [英] How do I make ccache cache compilation when using absolute paths to the compiled files in different directories?

查看:125
本文介绍了在不同目录中使用已编译文件的绝对路径时,如何进行ccache缓存编译?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用CMake创建一个makefile. CMake创建包含绝对路径的GCC行.

I use CMake to create a makefiles. CMake creates GCC line containing absolute paths.

为了加快编译速度,我使用了ccache.

To speed up compilation I use ccache.

从不同的位置构建相同的代码(例如,多个开发人员在其主目录下编译相同的代码)会导致ccache缓存未命中.

Building same code from different locations (e.g. several developers compile the same code, each under its home directory) causes ccache cache misses.

推荐答案

如上面的注释中所述,一个问题是,预处理器行指令中的任何绝对路径都由ccache散列,并且如果编译器选项-g为使用时,编译器也会发出到源代码文件的绝对路径.另一个类似的问题是,如果源代码文件的路径在命令行中是绝对路径,则如果代码具有__FILE__宏的扩展名,则该路径将被散列.

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.

解决方案是升级到几天前发布的ccache 3.0.它具有对将绝对路径重写为相对路径以提高命中率的可选支持.参见手册中的在不同目录中进行编译.

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缓存编译?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆