⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ccache.1

📁 ccache 是一个快速的编译器缓存。当您编译一个程序的时候
💻 1
字号:
.TH "ccache" "1" "April 2002" "" "" .SH "NAME" ccache \- a fast compiler cache.SH "SYNOPSIS" .PP ccache [OPTION].PP ccache <compiler> [COMPILER OPTIONS].PP <compiler> [COMPILER OPTIONS].PP .SH "DESCRIPTION" .PP ccache is a compiler cache\&. It speeds up re-compilation of C/C++ code by caching previous compiles and detecting when the same compile isbeing done again\&..PP .SH "OPTIONS SUMMARY" .PP Here is a summary of the options to ccache\&..PP .nf  -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.fi  .PP .SH "OPTIONS" .PP These options only apply when you invoke ccache as "ccache"\&. Wheninvoked as a compiler none of these options apply\&. In that case yournormal compiler options apply and you should refer to your compilersdocumentation\&..PP .IP "\fB-h\fP" Print a options summary page.IP .IP "\fB-s\fP" Print the current statistics summary for the cache\&. Thestatistics are stored spread across the subdirectories of thecache\&. Using "ccache -s" adds up the statistics across allsubdirectories and prints the totals\&..IP .IP "\fB-z\fP" Zero the cache statistics\&. .IP .IP "\fB-V\fP" Print the ccache version number.IP .IP "\fB-c\fP" Clean the cache and re-calculate the cache file count andsize totals\&. Normally the -c option should not be necessary as ccachekeeps the cache below the specified limits at runtime and keepsstatistics up to date on each compile\&. This option is mostly usefulif you manually modify the cache contents or believe that the cachesize statistics may be inaccurate\&..IP .IP "\fB-C\fP" Clear the entire cache, removing all cached files\&..IP .IP "\fB-F maxfiles\fP" This sets the maximum number of files allowed inthe cache\&. The value is stored inside the cache directory and appliesto all future compiles\&. Due to the way the value is stored the actualvalue used is always rounded down to the nearest multiple of 16\&..IP .IP "\fB-M maxsize\fP" This sets the maximum cache size\&. You can specifya value in gigabytes, megabytes or kilobytes by appending a G, M or Kto the value\&. The default is gigabytes\&. The actual value stored isrounded down to the nearest multiple of 16 kilobytes\&..IP .PP .SH "INSTALLATION" .PP There are two ways to use ccache\&. You can either prefix your compilecommands with "ccache" or you can create a symbolic link betweenccache and the names of your compilers\&. The first method is mostconvenient if you just want to try out ccache or wish to use it forsome specific projects\&. The second method is most useful for when youwish to use ccache for all your compiles\&..PP To install for usage by the first method just copy ccache to somewherein your path\&. .PP To install for the second method do something like this:.nf    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.fi  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\&..PP Note! Do not use a hard link, use a symbolic link\&. A hardlink willcause "interesting" problems\&..PP .SH "EXTRA OPTIONS" .PP When run as a compiler front end ccache usually just takes the samecommand line options as the compiler you are using\&. The only exceptionto this is the option \&'--ccache-skip\&'\&. That option can be used to tellccache that the next option is definately not a input filename, andshould be passed along to the compiler as-is\&. .PP The reason this can be important is that ccache does need to parse thecommand line and determine what is an input filename and what is acompiler option, as it needs the input filename to determine the nameof the resulting object file (among other things)\&. The heuristicccache uses in this parse is that any string on the command line thatexists as a file is treated as an input file name (usually a Cfile)\&. By using --ccache-skip you can force an option to not betreated as an input file name and instead be passed along to thecompiler as a command line option\&..PP .SH "ENVIRONMENT VARIABLES" .PP ccache uses a number of environment variables to control operation\&. Inmost cases you won\&'t need any of these as the defaults will be fine\&..PP .IP .IP "\fBCCACHE_DIR\fP" the CCACHE_DIR environment variable specifieswhere ccache will keep its cached compiler output\&. The default is"$HOME/\&.ccache"\&..IP .IP "\fBCCACHE_LOGFILE\fP" If you set the CCACHE_LOGFILE environmentvariable then ccache will write some log information on cache hitsand misses in that file\&. This is useful for tracking down problems\&..IP .IP "\fBCCACHE_PATH\fP" You can optionally set CCACHE_PATH to a colonseparated path where ccache will look for the real compilers\&. If youdon\&'t do this then ccache will look for the first executable matchingthe compiler name in the normal PATH that isn\&'t a symbolic link toccache itself\&..IP .IP "\fBCCACHE_CC\fP" You can optionally set CCACHE_CC to force the nameof the compiler to use\&. If you don\&'t do this then ccache works it outfrom the command line\&..IP .IP "\fBCCACHE_PREFIX\fP" This option adds a prefix to the command linethat ccache runs when invoking the compiler\&. Also see the sectionbelow on using ccache with distcc\&..IP .IP "\fBCCACHE_DISABLE\fP" If you set the environment variableCCACHE_DISABLE then ccache will just call the real compiler,bypassing the cache completely\&..IP .IP "\fBCCACHE_CPP2\fP" If you set the environment variable CCACHE_CPP2then ccache will not use the optimisation of avoiding the 2nd call tothe pre-processor by compiling the pre-processed output that was usedfor finding the hash in the case of a cache miss\&. This is primarily adebugging option, although it is possible that some unusual compilerswill have problems with the intermediate filename extensions used inthis optimisation, in which case this option could allow ccache to beused\&..IP .IP "\fBCCACHE_NOSTATS\fP" If you set the environment variableCCACHE_NOSTATS then ccache will not update the statistics files oneach compile\&..IP .IP "\fBCCACHE_NLEVELS\fP" The environment variable CCACHE_NLEVELS allowsyou to choose the number of levels of hash in the cache directory\&. Thedefault is 2\&. The minimum is 1 and the maximum is 8\&. .IP .IP "\fBCCACHE_HARDLINK\fP" If you set the environment variableCCACHE_HARDLINK then ccache will attempt to use hard links from thecache directory when creating the compiler output rather than using afile copy\&. Using hard links is faster, but can confuse programs like\&'make\&' that rely on modification times\&..IP .IP "\fBCCACHE_RECACHE\fP" This forces ccache to not use any cachedresults, even if it finds them\&. New results are still cached, butexisting cache entries are ignored\&..IP .IP "\fBCCACHE_UMASK\fP" This sets the umask for ccache and all childprocesses (such as the compiler)\&. This is mostly useful when you wishto share your cache with other users\&. Note that this also affects thefile permissions set on the object files created from yourcompilations\&..IP .IP "\fBCCACHE_HASHDIR\fP" This tells ccache to hash the current workingdirectory when calculating the hash that is used to distinguish twocompiles\&. This prevents a problem with the storage of the currentworking directory in the debug info of a object file, which can leadccache to give a cached object file that has the working directory inthe debug info set incorrectly\&. This option is off by default as theincorrect setting of this debug info rarely causes problems\&. If youstrike problems with gdb not using the correct directory then enablethis option\&..IP .IP "\fBCCACHE_UNIFY\fP" If you set the environment variable CCACHE_UNIFYthen ccache will use the C/C++ unifier when hashing the pre-processoroutput if -g is not used in the compile\&. The unifier is slower than anormal hash, so setting this environment variable loses a little bitof speed, but it means that ccache can take advantage of notrecompiling when the changes to the source code consist ofreformatting only\&. Note that using CCACHE_UNIFY changes the hash, socached compiles with CCACHE_UNIFY set cannot be used whenCCACHE_UNIFY is not set and vice versa\&. The reason the unifier is offby default is that it can give incorrect line number information incompiler warning messages\&..IP .IP "\fBCCACHE_EXTENSION\fP" Normally ccache tries to automaticallydetermine the extension to use for intermediate C pre-processor filesbased on the type of file being compiled\&. Unfortunately this sometimesdoesn\&'t work, for example when using the aCC compiler on HP-UX\&. Onsystems like this you can use the CCACHE_EXTENSION option to overridethe default\&. On HP-UX set this environment variable to "i" if you usethe aCC compiler\&..IP .PP .SH "CACHE SIZE MANAGEMENT" .PP By default ccache has a one gigabyte limit on the cache size and nomaximum number of files\&. You can set a different limit using the"ccache -M" and "ccache -F" options, which set the size and number offiles limits\&..PP When these limits are reached ccache will reduce the cache to 20%below the numbers you specified in order to avoid doing the cacheclean operation too often\&..PP .SH "HOW IT WORKS" .PP The basic idea is to detect when you are compiling exactly the samecode a 2nd time and use the previously compiled output\&. You detectthat it is the same code by forming a hash of:.PP .IP o the pre-processor output from running the compiler with -E.IP o the command line options.IP o the real compilers size and modification time.IP o any stderr output generated by the compiler.PP These are hashed using md4 (a strong hash) and a cache file is formedbased on that hash result\&. When the same compilation is done a secondtime ccache is able to supply the correct compiler output (includingall warnings etc) from the cache\&..PP ccache has been carefully written to always produce exactly the samecompiler output that you would get without the cache\&. If you everdiscover a case where ccache changes the output of your compiler thenplease let me know\&..PP .SH "USING CCACHE WITH DISTCC" .PP distcc is a very useful program for distributing compilation across arange of compiler servers\&. It is often useful to combine distcc withccache, so that compiles that are done are sped up by distcc, but thatccache avoids the compile completely where possible\&..PP To use distcc with ccache I recommend using the CCACHE_PREFIXoption\&. You just need to set the environment variable CCACHE_PREFIX to\&'distcc\&' and ccache will prefix the command line used with thecompiler with the command \&'distcc\&'\&. .PP .SH "SHARING A CACHE" .PP A group of developers can increase the cache hit rate by sharing acache directory\&.  The hard links however cause unwanted side effects,as all links to a cached file share the file\&'s modification timestamp\&.This results in false dependencies to be triggered by timestamp-basedbuild systems whenever another user links to an existingfile\&. Typically, users will see that their libraries and binaries arerelinked without reason\&.  To share a cache without side effects, thefollowing conditions need to be met:.PP .IP o Use the same \fBCCACHE_DIR\fP environment variable setting.IP o Make sure that all users have write permission in the entirecache directory (and that you trust all users of the shared cache)\&. .IP o Make sure everyone sets the CCACHE_UMASK environment variableto 002, this ensures that cached files are accessible to everyone\&..IP o Make sure that the setgid bit is set on all directories in thecache\&. This tells the filesystem to inherit group ownership for newdirectories\&. The command "chmod g+s `find $CCACHE_DIR -type d`" mightbe useful for this\&..PP .SH "HISTORY" .PP ccache was inspired by the compilercache shell script script writtenby Erik Thiele and I would like to thank him for an excellent piece ofwork\&. See http://www\&.erikyyy\&.de/compilercache/for the Erik\&'s scripts\&..PP I wrote ccache because I wanted to get a bit more speed out of acompiler cache and I wanted to remove some of the limitations of theshell-script version\&..PP .SH "DIFFERENCES FROM COMPILERCACHE" .PP The biggest differences between Erik\&'s compilercache script and ccacheare:.IP o ccache is written in C, which makes it a bit faster (calling out toexternal programs is mostly what slowed down the scripts)\&..IP o ccache can automatically find the real compiler.IP o ccache keeps statistics on hits/misses.IP o ccache can do automatic cache management.IP o ccache can cache compiler output that includes warnings\&. In manycases this gives ccache a much higher cache hit rate\&..IP o ccache can handle a much wider ranger of compiler options.IP o ccache avoids a double call to cpp on a cache miss.PP .SH "BUGS" .PP When the cache is stored on an NFS filesystem, the filesystem must beexported with the \fBno_subtree_check\fP option to make renames betweendirectories reliable\&..PP .SH "CREDITS" .PP Thanks to the following people for their contributions to ccache.IP o Erik Thiele for the original compilercache script.IP o Luciano Rocha for the idea of compiling the pre-processor outputto avoid a 2nd cpp pass.IP o Paul Russell for many suggestions and the debian packaging.PP .SH "AUTHOR" .PP ccache was written by Andrew Tridgellhttp://samba\&.org/~tridge/.PP If you wish to report a problem or make a suggestion then please emailbugs@ccache\&.samba\&.org.PP ccache is released under the GNU General Public License version 2 orlater\&. Please see the file COPYING for license details\&.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -