Jump to content
×
×
  • Create New...
  • 0

Improving Speed of compliation


Casawir

Question

Install ccache
# cd /usr/ports/devel/ccache && make install clean
or
# pkg_add -r ccache
THEN:
# ee /etc/make.conf
PASTE IN THIS:
.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
SAVE AND CLOSE.
 
THEN:
 
# ee /.cshrc

PASTE IN THIS:

# 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
SAVE AND CLOSE.
 
THEN: 
# source /.cshrc

RESTART MAY BE REQUIRED

 

With this command we can check usage of memory:
# ccache -s

MANUAL

https://ccache.samba.org/manual.html
  • Love 1
Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0

ccache also does some weird things on my VM. When I'm doing small changes, ccache will just ignore them (maybe because it thinks the files are unchanged or something). Even after cleaning, I was not able to compile a gamefile with changes. Only after waiting for a while or disabling ccache at compilation, the new gamefile worked as intended :)

 

Also you'd note that people will have to change the Makefile, otherwise the source won't be compiled with ccache as far as I know, especially not if you're doing things like:

CC = gcc49

 

Instead, if you want to use ccache then, just use:

CC = ccache gcc49

Link to comment
Share on other sites

  • 0

ccache also does some weird things on my VM. When I'm doing small changes, ccache will just ignore them (maybe because it thinks the files are unchanged or something). Even after cleaning, I was not able to compile a gamefile with changes. Only after waiting for a while or disabling ccache at compilation, the new gamefile worked as intended :)

 

Also you'd note that people will have to change the Makefile, otherwise the source won't be compiled with ccache as far as I know, especially not if you're doing things like:

CC = gcc49

 

Instead, if you want to use ccache then, just use:

CC = ccache gcc49

With this changes i wrote in tutorial u dont need to change Makefile, but im not sure it might be depended on FreeBSD version. Maybe your problem with small changes is caused of not clearing,deleting .o files before compilation,

Link to comment
Share on other sites

  • 0

I cleared it^^

But many people are using newer versions of gcc/clang which won't work like this.

 

Since cc is only replaced in /etc/make.conf it will take part in compiling ports in the portstree or building the kernel, but it won't take effect in compiling the source at least not when you're doing something like this:

CC = gcc49

That's the point where ccache won't be a part of the compilation. Also, feel free to use

cc -v

This prints out the compiler version. If you replace it on /etc/make.conf, you'll notice that cc -v still prints out the system's compiler no matter if you're using a more actual version of gcc/clang or whatever. So the effects from make.conf are applied when building ports or kernel, but not when compiling your custom sources.

 

Adding ccache to your Makefile is therefore needed to make it work. Maybe it'll work when using CC = cc but I don't know and I guess it won't but feel free to correct me if I'm wrong :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.