Difference between revisions of "Ccache"

From CBLFS
Jump to navigationJump to search
 
Line 22: Line 22:
 
== Multilib ==
 
== Multilib ==
 
'''''This package does not install any libraries so only one installation is needed.'''''
 
'''''This package does not install any libraries so only one installation is needed.'''''
 
=== 32Bit ===
 
 
Compile the package:
 
 
CC="gcc ${BUILD32}" ./configure --prefix=/usr &&
 
make
 
 
Install the package:
 
 
make install
 
 
=== N32 ===
 
 
Compile the package:
 
 
CC="gcc ${BUILDN32}" ./configure --prefix=/usr &&
 
make
 
Install the package:
 
 
make install
 
 
=== 64Bit ===
 
  
 
Compile the package:
 
Compile the package:
Line 63: Line 40:
 
==== Method 1 ====
 
==== Method 1 ====
  
To prefix the compiler with ccache you would need to set the following enviornment variables where appropriate:
+
To prefix the compiler with ccache you would need to set the following environment variables where appropriate:
  
 
  CC="ccache gcc"
 
  CC="ccache gcc"

Latest revision as of 02:47, 28 October 2010

Download Source: http://samba.org/ftp/ccache/ccache-2.4.tar.gz

Introduction to Ccache

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.

Project Homepage: http://ccache.samba.org/

Non-Multilib

Compile the package:

./configure --prefix=/usr &&
make

Install the package:

make install

Multilib

This package does not install any libraries so only one installation is needed.

Compile the package:

CC="gcc ${BUILD64}" ./configure --prefix=/usr &&
make

Install the package:

make install

Configuring

Using ccache

There are 2 ways to configure ccache. Either to prefix the compiler with ccache or to create alternate symlinks.

Method 1

To prefix the compiler with ccache you would need to set the following environment variables where appropriate:

CC="ccache gcc"
CXX="ccache g++"

Or on multilib

CC="ccache gcc ${BUILD32}"
CXX="ccache g++ ${BUILD32}"

Method 2

The second way would be to create some compatibility symlinks.

install -dv -m755 /opt/ccache/bin &&
ln -sfv ../../../usr/bin/ccache /opt/ccache/bin/gcc &&
ln -sfv ../../../usr/bin/ccache /opt/ccache/bin/cc &&
ln -sfv ../../../usr/bin/ccache /opt/ccache/bin/g++

Then put those links at the top of your path each time you login.

cat > /etc/profile.d/50-ccache.sh << "EOF"
# Begin /etc/profile.d/50-ccache.sh

export PATH="/opt/ccache/bin:${PATH}"
export CCACHE_PATH="/usr/bin"
 
# End /etc/profile.d/50-ccache.sh
EOF
Caution.png

Note

The CCACHE_PATH is the order of the directories that ccache will look for compilers in. If it is not set ccache will default to using $PATH.

Using ccache with distcc

In addition to the above section. The CCACHE_PREFIX variable is a prefix tagged onto the command that ccache would run to compile code.

export CCACHE_PREFIX="distcc"

Contents

Installed Programs: ccache
Installed Libraries: None
Installed Directories: None
Retrieved from "?title=Ccache&oldid=20683"