# ccache help?



## sk8harddiefast (Oct 25, 2010)

I read on Google about a package named ccache which is on ports and make compile faster. Use some kind of space (on disk I guess) and save compilation to do it faster next time? What exactly is that and how to setup it? Searching on forum, I read about some problems with ccache on and compiling / rebuilding world errors. Is dangerous? Try it?


----------



## graudeejs (Oct 25, 2010)

http://forums.freebsd.org/showthread.php?t=174
It only helps if you compile same/similar source more than 1 time.
For the first time, it will probably slow things down....

Also if you're porter or developer of some c/c++ apps, ccache is very useful


----------



## vermaden (Oct 25, 2010)

killasmurf86 said:
			
		

> Also if you're porter or developer of some c/c++ apps, ccache is very useful



... or use Ports a lot and source upgrades (kernel/world rebuild).


----------



## sk8harddiefast (Oct 25, 2010)

From: http://forums.freebsd.org/showthread.php?t=174


> # set ccache temp size to 512MB (default 1GB)


What exactly is that? How I should give?


----------



## vermaden (Oct 25, 2010)

Size of *ccache's* cache on disk, You can give as much as You want.


----------



## sk8harddiefast (Oct 25, 2010)

> add the following to /.cshrc:
> Code:
> 
> ```
> ...


If I use bash?


----------



## vermaden (Oct 25, 2010)

```
# set ccache temp size to 4G (default 1GB)
if [ -x /usr/local/bin/ccache ]; then
  export PATH=/usr/local/libexec/ccache:$PATH
  export CCACHE_PATH=/usr/bin:/usr/local/bin
  export CCACHE_DIR=/var/ccache
  /usr/local/bin/ccache -M 4g > /dev/null
fi
```


----------



## sk8harddiefast (Oct 25, 2010)

My /etc/make.conf

```
.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
```

My .bashrc

```
# set ccache temp size to 4G (default 1GB)
if [ -x /usr/local/bin/ccache ]; then
  export PATH=/usr/local/libexec/ccache:$PATH
  export CCACHE_PATH=/usr/bin:/usr/local/bin
  export CCACHE_DIR=/var/ccache
  /usr/local/bin/ccache -M 5g > /dev/null
fi
```

but ccache -s

```
cache                 directory                     /var/ccache
cache hit (direct)                     0
cache hit (preprocessed)               0
cache miss                             0
files in cache                         0
cache size                             0 Kbytes
max cache size                       1.0 Gbytes
```


----------



## vermaden (Oct 25, 2010)

```
# source ~/.bashrc
# ccache -s
```


----------



## sk8harddiefast (Oct 25, 2010)

```
sudo source ~/.bashrc
Password:
sudo: source: command not found
```
 :OOO


----------



## vermaden (Oct 25, 2010)

Learn how to use *sudo(8)* properly:

*/usr/local/etc/sudoers*

```
Defaults        env_keep += "PKG_PATH PKG_DBDIR PKG_TMPDIR TMPDIR PACKAGEROOT PACKAGESITE PKGDIR FTP_PASSIVE_MODE"
Defaults        env_keep += "PATH CCACHE_PATH CCACHE_DIR"
```

... or use it as *root*:

```
# su -
# source /home/YOU/.bashrc
# ccache -s
```


----------



## fronclynne (Oct 25, 2010)

*I thought source was a csh builtin*



			
				vermaden said:
			
		

> ```
> # source ~/.bashrc
> # ccache -s
> ```



Oughtn't that be `# . ~/.bashrc` or is my memory of Bourne syntax obsolete?


----------

