3
3
.\" Author: [see the "Author" section]
4
4
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
6
6
.\" Manual: ccache Manual
7
.\" Source: ccache 3.0.1
7
.\" Source: ccache 3.1.3
8
8
.\" Language: English
10
.TH "CCACHE" "1" "07/15/2010" "ccache 3\&.0\&.1" "ccache Manual"
10
.TH "CCACHE" "1" "11/28/2010" "ccache 3\&.1\&.3" "ccache Manual"
11
11
.\" -----------------------------------------------------------------
12
12
.\" * Define some portability stuff
13
13
.\" -----------------------------------------------------------------
158
There are two ways to use ccache\&. You can either prefix your compilation commands with \fBccache\fR or you can create a symbolic link (named as your compiler) to ccache\&. The first method is most convenient if you just want to try out ccache or wish to use it for some specific projects\&. The second method is most useful for when you wish to use ccache for all your compilations\&.
160
To install for usage by the first method just make sure \fBccache\fR is in your path\&.
162
To install for the second method, do something like this:
158
There are two ways to use ccache\&. You can either prefix your compilation commands with \fBccache\fR or you can let ccache masquerade as the compiler by creating a symbolic link (named as the compiler) to ccache\&. The first method is most convenient if you just want to try out ccache or wish to use it for some specific projects\&. The second method is most useful for when you wish to use ccache for all your compilations\&.
160
To use the first method, just make sure that \fBccache\fR is in your \fBPATH\fR\&.
162
To use the symlinks method, do something like this:
178
And so forth\&. This will work as long as /usr/local/bin comes before the path to the compiler (which is usually in /usr/bin)\&. After installing you may wish to run \(lqwhich gcc\(rq to make sure that the correct link is being used\&.
184
.nr an-no-space-flag 1
178
And so forth\&. This will work as long as the directory with symlinks comes before the path to the compiler (which is usually in /usr/bin)\&. After installing you may wish to run \(lqwhich gcc\(rq to make sure that the correct link is being used\&.
184
.nr an-no-space-flag 1
192
The technique of letting ccache masquerade as the compiler works well, but currently doesn\(cqt interact well with other tools that do the same thing\&. See USING CCACHE WITH OTHER COMPILER WRAPPERS\&.
200
.nr an-no-space-flag 1
238
254
.SH "EXTRA OPTIONS"
240
When run as a compiler, ccache usually just takes the same command line options as the compiler you are using\&. The only exception to this is the option \fB\-\-ccache\-skip\fR\&. That option can be used to tell ccache that the next option is definitely not a input filename, and should be passed along to the compiler as\-is\&.
256
When run as a compiler, ccache usually just takes the same command line options as the compiler you are using\&. The only exception to this is the option \fB\-\-ccache\-skip\fR\&. That option can be used to tell ccache to avoid interpreting the next option in any way and to pass it along to the compiler as\-is\&.
242
258
The reason this can be important is that ccache does need to parse the command line and determine what is an input filename and what is a compiler option, as it needs the input filename to determine the name of the resulting object file (among other things)\&. The heuristic ccache uses when parsing the command line is that any argument that exists as a file is treated as an input file name\&. By using \fB\-\-ccache\-skip\fR 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 option\&.
260
Another case where \fB\-\-ccache\-skip\fR can be useful is if ccache interprets an option specially but shouldn\(cqt, since the option has another meaning for your compiler than what ccache thinks\&.
243
261
.SH "ENVIRONMENT VARIABLES"
245
263
ccache uses a number of environment variables to control operation\&. In most cases you won\(cqt need any of these as the defaults will be fine\&.
259
277
to force the name of the compiler to use\&. If you don\(cqt do this then ccache works it out from the command line\&.
280
\fBCCACHE_COMPILERCHECK\fR
282
By default, ccache includes the modification time (\(lqmtime\(rq) and size of the compiler in the hash to ensure that results retrieved from the cache are accurate\&. The
283
\fBCCACHE_COMPILERCHECK\fR
284
environment variable can be used to select another strategy\&. Possible values are:
288
Hash the content of the compiler binary\&. This makes ccache very slightly slower compared to the
290
setting, but makes it cope better with compiler upgrades during a build bootstrapping process\&.
295
Hash the compiler\(cqs mtime and size, which is fast\&. This is the default\&.
300
Don\(cqt hash anything\&. This may be good for situations where you can safely use the cached results even though the compiler\(cqs mtime or size has changed (e\&.g\&. if the compiler is built as part of your build system and the compiler\(cqs source has not changed, or if the compiler only has changes that don\(cqt affect code generation)\&. You should only use the
302
setting if you know what you are doing\&.
305
\fIa command string\fR
307
Hash the standard output and standard error output of the specified command\&. The string will be split on whitespace to find out the command and arguments to run\&. No other interpretation of the command string will be done, except that the special word \(lq%compiler%\(rq will be replaced with the path to the compiler\&. Several commands can be specified with semicolon as separator\&. Examples:
330
%compiler% \-dumpmachine; %compiler% \-dumpversion
333
You should make sure that the specified command is as fast as possible since it will be run once for each ccache invocation\&.
335
Identifying the compiler using a command is useful if you want to avoid cache misses when the compiler has been rebuilt but not changed\&.
337
Another case is when the compiler (as seen by ccache) actually isn\(cqt the real compiler but another compiler wrapper \(em in that case, the default
339
method will hash the mtime and size of the other compiler wrapper, which means that ccache won\(cqt be able to detect a compiler upgrade\&. Using a suitable command to identify the compiler is thus safer, but it\(cqs also slower, so you should consider continue using the
341
method in combination with
344
USING CCACHE WITH OTHER COMPILER WRAPPERS\&.
262
348
\fBCCACHE_COMPRESS\fR
264
350
If you set the environment variable
266
352
then ccache will compress object files and other compiler output it puts in the cache\&. However, this setting has no effect on how files are retrieved from the cache; compressed and uncompressed results will still be usable regardless of this setting\&.
269
\fBCCACHE_COMPILERCHECK\fR
271
By default, ccache includes the modification time (mtime) and size of the compiler in the hash to ensure that results retrieved from the cache are accurate\&. The
272
\fBCCACHE_COMPILERCHECK\fR
273
environment variable can be used to select another strategy\&. Possible values are:
277
Hash the content of the compiler binary\&.
282
Hash the compiler\(cqs mtime and size\&. This is the default\&.
287
Don\(cqt hash anything\&.
290
Setting the variable to
292
makes ccache very slightly slower, but makes it cope better with compiler upgrades during a build bootstrapping process\&. The
294
setting may be good for situations where you can safely use the cached results even though the compiler\(cqs mtime or size has changed (e\&.g\&. if the compiler is built as part of your build system and the compiler\(cqs source has not changed, or if the compiler only has changes that don\(cqt affect code generation)\&. You should only set the variable to
296
if you know what you are doing\&.
299
355
\fBCCACHE_CPP2\fR
301
357
If you set the environment variable
303
359
then ccache will not use the optimisation of avoiding the second call to the preprocessor by compiling the preprocessed output that was used for finding the hash in the case of a cache miss\&. This is primarily a debugging option, although it is possible that some unusual compilers will have problems with the intermediate filename extensions used in this optimisation, in which case this option could allow ccache to be used anyway\&.
362
\fBCCACHE_DETECT_SHEBANG\fR
365
\fBCCACHE_DETECT_SHEBANG\fR
366
environment variable only has meaning on Windows\&. It instructs ccache to open the executable file to detect the
368
string, in which case ccache will search for
372
and use that to launch the executable\&.
523
592
The direct mode is generally faster since running the preprocessor has some overhead\&.
593
.SS "Common hashed information"
595
For both modes, the following information is included in the hash:
605
the extension used by the compiler for a file with preprocessor output (normally
620
the compiler\(cqs size and modification time (or other compiler\-specific information specified by
621
\fBCCACHE_COMPILERCHECK\fR)
632
the name of the compiler
643
the current directory (if
656
contents of files specified by
657
\fBCCACHE_EXTRAFILES\fR
524
660
.SS "The direct mode"
526
In the direct mode, the hash is formed of:
662
In the direct mode, the hash is formed of the common information and:
812
922
If you specify an absolute path to the source code file and compile with
813
923
\fB\-g\fR, the source code path stored in the object file may point to the wrong directory, which may prevent debuggers like GDB from finding the source code\&. Sometimes, a work\-around is to change the directory explicitly with the \(lqcd\(rq command in GDB\&.
925
.SH "PRECOMPILED HEADERS"
927
ccache has support for GCC\(cqs precompiled headers\&. However, you have to do some things to make it work properly:
938
\fBCCACHE_SLOPPINESS\fR
940
\fBtime_macros\fR\&. The reason is that ccache can\(cqt tell whether
944
is used when using a precompiled header\&.
967
compiler option to include the precompiled header (i\&.e\&., don\(cqt use
969
in the source code to include the header); or
981
\fB\-fpch\-preprocess\fR
982
compiler option when compiling\&.
985
If you don\(cqt do this, either the non\-precompiled version of the header file will be used (if available) or ccache will fall back to running the real compiler and increase the statistics counter \(lqpreprocessor error\(rq (if the non\-precompiled header file is not available)\&.
815
987
.SH "SHARING A CACHE"
817
989
A group of developers can increase the cache hit rate by sharing a cache directory\&. To share a cache without unpleasant side effects, the following conditions should to be met:
909
1081
A tip is to set \fBCCACHE_TEMPDIR\fR to a directory on the local host to avoid NFS traffic for temporary files\&.
910
.SH "USING CCACHE WITH DISTCC"
912
\(lqdistcc\(rq is a very useful program for distributing compilation across a range of compiler servers\&. It is often useful to combine distcc with ccache so that compilations that are done are sped up by distcc, but ccache avoids the compilation completely where possible\&.
914
The recommended way of combining distcc and ccache is by using the \fBCCACHE_PREFIX\fR option\&. You just need to set the environment variable \fBCCACHE_PREFIX\fR to \fBdistcc\fR and ccache will prefix the command line used with the compiler with the command \(lqdistcc\(rq\&.
916
It is not recommended to use the form \fBccache distcc compiler args\fR as the compilation command, because ccache will in that case hash the mtime of distcc instead of the compiler (see the \fBCCACHE_COMPILERCHECK\fR option), which means that compiler upgrades will not be detected properly and that the cached results will not be shared between compilations with and without distcc\&.
1082
.SH "USING CCACHE WITH OTHER COMPILER WRAPPERS"
1084
The recommended way of combining ccache with another compiler wrapper (such as \(lqdistcc\(rq) is by using the \fBCCACHE_PREFIX\fR option\&. You just need to set the environment variable \fBCCACHE_PREFIX\fR to the name of the wrapper (e\&.g\&. \fBdistcc\fR) and ccache will prefix the command line with the specified command when running the compiler\&.
1086
Unless you set \fBCCACHE_COMPILERCHECK\fR to a suitable command (see the description of that configuration option), it is not recommended to use the form \fBccache anotherwrapper compiler args\fR as the compilation command\&. It\(cqs also not recommended to use the masquerading technique for the other compiler wrapper\&. The reason is that by default, ccache will in both cases hash the mtime and size of the other wrapper instead of the real compiler, which means that:
1090
\h'-04'\(bu\h'+03'\c
1096
Compiler upgrades will not be detected properly\&.
1101
\h'-04'\(bu\h'+03'\c
1107
The cached results will not be shared between compilations with and without the other wrapper\&.
1110
Another minor thing is that if \fBCCACHE_PREFIX\fR is not used, ccache will needlessly invoke the other wrapper when running the preprocessor\&.
1131
If \(lqpreprocessor error\(rq has been incremented, one possible reason is that precompiled headers are being used\&. ccache currently doesn\(cqt handle that\&.
1136
\h'-04'\(bu\h'+03'\c
1142
1325
If \(lqunsupported compiler option\(rq has been incremented, enable debug logging and check which option was rejected\&.
1330
\h'-04'\(bu\h'+03'\c
1336
If \(lqpreprocessor error\(rq has been incremented, one possible reason is that precompiled headers are being used\&. See
1338
for how to remedy this\&.
1343
\h'-04'\(bu\h'+03'\c
1349
If \(lqcan\(cqt use precompiled header\(rq has been incremented, see
1350
PRECOMPILED HEADERS\&.
1144
1352
.SS "Errors when compiling with ccache"
1146
1354
If compilation doesn\(cqt work with ccache, but it works without it, one possible reason is that the compiler can\(cqt compile preprocessed output correctly\&. A workaround that may work is to set \fBCCACHE_CPP2\fR\&. This will make cache misses slower, though, so it is better to find and fix the root cause\&.
1154
1362
Credits, mailing list information, bug reporting instructions, source code, etc, can be found on ccache\(cqs web site: http://ccache\&.samba\&.org\&.
1157
ccache is currently maintained by Joel Rosdahl and was originally written by Andrew Tridgell\&. See http://ccache\&.samba\&.org/credits\&.html for a list of contributors\&.
1365
ccache was originally written by Andrew Tridgell and is currently developed and maintained by Joel Rosdahl\&. See AUTHORS\&.txt or AUTHORS\&.html and http://ccache\&.samba\&.org/credits\&.html for a list of contributors\&.