Difference between revisions of "Ccache"

From CBLFS
Jump to navigationJump to search
(New page: {| style="text-align: left; background-color: AliceBlue;" |-valign="top" !Download Source: | http://samba.org/ftp/ccache/ccache-{{Ccache-Version}}.tar.gz |} ---- {{Package-Introduction|c...)
 
 
(4 intermediate revisions by one other user not shown)
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:
 
Compile the package:
  
  CC="gcc ${BUILD32}" ./configure --prefix=/usr &&
+
  CC="gcc ${BUILD64}" ./configure --prefix=/usr &&
 
  make
 
  make
  
Line 34: Line 32:
 
  make install
 
  make install
  
=== N32 ===
+
== Configuring ==
 +
 
 +
=== Using ccache ===
  
Compile the package:
+
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 ====
  
CC="gcc ${BUILDN32}" ./configure --prefix=/usr &&
+
The second way would be to create some compatibility symlinks.
make
 
Install the package:
 
  
  make install
+
  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++
  
=== 64Bit ===
+
Then put those links at the top of your path each time you login.
  
Compile the package:
+
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
  
CC="gcc ${BUILD64}" ./configure --prefix=/usr &&
+
{{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.}}
make
 
  
Install the package:
+
=== Using ccache with [[distcc]] ===
  
make install
+
In addition to the above section. The '''CCACHE_PREFIX''' variable is a prefix tagged onto the command that ccache would run to compile code.
  
== Configuring ==
+
export CCACHE_PREFIX="distcc"
  
 
= Contents =
 
= Contents =
Line 70: Line 91:
 
| None
 
| None
 
|}
 
|}
 +
 +
[[Category:Programming]]

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"