'ccache'配置 [英] 'ccache' configuration

查看:216
本文介绍了'ccache'配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个与ccache配置有关的问题.在我们的开发环境中,我们有数百个使用绝对路径构建对象的make文件.

I have a question related to ccache configuration. In our development environment we have hundreds of make files that build objects using absolute paths.

我想加快该过程并使用ccache.不幸的是,从不同位置进行编译时,我会看到缓存未命中.以下是一个示例 简化了将源文件放置在不同目录中的情况.我如何设置ccache才能获得正确的命中率?

I wanted to speed up the process and use ccache. Unfortunately when compiling from different locations I can see cache misses. Below is an example of simplified situation where source files are placed in different directories. How do I have to setup ccache to get the proper hit ratio?

我尝试设置CCACHE_BASEDIR变量没有成功:

I tried to play with setting the CCACHE_BASEDIR variable with no success:

developer@crunchbang:~$ pwd
/home/developer
developer@crunchbang:~$ ccache -s
cache directory                     /home/developer/.ccache
cache hit (direct)                     0
cache hit (preprocessed)               0
cache miss                             0
files in cache                         0
cache size                             0 Kbytes
max cache size                       1.0 Gbytes
developer@crunchbang:~$ ccache g++ -c /home/developer/unique_name1/contest.cpp
developer@crunchbang:~$ ccache g++ -c /home/developer/unique_name2/contest.cpp
developer@crunchbang:~$ ccache -s
cache directory                     /home/developer/.ccache
cache hit (direct)                     0
cache hit (preprocessed)               0
cache miss                             2
files in cache                         4
cache size                            16 Kbytes
max cache size                       1.0 Gbytes
developer@crunchbang:~$ ccache g++ -c /home/developer/unique_name1/contest.cpp
developer@crunchbang:~$ ccache g++ -c /home/developer/unique_name2/contest.cpp
developer@crunchbang:~$ ccache -s
cache directory                     /home/developer/.ccache
cache hit (direct)                     2
cache hit (preprocessed)               0
cache miss                             2
files in cache                         4
cache size                            16 Kbytes
max cache size                       1.0 Gbytes
developer@crunchbang:~$ ccache --version
ccache version 3.1.7

Copyright (C) 2002-2007 Andrew Tridgell
Copyright (C) 2009-2011 Joel Rosdahl

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.

推荐答案

您是否考虑过更改Makefile以使用相对路径?您可以使用本文中提到的这类技术无需进行太多更改.

Have you considered changing your Makefiles to use relative paths? You could use a technique like mentioned in this post to do this without having to make too much changes.

另外请注意:CCACHE_BASEDIR会创建相对于当前工作目录的路径(可以在联机帮助页中更清楚地指定一些路径).这意味着您将产生2条编译命令(使用CCACHE_BASEDIR =/home/developer):

Note additionally: CCACHE_BASEDIR makes paths relative to the current working directory (something which perhaps could be specified a bit more clearly in the manpage). This means your 2 compilation commands will result in (with CCACHE_BASEDIR=/home/developer):

developer@crunchbang:~$ ccache g++ -c unique_name1/contest.cpp
developer@crunchbang:~$ ccache g++ -c unique_name2/contest.cpp

换句话说:它们仍然会有所不同. 仅当在unique_name目录中进行编译时,此问题才能解决. 例如

In other words: they will still be different. This issue will only be resolved if you compile inside the unique_name directories. For example

developer@crunchbang:~$ cd /home/developer/unique_name1 && ccache g++ -c /home/developer/unique_name1/contest.cpp
developer@crunchbang:~$ cd /home/developer/unique_name2 && ccache g++ -c /home/developer/unique_name2/contest.cpp

将导致:

developer@crunchbang:~$ ccache g++ -c contest.cpp
developer@crunchbang:~$ ccache g++ -c contest.cpp

这篇关于'ccache'配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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