HOWTO: FreeBSD with CCACHE

I'm a bit at a loss so please explain the following to me: how do I use ccache with clang for world and ports? I am aware that not all ports compile with clang so once I understand how to get it to work, I can find workarounds for ports that are not happy when they're being built with clang.
 
donduq said:
I'm a bit at a loss so please explain the following to me: how do I use ccache with clang for world and ports? I am aware that not all ports compile with clang so once I understand how to get it to work, I can find workarounds for ports that are not happy when they're being built with clang.

Shortly after asking this I took a leap of foo and am now trying to build world after the following steps.

Big fat red warning for info scavengers: I'm just posting what I am trying out; don't blindly follow these steps. I'm posting this so someone can review them.

Code:
cd /usr/local/libexec/ccache/world
ln -s ccache clang
ln -s ccache clang++
cd ..
ln -s /usr/local/bin/ccache clang
ln -s /usr/local/bin/ccache++ clang

Then I edited /etc/make.conf:

Code:
(...other stuff...)

CC=clang
CXX=clang++
CPP=clang-cpp

.if (!empty(.CURDIR:M/usr/src*) || !empty(.CURDIR:M/usr/obj*))
.if !defined(NOCCACHE)
CC:=${CC:C,^cc,/usr/local/libexec/ccache/world/cc,1}
CXX:=${CXX:C,^c\+\+,/usr/local/libexec/ccache/world/c++,1}
CC:=${CC:C,^clang,/usr/local/libexec/ccache/world/clang,1}
CXX:=${CXX:C,^clang\+\+,/usr/local/libexec/ccache/world/clang++,1}
CCACHE_DIR:=/usr/sysccache
CCACHE_COMPRESS:=yes
CCACHE_COMPILERCHECK:=content
.endif
.endif
.if ${CC:T} == "clang"
CFLAGS+=        -Qunused-arguments
.endif

We'll see how it goes... but (wo)men of wisdom, please shine your light on this.
 
Replying to my own comment... again. :stud

The system has been running for a week now. A little background information: it is a rented VPS, FreeBSD runs as a Xen HVM domU. It has 512M of RAM and one CPU core. Purpose of the VPS: to run Apache and Redmine.

Good news first: everything builds except for the Midnight Commander (mc). I could compile the many ports required by me and/or Redmine.

But the bad news: The system is painfully slow. I'm puzzled because the box seems to be healthy as can be seen in the following snippet from top:

Code:
CPU:  0.0% user,  0.0% nice,  0.0% system,  0.0% interrupt,  100% idle
Mem: 172M Active, 144M Inact, 139M Wired, 18M Cache, 59M Buf, 4860K Free
Swap: 3072M Total, 896K Used, 3071M Free

See? This is when the system is idle, no one is using Redmine today. But when I go there to edit things or add new things I do notice a painful delay.

What I'm going to do now is this: recompile everything with gcc and test it again. If it is just as slow then we can assume that clang is not to blame. But if it is faster then something is up. Unfortunately I am not a C programmer or capable system engineer in these matters, so I can't be of much help beyond posting my own findings.

I would welcome feedback though. :f
 
Back
Top