用ccache加速编译内核

3040阅读 0评论2013-06-28 M_O_Bz
分类:LINUX

   如果你经常编译大型的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对某个编译选项的判断失误导致编译失败,死活查不出来为什么原因。所以当出现某些怪异的现象时,请用正常的方式编译试试。


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

 



上一篇:使用cscope+ctags+global 查看uboot及linux kernel 代码脚本
下一篇:在 shell 中创建临时文件(随机文件名)的方法总结