Welcome to Linux Knowledge Base and Tutorial
"The place where you learn linux"
International Rescue Committe

 Create an AccountHome | Submit News | Your Account  

Tutorial Menu
Linux Tutorial Home
Table of Contents

· Introduction to Operating Systems
· Linux Basics
· Working with the System
· Shells and Utilities
· Editing Files
· Basic Administration
· The Operating System
· The X Windowing System
· The Computer Itself
· Networking
· System Monitoring
· Solving Problems
· Security
· Installing and Upgrading
· Linux and Windows

Man Pages
Linux Topics
Test Your Knowledge

Site Menu
Site Map
Copyright Info
Terms of Use
Privacy Info
Masthead / Impressum
Your Account

Private Messages

News Archive
Submit News
User Articles
Web Links


The Web

Who's Online
There are currently, 68 guest(s) and 0 member(s) that are online.

You are an Anonymous user. You can register for free by clicking here




       ccache [OPTION]

       ccache <compiler> [COMPILER OPTIONS]

       <compiler> [COMPILER OPTIONS]


       ccache is a compiler cache. It speeds up re-compilation of
       C/C++ code by caching previous compiles and detecting when
       the same compile is being done again.


       Here is a summary of the options to ccache.

       -s                      show statistics summary
       -z                      zero statistics
       -c                      run a cache cleanup
       -C                      clear the cache completely
       -F <maxfiles>           set maximum files in cache
       -M <maxsize>            set maximum size of cache (use G, M or K)
       -h                      this help page
       -V                      print version number


       These  options  only  apply  when  you  invoke  ccache  as
       "ccache". When invoked as a compiler none of these options
       apply. In that case your normal compiler options apply and
       you should refer to your compilers documentation.

       -h     Print a options summary page

       -s     Print the current statistics summary for the cache.
              The  statistics are stored spread across the subdi­
              rectories of the cache. Using "ccache -s"  adds  up
              the statistics across all subdirectories and prints
              the totals.

       -z     Zero the cache statistics.

       -C     Clear  the entire cache, removing all cached files.

       -F maxfiles
              This sets the maximum number of  files  allowed  in
              the  cache.  The  value  is stored inside the cache
              directory and applies to all future  compiles.  Due
              to  the  way  the  value is stored the actual value
              used is always rounded down to the nearest multiple
              of 16.

       -M maxsize
              This sets the maximum cache size. You can specify a
              value  in  gigabytes,  megabytes  or  kilobytes  by
              appending  a G, M or K to the value. The default is
              gigabytes. The actual value stored is rounded  down
              to the nearest multiple of 16 kilobytes.


       There  are  two  ways to use ccache. You can either prefix
       your compile commands with "ccache" or you  can  create  a
       symbolic link between ccache and the names of your compil­
       ers. The first method is most convenient if you just  want
       to try out ccache or wish to use it for some specific pro­
       jects. The second method is most useful for when you  wish
       to use ccache for all your compiles.

       To  install for usage by the first method just copy ccache
       to somewhere in your path.

       To install for the second method do something like this:

         cp ccache /usr/local/bin/
         ln -s /usr/local/bin/ccache /usr/local/bin/gcc
         ln -s /usr/local/bin/ccache /usr/local/bin/cc

       This will work as long as /usr/local/bin comes before  the
       path   to  gcc  (which  is  usually  in  /usr/bin).  After
       installing you may wish to run "which gcc"  to  make  sure
       that the correct link is being used.

       Note!  Do  not  use  a  hard  link, use a symbolic link. A
       hardlink will cause "interesting" problems.

       that  exists  as  a  file is treated as an input file name
       (usually a C file). By using --ccache-skip you  can  force
       an  option  to  not  be  treated as an input file name and
       instead be passed along to the compiler as a command  line


       ccache  used  a number of environment variables to control
       operation. In most cases you won't need any  of  these  as
       the defaults will be fine.

              the CCACHE_DIR environment variable specifies where
              ccache will keep its cached  compiler  output.  The
              default is "$HOME/.ccache".

              If  you set the CCACHE_LOGFILE environment variable
              then ccache will  write  some  log  information  on
              cache  hits and misses in that file. This is useful
              for tracking down problems.

              You can optionally set CCACHE_PATH to a colon sepa­
              rated path where ccache will look for the real com­
              pilers. If you don't do this then ccache will  look
              for the first executable matching the compiler name
              in the normal PATH that isn't a  symbolic  link  to
              ccache itself.

              You  can optionally set CCACHE_CC to force the name
              of the compiler to use. If you don't do  this  then
              ccache works it out from the command line.

              This  option adds a prefix to the command line that
              ccache runs when invoking the  compiler.  Also  see
              the section below on using ccache with distcc.

              If  you set the environment variable CCACHE_DISABLE
              then ccache  will  just  call  the  real  compiler,
              bypassing the cache completely.

              If you set the environment variable  CCACHE_NOSTATS
              then ccache will not update the statistics files on
              each compile.

              The environment variable CCACHE_NLEVELS allows  you
              to choose the number of levels of hash in the cache
              directory. The default is 2. The minimum is  1  and
              the maximum is 8.

              If you set the environment variable CCACHE_HARDLINK
              then ccache will attempt to use hard links from the
              cache  directory  when creating the compiler output
              rather than using a file copy. Using hard links  is
              faster,  but  can confuse programs like 'make' that
              rely on modification times.

              This forces ccache to not use any  cached  results,
              even  if  it  finds  them.  New  results  are still
              cached, but existing cache entries are ignored.

              This tells  ccache  to  hash  the  current  working
              directory when calculating the hash that is used to
              distinguish two compiles. This prevents  a  problem
              with  the  storage of the current working directory
              in the debug info of a object file, which can  lead
              ccache  to  give  a cached object file that has the
              working directory in  the  debug  info  set  incor­
              rectly. This option is off by default as the incor­
              rect setting of this debug info rarely causes prob­
              lems. If you strike problems with gdb not using the
              correct directory then enable this option.

              If you set the  environment  variable  CCACHE_UNIFY
              then ccache will use the C/C++ unifier when hashing
              the pre-processor output if -g is not used  in  the
              compile.  The unifier is slower than a normal hash,
              so setting this environment variable loses a little
              bit  of  speed,  but  it means that ccache can take
              advantage of not recompiling when  the  changes  to
              the  source code consist of reformatting only. Note
              systems like this you can use the  CCACHE_EXTENSION
              option  to  override the default. On HP-UX set this
              environment variable to "i" if you use the aCC com­


       By  default  ccache  has a one gigabyte limit on the cache
       size and no maximum number of files. You can set a differ­
       ent  limit  using the "ccache -M" and "ccache -F" options,
       which set the size and number of files limits.

       When these limits are reached ccache will reduce the cache
       to  20%  below the numbers you specified in order to avoid
       doing the cache clean operation too often.


       The basic idea is to detect when you are compiling exactly
       the  same  code a 2nd time and use the previously compiled
       output. You detect that it is the same code by  forming  a
       hash of:

       o      the  pre-processor output from running the compiler
              with -E

       o      the command line options

       o      the real compilers size and modification time

       o      any stderr output generated by the compiler

       These are hashed using md4 (a strong  hash)  and  a  cache
       file  is  formed  based on that hash result. When the same
       compilation is done a second time ccache is able to supply
       the  correct  compiler output (including all warnings etc)
       from the cache.

       ccache  has  been  carefully  written  to  always  produce
       exactly  the same compiler output that you would get with­
       out the cache. If you ever discover a  case  where  ccache
       changes  the  output  of  your compiler then please let me


       distcc is a very useful program for distributing  compila­
       tion  across a range of compiler servers. It is often use­
       ful to combine distcc with ccache, so that  compiles  that
       are done are sped up by distcc, but that ccache avoids the
       dependencies to be triggered by timestamp-based build sys­
       tems whenever another user links to an existing file. Typ­
       ically, users will see that their libraries  and  binaries
       are  relinked  without  reason.   To share a cache without
       side effects, the following conditions need to be met:

       o      Use the same CCACHE_DIR environment  variable  set­

       o      Make  sure  that all users have write permission in
              the entire cache directory (and that you trust  all
              users of the shared cache).

       o      Tell  your  users  to set a umask that allows group
              writes (eg. umask 002)

       o      Make sure that the setgid bit is set on all  direc­
              tories  in  the cache. This tells the filesystem to
              inherit group ownership for  new  directories.  The
              command  "chmod  g+s  `find  $CCACHE_DIR  -type d`"
              might be useful for this.


       ccache was inspired  by  the  compilercache  shell  script
       script  written  by  Erik Thiele and I would like to thank
       him   for   an    excellent    piece    of    work.    See
       http://www.erikyyy.de/compilercache/    for   the   Erik's

       I wrote ccache because I wanted to get a  bit  more  speed
       out of a compiler cache and I wanted to remove some of the
       limitations of the shell-script version.


       The  biggest  differences  between  Erik's   compilercache
       script and ccache are:

       o      ccache is written in C, which makes it a bit faster
              (calling out to external programs  is  mostly  what
              slowed down the scripts).

       o      ccache can automatically find the real compiler

       o      ccache keeps statistics on hits/misses

       o      ccache can do automatic cache management

       o      ccache  can  cache  compiler  output  that includes
              warnings. In many cases this gives  ccache  a  much

       o      Luciano  Rocha  for  the idea of compiling the pre-
              processor output to avoid a 2nd cpp pass

       o      Paul Russell for many suggestions  and  the  debian


       ccache      was     written     by     Andrew     Tridgell

       If you wish to report a problem or make a suggestion  then
       please email bugs@ccache.samba.org

       ccache  is  released  under the GNU General Public License
       version 2 or  later.  Please  see  the  file  COPYING  for
       license details.

                            April 2002                  ccache(1)

Looking for a "printer friendly" version?



Security Code
Security Code
Type Security Code

Don't have an account yet? You can create one. As a registered user you have some advantages like theme manager, comments configuration and post comments with your name.

Help if you can!

Amazon Wish List

Did You Know?
The Linux Tutorial can use your help.


Tell a Friend About Us

Bookmark and Share

Web site powered by PHP-Nuke

Is this information useful? At the very least you can help by spreading the word to your favorite newsgroups, mailing lists and forums.
All logos and trademarks in this site are property of their respective owner. The comments are property of their posters. Articles are the property of their respective owners. Unless otherwise stated in the body of the article, article content (C) 1994-2013 by James Mohr. All rights reserved. The stylized page/paper, as well as the terms "The Linux Tutorial", "The Linux Server Tutorial", "The Linux Knowledge Base and Tutorial" and "The place where you learn Linux" are service marks of James Mohr. All rights reserved.
The Linux Knowledge Base and Tutorial may contain links to sites on the Internet, which are owned and operated by third parties. The Linux Tutorial is not responsible for the content of any such third-party site. By viewing/utilizing this web site, you have agreed to our disclaimer, terms of use and privacy policy. Use of automated download software ("harvesters") such as wget, httrack, etc. causes the site to quickly exceed its bandwidth limitation and are therefore expressly prohibited. For more details on this, take a look here

PHP-Nuke Copyright © 2004 by Francisco Burzi. This is free software, and you may redistribute it under the GPL. PHP-Nuke comes with absolutely no warranty, for details, see the license.
Page Generation: 0.11 Seconds