Chinaunix首页 | 论坛 | 博客
  • 博客访问: 207898
  • 博文数量: 47
  • 博客积分: 72
  • 博客等级: 民兵
  • 技术积分: 171
  • 用 户 组: 普通用户
  • 注册时间: 2012-08-31 11:44
文章分类

全部博文(47)

文章存档

2015年(14)

2014年(5)

2013年(11)

2012年(17)

分类: LINUX

2013-06-28 22:29:35

原文地址:用ccache加速编译内核 作者:hndeng06

   如果你经常编译大型的C/C++工程,不使用ccache你就out了。 

   cache is a compiler cache. It speeds up recompilation by caching previous compilations and detecting when the same compilation is being done again. Supported languages are C, C++, Objective-C and Objective-C++.


1. 安装 ccache

sudo apt-get install ccache


2. Usage


details see : man ccache
使用ccache
  • 编译指令前增加ccache. $ ccache gcc xxx
  • 创建软链接。 $ ln -s ccache /usr/local/bin/gcc

建议使用第一种方式,因为ccache偶尔也犯晕,当由于它出现错误的时候, 很难看出端倪。曾在某次编译某份代码时,ccache对某个编译选项的判断失误导致编译失败,死活查不出来为什么原因。所以当出现某些怪异的现象时,请用正常的方式编译试试。


3. 在交叉编译内核时,编译速度也快了近十倍。 

time ./build.sh


real 3m4.146s

user 10m30.640s

sys 0m37.138s


make clean -j4


time ./build.sh

real    0m43.477s

user    1m0.564s

sys     0m14.913s

 



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