如何在Linux上启用ccache

关于在GNU / Linux上启用ccache的文档很少.以下是 launchpad.net回复

At the moment,I think the best way to enable ccache is to add
“/usr/lib/ccache” to the front of your path. If you want to enable it
for all users by default,change the PATH variable in
/etc/environment.

有人可以给我更多关于启用ccache的信息吗?

解决方法

至少有两种方法

i)覆盖Makefile中的CC,CXX,…标志.在R框架内,读取系统和可选的用户配置文件,我只需设置

VER=4.7
CC=ccache gcc-$(VER)
CXX=ccache g++-$(VER)
SHLIB_CXXLD=g++-$(VER)
FC=ccache gfortran
F77=ccache gfortran

这也允许我在gcc版本之间来回切换.现在所有涉及R的编译都使用ccache.

ii)对于其他用途,我已经部署了在/usr/bin之前检查/usr/local / bin /的事实.人们可以做到

root@max:/usr/local/bin# ls -l gcc
lrwxrwxrwx 1 root root 15 Jan 27 11:04 gcc -> /usr/bin/ccache
root@max:/usr/local/bin# ./gcc --version
gcc (Ubuntu/Linaro 4.7.2-2ubuntu1) 4.7.2
copyright (C) 2012 Free Software Foundation,Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or fitness FOR A PARTIculaR PURPOSE.

root@max:/usr/local/bin#

现在通过ccache调用gcc:

edd@max:/tmp$cp -vax ~/src/progs/C/benfordsLaw.c .
`/home/edd/src/progs/C/benfordsLaw.c' -> `./benfordsLaw.c'
edd@max:/tmp$time /usr/local/bin/gcc -c benfordsLaw.c 

real    0m0.292s
user    0m0.052s
sys     0m0.012s
edd@max:/tmp$time /usr/local/bin/gcc -c benfordsLaw.c 

real    0m0.026s
user    0m0.004s
sys     0m0.000s
edd@max:/tmp$

相关文章

insmod和modprobe加-f参数导致Invalid module format错误 这...
将ArchLinux安装到U盘 几个月前入门Arch的时候上网搜了不少安...
1、安装Apache。 1)执行如下命令,安装Apache服务及其扩展包...
一、先说一下用ansible批量采集机器信息的实现办法: 1、先把...
安装配置 1. 安装vsftpd 检查是否安装了vsftpd # rpm -qa | ...
如何抑制stable_secret读取关键的“net.ipv6.conf.all.stabl...