tags:

views:

215

answers:

2

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.

+1  A: 

Well, maybe stating the obvious: you'd have to either get cmake to produce relative paths, or modify ccache to consider cache entries as matching if the only difference is the absolute path.

I have modified my copy of ccache to ignore the -pipe option when calculating the hash (which is used to name the cache entries); since that option causes no difference on the compiler output, only on its speed. Maybe it wouldn't be so hard to make it strip the initial /home/*/ from paths when calculating the hash.

Nicolás
+1  A: 

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.

Joel Rosdahl
This new version sounds cool...
Nicolás