ccache
先使用apt-get install ccache
进行安装。
1 | sudo vim /etc/environment |
输入which gcc
,应该得到/usr/lib/ccache/gcc
修改CMakeLists.txt
1
2set(CMAKE_CXX_COMPILER_LAUNCHER ccache)
set(CMAKE_C_COMPILER_LAUNCHER ccache)
但是在ROS环境下,没发现起作用
distcc
Setting up distcc (server)
So, go ahead and install distcc on the server computer (in my case, the desktop)
And then spin up the server. (The following assumes I’m on the 10.8.33.0 subnet, and I’m allowing all hosts on that subnet to send jobs)1
sudo distccd --log-file=/tmp/distccd.log --daemon -a 10.8.33.0/24
Setting up distcc (client) So, now you have to tell ccache to use the distcc distributed compilation servers. To do this, just add the following line to your ~/.bashrc file.1
export CCACHE_PREFIX=distcc
Next, we have to tell distcc where to go to find the server. This also, just add to the bottom of your ~/.bashrc
(my desktop is at 10.8.33.182 and it has 8 cores, my laptop is at localhost and has 4)1
export DISTCC_HOSTS='localhost/4 10.8.33.182/8'
在另一个终端,使用下面命令检验ccache的运行效果1
watch -n1 'ccache -s -v'
或者watch -n1 'ccache --show-stats -v'
编译时,使用top看 distcc process starts spooling up its threads.