加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

如何在Linux上启用ccache

发布时间:2020-12-13 19:18:00 所属栏目:Linux 来源:网络整理
导读:关于在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
关于在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$

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读