DaemonForums  

Go Back   DaemonForums > Miscellaneous > Guides

Guides All Guides and HOWTO's.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 5th May 2008
vermaden's Avatar
vermaden vermaden is offline
Administrator
 
Join Date: Apr 2008
Location: pl_PL.lodz
Posts: 1,052
Thanked 118 Times in 93 Posts
Default HOWTO: FreeBSD with CCACHE

install ccache port or add a package:
Code:
# cd /usr/ports/devel/ccache && make install clean
# pkg_add -r ccache
add the following to /etc/make.conf:
Code:
CC=/usr/local/libexec/ccache/world-cc
CXX=/usr/local/libexec/ccache/world-c++
add the following to /.cshrc:
Code:
# set ccache varibles
setenv PATH /usr/local/libexec/ccache:$PATH
setenv CCACHE_PATH /usr/bin:/usr/local/bin
setenv CCACHE_DIR /var/tmp/ccache
setenv CCACHE_LOGFILE /var/log/ccache.log

# set ccache temp size to 512MB (default 1GB)
if ( -x /usr/local/bin/ccache ) then
  /usr/local/bin/ccache -M 512m > /dev/null
endif
logout and login again before using ccache because when You dont ccache will use /root/.ccache dir instead of /var/tmp/ccache.

ccache can be shared between several computers the same as ports tree for example, check man ccache for more info.

ADDED 2007.2.15:
example ccache stats from my box.
Code:
% ccache -s
cache directory                     /var/tmp/ccache
cache hit                          18562
cache miss                        102820
called for link                     9824
multiple source files                 75
compile failed                      1610
preprocessor error                  1446
not a C/C++ file                    3747
autoconf compile/link              16982
unsupported compiler option          511
no input file                       6698
files in cache                     49631
cache size                         464.3 Mbytes
max cache size                     512.0 Mbytes
ADDED 2007.2.16:
comparasion of buildworld times with and without ccache:
Code:
# without ccache
make -j1 buildworld  4148.38s user 937.02s system 97% cpu 1:27:00.40 total

# with ccache
make -j1 buildworld  1043.30s user 703.76s system 88% cpu 32:50.02 total
If you face a problem with /root/.ccache being used instead of /var/tmp/ccache then you may solve it that way:

Code:
% cd /home/${USER}
% rm -rf .ccache
% ln -s /var/tmp/ccache .ccache
% ls -l .ccache
lrwxr-xr-x  1 ${USER}  ${USER}  15 Dec 19 15:20 .ccache -> /var/tmp/ccache
% ccache -s
cache directory                     /var/tmp/ccache
cache hit                         165292
cache miss                        327142
called for link                    38002
multiple source files                216
compile failed                      5182
preprocessor error                  4934
couldn't find the compiler             1
not a C/C++ file                   26249
autoconf compile/link              52665
unsupported compiler option         1379
no input file                      23289
files in cache                     79438
cache size                         530.2 Mbytes
max cache size                     512.0 Mbytes
% sudo ccache -s
cache directory                     /home/vermaden/.ccache
cache hit                         165292
cache miss                        327142
called for link                    38002
multiple source files                216
compile failed                      5182
preprocessor error                  4934
couldn't find the compiler             1
not a C/C++ file                   26249
autoconf compile/link              52665
unsupported compiler option         1379
no input file                      23289
files in cache                     79438
cache size                         530.2 Mbytes
max cache size                     512.0 Mbytes
__________________
religions, worst damnation of mankind
"If 386BSD had been available when I started on Linux, Linux would probably never had happened." Linus Torvalds

Linux is not UNIX! Face it! It is not an insult. It is fact: GNU is a recursive acronym for “GNU's Not UNIX”.
vermaden's: links resources deviantart spreadbsd
Reply With Quote
  #2   (View Single Post)  
Old 27th May 2008
Starhost Starhost is offline
New User
 
Join Date: May 2008
Posts: 4
Thanked 0 Times in 0 Posts
Default

Can someone explain to me what ccache is and what it does on a system? And also why it isn't the default when it can speed up building that fast?
Reply With Quote
  #3   (View Single Post)  
Old 27th May 2008
Carpetsmoker's Avatar
Carpetsmoker Carpetsmoker is offline
Real Name: Martin
Old man from scene 24
 
Join Date: Apr 2008
Location: Eindhoven, Netherlands
Posts: 2,071
Thanked 198 Times in 156 Posts
Default

Code:
[~]# cat /ports/devel/ccache/pkg-descr
ccache is a compiler cache.  It acts as a caching pre-processor to C/C++
compilers, using the -E compiler switch and a hash to detect when a
compilation can be satisfied from cache.  This often results in a 5 to 10
times speedup in common compilations.

WWW: http://ccache.samba.org/
So, it's just a cache, it doesn't speed up compilation the first time (It may in fact slow it a bit).
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things.
Reply With Quote
  #4   (View Single Post)  
Old 29th May 2008
Oliver_H's Avatar
Oliver_H Oliver_H is offline
Real Name: Oliver Herold
UNIX lover
 
Join Date: May 2008
Location: Germany
Posts: 429
Thanked 26 Times in 22 Posts
Default

And sometimes you have to build without ccache, but most of the time you'll be fine and speed up compilation at least while updating the next time. Building kernel and world with ccache and a dualcore is just the best you can get in performance
__________________
use UNIX or die :-)
Reply With Quote
  #5   (View Single Post)  
Old 19th June 2008
ohauer ohauer is offline
Port Guard
 
Join Date: May 2008
Location: germany
Posts: 32
Thanked 2 Times in 2 Posts
Default

I have this lines in my /etc/make.conf to control ccache.
If build with ccache is not working I use make -DNOCACHE


Code:
.if ${.CURDIR:M*/devel/ccache}
NOCACHE=1
.endif

.if !defined(NOCACHE)
CC=/usr/local/libexec/ccache/world-cc
CCX=/usr/local/libexec/ccache/world-cc++
.endif
Reply With Quote
  #6   (View Single Post)  
Old 19th June 2008
Carpetsmoker's Avatar
Carpetsmoker Carpetsmoker is offline
Real Name: Martin
Old man from scene 24
 
Join Date: Apr 2008
Location: Eindhoven, Netherlands
Posts: 2,071
Thanked 198 Times in 156 Posts
Default

Yes, some ports seem to fail with ccache ... See:
http://www.nabble.com/Re%3A-Standard...p17992614.html
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things.
Reply With Quote
  #7   (View Single Post)  
Old 20th June 2008
vermaden's Avatar
vermaden vermaden is offline
Administrator
 
Join Date: Apr 2008
Location: pl_PL.lodz
Posts: 1,052
Thanked 118 Times in 93 Posts
Default

True, I just tested them and they fail with ccache, but there is bery simple sollution for them. for every port that fails you may add something like that to /etc/make.conf as ohauer suggested:

Code:
.if !defined(NO_CACHE)
  CC=  /usr/local/libexec/ccache/world-cc
  CCX= /usr/local/libexec/ccache/world-cc++
.endif

.if ${.CURDIR:M*/ports/games/freera}
  NO_CCACHE= yes
.endif
And you are done with that one.

You may even do something like that if you feel more comfortable:

Code:
CCACHE_DISABLED+= games/freera \
                  graphics/gsculpt \
                  devel/ccache

.for PORT in ${CCACHE_DISABLED}
.if ${.CURDIR:M*/ports/$(PORT)}
  NO_CCACHE= yes
.endif
.endfor
__________________
religions, worst damnation of mankind
"If 386BSD had been available when I started on Linux, Linux would probably never had happened." Linus Torvalds

Linux is not UNIX! Face it! It is not an insult. It is fact: GNU is a recursive acronym for “GNU's Not UNIX”.
vermaden's: links resources deviantart spreadbsd
Reply With Quote
  #8   (View Single Post)  
Old 9th July 2008
ninjatux's Avatar
ninjatux ninjatux is offline
Real Name: Baqir Majlisi
Spam Deminer
 
Join Date: May 2008
Location: Antarctica
Posts: 293
Thanked 15 Times in 15 Posts
Default

Geany doesn't build with ccache either, so I used the solutions listed above, although I'm not exactly sure what the benefits to ccache are. I haven't really seen any massive speed ups in recompilation. I think the biggest speed up will come with better parallel support in ports.
__________________
"UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity."
MacBook Pro (Darwin 9), iMac (Darwin 9), iPod Touch (Darwin 9), Dell Optiplex GX620 (FreeBSD 7.1-STABLE)
Reply With Quote
  #9   (View Single Post)  
Old 9th July 2008
vermaden's Avatar
vermaden vermaden is offline
Administrator
 
Join Date: Apr 2008
Location: pl_PL.lodz
Posts: 1,052
Thanked 118 Times in 93 Posts
Default

Quote:
Originally Posted by ninjatux View Post
Geany doesn't build with ccache either
Strange, I have never had any issues with Geany compilation using ccache, to be precise, all ports that I used built successfully with ccache.
__________________
religions, worst damnation of mankind
"If 386BSD had been available when I started on Linux, Linux would probably never had happened." Linus Torvalds

Linux is not UNIX! Face it! It is not an insult. It is fact: GNU is a recursive acronym for “GNU's Not UNIX”.
vermaden's: links resources deviantart spreadbsd
Reply With Quote
Old 9th July 2008
Carpetsmoker's Avatar
Carpetsmoker Carpetsmoker is offline
Real Name: Martin
Old man from scene 24
 
Join Date: Apr 2008
Location: Eindhoven, Netherlands
Posts: 2,071
Thanked 198 Times in 156 Posts
Default

Quote:
Originally Posted by ninjatux View Post
Geany doesn't build with ccache either, so I used the solutions listed above, although I'm not exactly sure what the benefits to ccache are. I haven't really seen any massive speed ups in recompilation. I think the biggest speed up will come with better parallel support in ports.
No, ccache is not magic, ccache is a cache to speed up the second build, not the first one, since there is no cache the first build ... It has nothing to do with parallel builds...

For example, If I upgrade a port or something, I may need to compile the application several times (Depending on how much patching is needed), so then ccache is very useful.
For a normal end-user who just compiles ports, ccache's usefulness is limited...

As for geany, I had no problems compiling 0.14,1 - Which is the latest version (VTE and NLS turned off) ... What error/problem did you have exactly?
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things.
Reply With Quote
Old 9th July 2008
ninjatux's Avatar
ninjatux ninjatux is offline
Real Name: Baqir Majlisi
Spam Deminer
 
Join Date: May 2008
Location: Antarctica
Posts: 293
Thanked 15 Times in 15 Posts
Default

Quote:
I haven't really seen any massive speed ups in recompilation.
I should've been more clear. I didn't mean parallel builds. I was referring to MAKEOPTS, you know -j10 or whatever. Implementing that in ports would improve compile times quite a bit. Currently, you need to use some hack to use anything above standard. I've tried setting MAKEOPTS, but it seems that it's not obeyed or such.

The configure script died with ccache enabled because it apparently couldn't find the compiler. So, I went to test another ports, pidgin. It compiled fine. So, I disabled ccache, and Geany compiled. It's not of much use to me as I'm actually interested in getting NetBeans to bend to FreeBSD or working with source code for that.
__________________
"UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity."
MacBook Pro (Darwin 9), iMac (Darwin 9), iPod Touch (Darwin 9), Dell Optiplex GX620 (FreeBSD 7.1-STABLE)

Last edited by ninjatux; 9th July 2008 at 07:13 PM.
Reply With Quote
Reply

Tags
ccache

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
FreeBSD GPT howto graudeejs Guides 10 21st December 2010 12:24 AM
HOWTO: FreeBSD CPU Scaling with cpufreq.ko vermaden Guides 10 27th October 2010 07:58 AM
HOWTO: Enemy Territory on FreeBSD tangram Guides 0 9th June 2009 03:31 PM
HOWTO: QEMU on FreeBSD vermaden Guides 10 9th March 2009 07:10 PM
FreeBSD howto: burning and ripping cd's graudeejs Guides 9 31st December 2008 06:39 AM


All times are GMT. The time now is 10:26 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick