Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
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

2 Answers 2

up vote 0 down vote accepted

(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
share|improve this answer

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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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