Chinaunix首页 | 论坛 | 博客
  • 博客访问: 173137
  • 博文数量: 43
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 451
  • 用 户 组: 普通用户
  • 注册时间: 2014-06-28 09:10
文章分类
文章存档

2016年(43)

我的朋友

分类: 嵌入式

2016-05-27 16:40:00


编译过程中出现的一个问题:

 

ccache: FATAL: Could not create /root/.ccache/f/2/914e1bca1f959b58083b48ad5318a4-636193.o.tmp.stdout.localhost.localdomain.27598 (permission denied?)

make[4]: ***

 

 

为了解决这个问题,了解了一下ccache

一.关于ccache

Ccache的出现是为了减少编译时间,ccache 的基本原理是通过将头文件高速缓存到源文件之中而改进了构建性能,因而通过减少每一步编译时添加头文件所需要的时间而提高了构建速度

第一趟编译时ccache缓存了GCC的“-E”输出、编译选项以及.o文件到$HOME/.ccache。第二次编译时尽量利用缓存,必要时更新缓存

 

二.Ccache的使用方法

使用"ccache gcc""ccache g++"代替"gcc""g++" ,以 gcc 为第一个参数调用 ccache,而不是调用 gcc。例如,要在命令行中编译一个文件,您通常会使用:

$ gcc foo.c

要使用 ccache,您应该输入:

$ ccache gcc foo.c

像这样对一个文件进行单独的编译,尤其是第一次使用 ccache 编译那个文件时,您将不会看到有任何的帮助,因为编译信息还没有被高速缓存。

 

三.Ccache的常用操作

   

Ccache  –s

获得关于高速缓存性能的统计数据

Ccache  –M

使用 -M 命令行选项来设置高速缓存的最大大小

Ccache  –F

-F 选项设置高速缓存目录的最大文件数目

Ccache  –c

-c 选项清空缓存

 

 

四.问题解决方法:

  最终解决这个问题的方法是在网上找到的,方法就是调整ccache缓存,增大缓存,具体分析如下

Looks like a straight-up race: one ccache invocation is cleaning up

files that are still in use by another invocation.  I bet the

precompiled headers triggered it because they take a long time to

generate.

 

Yes, spot on.

 

When doing cleanup in one of the 16 subdirectories, ccache deletes

temporary files that are older than one hour in a pre-step, assuming

that no compilation takes more than one hour. It doesn't look that

this happens to you, though.

 

The next step is that the 20% oldest files in the subdirectory are

removed. It sounds strange if at least 80% of the files in the

subdirectory have been put there (or used, which results in an updated

mtime) after the compilation of the precompiled header begun. Unless

your max cache size limit is way too low, that is... Could this be the

case? (Still, ccache should handle this more gracefully, of course.)

 

Almost certainly true.  My code generates impressively large object

files (this is C++, and I think that the size of an object file is

potentially even bigger than exponential in source file size), and in

pch mode it does so quickly.

 

My max cache size is 1 GB.  A non-pch build generates 844 MB of cache.

 

The weird thing: the pch build is failing too early for this to make a

lot of sense.  Cache usage is under 105 MB when ccache fails.

 

My pch build took 11 seconds or so.  I have multiple slow gcc possibly

in parallel, though: is it possible that they interact to purge far

more files than needed?  With the max size bumped to 5 GB, the build

succeeds, and the cache usage gets past 100 MB much faster than the

time it takes for the build to fail with the setting at 1 GB.

 

--Andy

 

阅读(1762) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~