# ccache: differences between building world and kernel



## lbc (Oct 28, 2012)

I'd like to use ccache(1) to rebuild kernels. In my current setup the buildworld target uses the ccache(1) symlinks as expected, but the buildkernel one doesn't.

I'm using the suggested snippet (/usr/local/share/doc/ccache/ccache-howto-freebsd.txt) in /etc/make.conf. It's similar to what i've seen on other threads: 
	
	



```
.if (!empty(.CURDIR:M/usr/src*) || !empty(.CURDIR:M/usr/obj*))
.if !defined(NOCCACHE)
C:=${CC:C,^cc,/usr/local/libexec/ccache/world/cc,1}
CXX:=${CXX:C,^c\+\+,/usr/local/libexec/ccache/world/c++,1}
.endif
.endif
```

I don't know enough make(1) syntax to understand how those variable expansion work, and I'm not finding anything about the C and CXX variables in make.conf(5) or in /usr/share/examples/etc/make.conf anyway...

Is there some fundamental difference between _world_ and _kernel_ that's preventing the compilation system from going through the ccache symlinks ?


----------



## wblock@ (Oct 28, 2012)

lbc said:
			
		

> ```
> .if (!empty(.CURDIR:M/usr/src*) || !empty(.CURDIR:M/usr/obj*))
> .if !defined(NOCCACHE)
> [color="Red"]C[/color]:=${CC:C,^cc,/usr/local/libexec/ccache/world/cc,1}
> ...



That should be CC.


----------



## wblock@ (Oct 28, 2012)

Incidentally, setting ccache(1) to keep the cache files compressed will allow more files in the same space.  When I tested it, it was actually a tiny bit faster than uncompressed.  Barely measurable, but the point is that there's no speed penalty.

Do that by setting

```
setenv CCACHE_COMPRESS yes
```

along with the other variables for ccache.


----------



## lbc (Oct 28, 2012)

Thanks Warren, I needed that second pair of eyes. I should probably think about enabling syntax coloring in vim to avoid such crude typos in the future 

I'm sure there's little to no speed penalty using modern CPUs to decompress things on the fly on such disk-bound tasks as compiling. I'm also a fan of storing the compilation cache in /var/cache/ccache using CCACHE_DIR and sharing it amongst users of a _developers_ groups, as has been described in other threads in the forums. 

(That probably stems from my using of an OS where you're both urged not to elevate your privileges mindlessly, and often stumble upon a piece of a build system that doesn't play nice with non-root users...)


----------



## bbzz (Oct 29, 2012)

wblock@ said:
			
		

> Incidentally, setting ccache(1) to keep the cache files compressed will allow more files in the same space.  When I tested it, it was actually a tiny bit faster than uncompressed.  Barely measurable, but the point is that there's no speed penalty.
> 
> Do that by setting
> 
> ...



What if there's zfs lzjb compression enabled already?


----------



## wblock@ (Oct 29, 2012)

If the underlying filesystem has compression, I would not combine them.


----------

