2

I'm new to FreeBSD (9.1) and I'm just setting up the system. One problem that I could not solve yet is to get ccache working. I installed it from ports and followed the guidelines in the documentation (modify /etc/make.conf). Compile new packages from ports works without errors but the cache is never filled, so it seems that ccache is simply not used.

Here is the content of my /etc/make.conf file:

WITH_PKGNG= yes
# added by use.perl 2013-01-20 01:08:34
PERL_VERSION=5.14.2

# the rest here is copied from /usr/local/share/doc/ccache/ccache-howto-freebsd.txt
.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}
.endif
.endif

I also tried to follow the other guidelines in ccache-howto-freebsd.txt and added the following lines to /etc/csh.cshrc, which is the default shell used by root:

setenv PATH /usr/local/libexec/ccache:$PATH
setenv CCACHE_PATH /usr/bin:/usr/local/bin

Still no difference. ccache -s shows that the cache is still not filled during compilation. Do you have any ideas?

  • 1
    got to a port directory you want to install and type make -V CC. The result should show ccache. If not, try to remove the first if statement, i am not sure what it is supposed to do. – arved Jan 22 '13 at 16:46
  • @arved Thanks, that solved my problem! I'll posted your comment as the accepted answer. Still I don't know the purpose of the if-statement (which I just copied). – Philipp Claßen Jan 22 '13 at 23:28
1

This question was asked in early 2013. In October of that year, instructions for properly using ccache with ports were added to ccache-howto-freebsd.txt. In the years since then, both ccache and the ports infrastructure have been improved and are now better integrated.

Currently, all you have to do in FreeBSD 11 and up is install the devel/ccache port and put WITH_CCACHE_BUILD=yes in your /etc/make.conf, and it will "just work" for base and ports.

In older FreeBSD versions, WITH_CCACHE_BUILD=yes only affects ports; base still needs the .if.endif clauses and path adjustments. The precise instructions are in ccache-howto-freebsd.txt and should be easy to follow.

0

(arved's comment was right. It solved my problem, but I still don't understand exactly why the if statement was recommended, anyway. Thus, I post the answer as community wiki. Feel free to improve it if you know why.)

First, find out which compiler is used:

 $ cd /usr/ports/devel/gdb && make -V CC
 cc

cc is the default C compiler but it should be ccache.

To solve the problem, edit /etc/make.conf and remove the if-statement ...

.if (!empty(.CURDIR:M/usr/src*) || !empty(.CURDIR:M/usr/obj*))`

... and, of course, its closing .endif statement. Then the problem is solved:

 $ cd /usr/ports/devel/gdb && make -V CC
 /usr/local/libexec/ccache/world/cc
0

I meet the same problem. A solution that works for me is the following /etc/make.conf

# added by use.perl 2013-09-06 18:26:40
PERL_VERSION=5.14.4

.if !defined(NO_CCACHE)
    CC= /usr/local/libexec/ccache/world/cc
    CXX= /usr/local/libexec/ccache/world/c++
.endif

.if ${.CURDIR:M*/ports/devel/ccache}
    NO_CCACHE= yes
.endif

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.