微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在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$

原文地址:https://www.jb51.cc/linux/394205.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐