首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >“‘ccache”配置

“‘ccache”配置
EN

Stack Overflow用户
提问于 2014-07-12 22:10:48
回答 2查看 5K关注 0票数 3

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

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

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

代码语言:javascript
复制
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.
EN

回答 2

Stack Overflow用户

发布于 2014-08-14 16:19:15

您是否考虑过将Makefiles更改为使用相对路径?您可以使用像前面提到的in this post这样的技术来实现这一点,而不必进行太多更改。

另外注意: CCACHE_BASEDIR的路径是相对于当前工作目录的(这一点也许可以在手册页中更清楚地指定)。这意味着您的两个编译命令将导致(使用CCACHE_BASEDIR=/home/developer):

代码语言:javascript
复制
developer@crunchbang:~$ ccache g++ -c unique_name1/contest.cpp
developer@crunchbang:~$ ccache g++ -c unique_name2/contest.cpp

换句话说:它们仍然是不同的。只有在unique_name目录内编译才能解决此问题。例如

代码语言:javascript
复制
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

将导致:

代码语言:javascript
复制
developer@crunchbang:~$ ccache g++ -c contest.cpp
developer@crunchbang:~$ ccache g++ -c contest.cpp
票数 4
EN

Stack Overflow用户

发布于 2019-06-11 11:46:47

第二次编译后的ccache未命中(2)是上次运行的旧统计数据。在重新编译之前,您可以运行"ccache -z“来清除上次的缓存统计数据。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24713745

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档