1CCACHE(1)                        ccache Manual                       CCACHE(1)
2
3
4

NAME

6       ccache - a fast C/C++ compiler cache
7

SYNOPSIS

9       ccache [options]
10       ccache compiler [compiler options]
11       compiler [compiler options]                   (via symbolic link)
12

DESCRIPTION

14       ccache is a compiler cache. It speeds up recompilation by caching the
15       result of previous compilations and detecting when the same compilation
16       is being done again. Supported languages are C, C++, Objective-C and
17       Objective-C++.
18
19       ccache has been carefully written to always produce exactly the same
20       compiler output that you would get without the cache. The only way you
21       should be able to tell that you are using ccache is the speed.
22       Currently known exceptions to this goal are listed under BUGS. If you
23       ever discover an undocumented case where ccache changes the output of
24       your compiler, please let us know.
25
26   Features
27       ·   Keeps statistics on hits/misses.
28
29       ·   Automatic cache size management.
30
31       ·   Can cache compilations that generate warnings.
32
33       ·   Easy installation.
34
35       ·   Low overhead.
36
37       ·   Optionally uses hard links where possible to avoid copies.
38
39       ·   Optionally compresses files in the cache to reduce disk space.
40
41   Limitations
42       ·   Only knows how to cache the compilation of a single
43           C/C++/Objective-C/Objective-C++ file. Other types of compilations
44           (multi-file compilation, linking, etc) will silently fall back to
45           running the real compiler.
46
47       ·   Only works with GCC and compilers that behave similar enough.
48
49       ·   Some compiler flags are not supported. If such a flag is detected,
50           ccache will silently fall back to running the real compiler.
51

RUN MODES

53       There are two ways to use ccache. You can either prefix your
54       compilation commands with ccache or you can let ccache masquerade as
55       the compiler by creating a symbolic link (named as the compiler) to
56       ccache. The first method is most convenient if you just want to try out
57       ccache or wish to use it for some specific projects. The second method
58       is most useful for when you wish to use ccache for all your
59       compilations.
60
61       To use the first method, just make sure that ccache is in your PATH.
62
63       To use the symlinks method, do something like this:
64
65           cp ccache /usr/local/bin/
66           ln -s ccache /usr/local/bin/gcc
67           ln -s ccache /usr/local/bin/g++
68           ln -s ccache /usr/local/bin/cc
69           ln -s ccache /usr/local/bin/c++
70
71       And so forth. This will work as long as the directory with symlinks
72       comes before the path to the compiler (which is usually in /usr/bin).
73       After installing you may wish to run “which gcc” to make sure that the
74       correct link is being used.
75
76           Warning
77           The technique of letting ccache masquerade as the compiler works
78           well, but currently doesn’t interact well with other tools that do
79           the same thing. See USING CCACHE WITH OTHER COMPILER WRAPPERS.
80
81           Warning
82           Do not use a hard link, use a symbolic link. A hard link will cause
83           “interesting” problems.
84

OPTIONS

86       These options only apply when you invoke ccache as “ccache”. When
87       invoked as a compiler (via a symlink as described in the previous
88       section), the normal compiler options apply and you should refer to the
89       compiler’s documentation.
90
91       -c, --cleanup
92           Clean up the cache by removing old cached files until the specified
93           file number and cache size limits are not exceeded. This also
94           recalculates the cache file count and size totals. Normally, it’s
95           not needed to initiate cleanup manually as ccache keeps the cache
96           below the specified limits at runtime and keeps statistics up to
97           date on each compilation. Forcing a cleanup is mostly useful if you
98           manually modify the cache contents or believe that the cache size
99           statistics may be inaccurate.
100
101       -C, --clear
102           Clear the entire cache, removing all cached files.
103
104       -F, --max-files=N
105           Set the maximum number of files allowed in the cache. The value is
106           stored inside the cache directory and applies to all future
107           compilations. Due to the way the value is stored the actual value
108           used is always rounded down to the nearest multiple of 16.
109
110       -h, --help
111           Print an options summary page.
112
113       -M, --max-size=SIZE
114           Set the maximum size of the files stored in the cache. You can
115           specify a value in gigabytes, megabytes or kilobytes by appending a
116           G, M or K to the value. The default is gigabytes. The actual value
117           stored is rounded down to the nearest multiple of 16 kilobytes.
118
119       -s, --show-stats
120           Print the current statistics summary for the cache.
121
122       -V, --version
123           Print version and copyright information.
124
125       -z, --zero-stats
126           Zero the cache statistics (but not the configured limits).
127

EXTRA OPTIONS

129       When run as a compiler, ccache usually just takes the same command line
130       options as the compiler you are using. The only exception to this is
131       the option --ccache-skip. That option can be used to tell ccache to
132       avoid interpreting the next option in any way and to pass it along to
133       the compiler as-is.
134
135       The reason this can be important is that ccache does need to parse the
136       command line and determine what is an input filename and what is a
137       compiler option, as it needs the input filename to determine the name
138       of the resulting object file (among other things). The heuristic ccache
139       uses when parsing the command line is that any argument that exists as
140       a file is treated as an input file name. By using --ccache-skip you can
141       force an option to not be treated as an input file name and instead be
142       passed along to the compiler as a command line option.
143
144       Another case where --ccache-skip can be useful is if ccache interprets
145       an option specially but shouldn’t, since the option has another meaning
146       for your compiler than what ccache thinks.
147

ENVIRONMENT VARIABLES

149       ccache uses a number of environment variables to control operation. In
150       most cases you won’t need any of these as the defaults will be fine.
151
152       CCACHE_BASEDIR
153           If you set the environment variable CCACHE_BASEDIR to an absolute
154           path to a directory, ccache rewrites absolute paths into relative
155           paths before computing the hash that identifies the compilation,
156           but only for paths under the specified directory. See the
157           discussion under COMPILING IN DIFFERENT DIRECTORIES.
158
159       CCACHE_CC
160           You can optionally set CCACHE_CC to force the name of the compiler
161           to use. If you don’t do this then ccache works it out from the
162           command line.
163
164       CCACHE_COMPILERCHECK
165           By default, ccache includes the modification time (“mtime”) and
166           size of the compiler in the hash to ensure that results retrieved
167           from the cache are accurate. The CCACHE_COMPILERCHECK environment
168           variable can be used to select another strategy. Possible values
169           are:
170
171           content
172               Hash the content of the compiler binary. This makes ccache very
173               slightly slower compared to the mtime setting, but makes it
174               cope better with compiler upgrades during a build bootstrapping
175               process.
176
177           mtime
178               Hash the compiler’s mtime and size, which is fast. This is the
179               default.
180
181           none
182               Don’t hash anything. This may be good for situations where you
183               can safely use the cached results even though the compiler’s
184               mtime or size has changed (e.g. if the compiler is built as
185               part of your build system and the compiler’s source has not
186               changed, or if the compiler only has changes that don’t affect
187               code generation). You should only use the none setting if you
188               know what you are doing.
189
190           a command string
191               Hash the standard output and standard error output of the
192               specified command. The string will be split on whitespace to
193               find out the command and arguments to run. No other
194               interpretation of the command string will be done, except that
195               the special word “%compiler%” will be replaced with the path to
196               the compiler. Several commands can be specified with semicolon
197               as separator. Examples:
198
199               ·    %compiler% -v
200
201               ·    %compiler% -dumpmachine; %compiler% -dumpversion
202
203               You should make sure that the specified command is as fast as
204               possible since it will be run once for each ccache invocation.
205
206               Identifying the compiler using a command is useful if you want
207               to avoid cache misses when the compiler has been rebuilt but
208               not changed.
209
210               Another case is when the compiler (as seen by ccache) actually
211               isn’t the real compiler but another compiler wrapper — in that
212               case, the default mtime method will hash the mtime and size of
213               the other compiler wrapper, which means that ccache won’t be
214               able to detect a compiler upgrade. Using a suitable command to
215               identify the compiler is thus safer, but it’s also slower, so
216               you should consider continue using the mtime method in
217               combination with CCACHE_PREFIX if possible. See USING CCACHE
218               WITH OTHER COMPILER WRAPPERS.
219
220       CCACHE_COMPRESS
221           If you set the environment variable CCACHE_COMPRESS then ccache
222           will compress object files and other compiler output it puts in the
223           cache. However, this setting has no effect on how files are
224           retrieved from the cache; compressed and uncompressed results will
225           still be usable regardless of this setting.
226
227       CCACHE_CPP2
228           If you set the environment variable CCACHE_CPP2 then ccache will
229           not use the optimisation of avoiding the second call to the
230           preprocessor by compiling the preprocessed output that was used for
231           finding the hash in the case of a cache miss. This is primarily a
232           debugging option, although it is possible that some unusual
233           compilers will have problems with the intermediate filename
234           extensions used in this optimisation, in which case this option
235           could allow ccache to be used anyway.
236
237       CCACHE_DETECT_SHEBANG
238           The CCACHE_DETECT_SHEBANG environment variable only has meaning on
239           Windows. It instructs ccache to open the executable file to detect
240           the #!/bin/sh string, in which case ccache will search for sh.exe
241           in PATH and use that to launch the executable.
242
243       CCACHE_DIR
244           The CCACHE_DIR environment variable specifies where ccache will
245           keep its cached compiler output. The default is $HOME/.ccache.
246
247       CCACHE_DISABLE
248           If you set the environment variable CCACHE_DISABLE then ccache will
249           just call the real compiler, bypassing the cache completely.
250
251       CCACHE_EXTENSION
252           ccache tries to automatically determine the extension to use for
253           intermediate preprocessor files based on the type of file being
254           compiled. Unfortunately this sometimes doesn’t work, for example
255           when using the “aCC” compiler on HP-UX. On systems like this you
256           can use the CCACHE_EXTENSION option to override the default. On
257           HP-UX set this environment variable to i if you use the “aCC”
258           compiler.
259
260       CCACHE_EXTRAFILES
261           If you set the environment variable CCACHE_EXTRAFILES to a list of
262           paths then ccache will include the contents of those files when
263           calculating the hash sum. The list separator is semicolon in
264           Windows systems and colon on other systems.
265
266       CCACHE_HARDLINK
267           If you set the environment variable CCACHE_HARDLINK then ccache
268           will attempt to use hard links from the cache directory when
269           creating the compiler output rather than using a file copy. Using
270           hard links may be slightly faster in some situations, but can
271           confuse programs like “make” that rely on modification times.
272           Another thing to keep in mind is that if the resulting object file
273           is modified in any way, this corrupts the cached object file as
274           well. Hard links are never made for compressed cache files. This
275           means that you should not set the CCACHE_COMPRESS variable if you
276           want to use hard links.
277
278       CCACHE_HASHDIR
279           This tells ccache to hash the current working directory when
280           calculating the hash that is used to distinguish two compilations.
281           This prevents a problem with the storage of the current working
282           directory in the debug info of a object file, which can lead ccache
283           to give a cached object file that has the working directory in the
284           debug info set incorrectly. This option is off by default as the
285           incorrect setting of this debug info rarely causes problems. If you
286           strike problems with GDB not using the correct directory then
287           enable this option.
288
289       CCACHE_LOGFILE
290           If you set the CCACHE_LOGFILE environment variable then ccache will
291           write information on what it is doing to the specified file. This
292           is useful for tracking down problems.
293
294       CCACHE_NLEVELS
295           The environment variable CCACHE_NLEVELS allows you to choose the
296           number of levels of hash in the cache directory. The default is 2.
297           The minimum is 1 and the maximum is 8.
298
299       CCACHE_NODIRECT
300           If you set the environment variable CCACHE_NODIRECT then ccache
301           will not use the direct mode.
302
303       CCACHE_NOSTATS
304           If you set the environment variable CCACHE_NOSTATS then ccache will
305           not update the statistics files on each compilation.
306
307       CCACHE_PATH
308           You can optionally set CCACHE_PATH to a colon-separated path where
309           ccache will look for the real compilers. If you don’t do this then
310           ccache will look for the first executable matching the compiler
311           name in the normal PATH that isn’t a symbolic link to ccache
312           itself.
313
314       CCACHE_PREFIX
315           This option adds a prefix to the command line that ccache runs when
316           invoking the compiler. Also see the section below on using ccache
317           with “distcc”.
318
319       CCACHE_READONLY
320           The CCACHE_READONLY environment variable tells ccache to attempt to
321           use existing cached object files, but not to try to add anything
322           new to the cache. If you are using this because your CCACHE_DIR is
323           read-only, then you may find that you also need to set
324           CCACHE_TEMPDIR as otherwise ccache will fail to create temporary
325           files.
326
327       CCACHE_RECACHE
328           This forces ccache to not use any cached results, even if it finds
329           them. New results are still cached, but existing cache entries are
330           ignored.
331
332       CCACHE_SLOPPINESS
333           By default, ccache tries to give as few false cache hits as
334           possible. However, in certain situations it’s possible that you
335           know things that ccache can’t take for granted. The
336           CCACHE_SLOPPINESS environment variable makes it possible to tell
337           ccache to relax some checks in order to increase the hit rate. The
338           value should be a comma-separated string with options. Available
339           options are:
340
341           file_macro
342               Ignore __FILE__ being present in the source.
343
344           include_file_mtime
345               Don’t check the modification time of include files in the
346               direct mode.
347
348           time_macros
349               Ignore __DATE__ and __TIME__ being present in the source code.
350
351           See the discussion under TROUBLESHOOTING for more information.
352
353       CCACHE_TEMPDIR
354           The CCACHE_TEMPDIR environment variable specifies where ccache will
355           put temporary files. The default is $CCACHE_DIR/tmp.
356
357               Note
358               In previous versions of ccache, CCACHE_TEMPDIR had to be on the
359               same filesystem as the CCACHE_DIR path, but this requirement
360               has been relaxed.)
361
362       CCACHE_UMASK
363           This sets the umask for ccache and all child processes (such as the
364           compiler). This is mostly useful when you wish to share your cache
365           with other users. Note that this also affects the file permissions
366           set on the object files created from your compilations.
367
368       CCACHE_UNIFY
369           If you set the environment variable CCACHE_UNIFY then ccache will
370           use a C/C++ unifier when hashing the preprocessor output if the -g
371           option is not used. The unifier is slower than a normal hash, so
372           setting this environment variable loses a little bit of speed, but
373           it means that ccache can take advantage of not recompiling when the
374           changes to the source code consist of reformatting only. Note that
375           using CCACHE_UNIFY changes the hash, so cached compilations with
376           CCACHE_UNIFY set cannot be used when CCACHE_UNIFY is not set and
377           vice versa. The reason the unifier is off by default is that it can
378           give incorrect line number information in compiler warning
379           messages. Also note that enabling the unifier implies turning off
380           the direct mode.
381

CACHE SIZE MANAGEMENT

383       By default ccache has a one gigabyte limit on the total size of files
384       in the cache and no maximum number of files. You can set different
385       limits using the -M/--max-size and -F/--max-files options. Use ccache
386       -s/--show-stats to see the cache size and the currently configured
387       limits (in addition to other various statistics).
388

CACHE COMPRESSION

390       ccache can optionally compress all files it puts into the cache using
391       the compression library zlib. While this involves a negligible
392       performance slowdown, it significantly increases the number of files
393       that fit in the cache. You can turn on compression by setting the
394       CCACHE_COMPRESS environment variable.
395

HOW CCACHE WORKS

397       The basic idea is to detect when you are compiling exactly the same
398       code a second time and reuse the previously produced output. The
399       detection is done by hashing different kinds of information that should
400       be unique for the compilation and then using the hash sum to identify
401       the cached output. ccache uses MD4, a very fast cryptographic hash
402       algorithm, for the hashing. (MD4 is nowadays too weak to be useful in
403       cryptographic contexts, but it should be safe enough to be used to
404       identify recompilations.) On a cache hit, ccache is able to supply all
405       of the correct compiler outputs (including all warnings, dependency
406       file, etc) from the cache.
407
408       ccache has two ways of doing the detection:
409
410       ·   the direct mode, where ccache hashes the source code and include
411           files directly
412
413       ·   the preprocessor mode, where ccache runs the preprocessor on the
414           source code and hashes the result
415
416       The direct mode is generally faster since running the preprocessor has
417       some overhead.
418
419   Common hashed information
420       For both modes, the following information is included in the hash:
421
422       ·   the extension used by the compiler for a file with preprocessor
423           output (normally .i for C code and .ii for C++ code)
424
425       ·   the compiler’s size and modification time (or other
426           compiler-specific information specified by CCACHE_COMPILERCHECK)
427
428       ·   the name of the compiler
429
430       ·   the current directory (if CCACHE_HASHDIR is set)
431
432       ·   contents of files specified by CCACHE_EXTRAFILES (if any)
433
434   The direct mode
435       In the direct mode, the hash is formed of the common information and:
436
437       ·   the input source file
438
439       ·   the command line options
440
441       Based on the hash, a data structure called “manifest” is looked up in
442       the cache. The manifest contains:
443
444       ·   references to cached compilation results (object file, dependency
445           file, etc) that were produced by previous compilations that matched
446           the hash
447
448       ·   paths to the include files that were read at the time the
449           compilation results were stored in the cache
450
451       ·   hash sums of the include files at the time the compilation results
452           were stored in the cache
453
454       The current contents of the include files are then hashed and compared
455       to the information in the manifest. If there is a match, ccache knows
456       the result of the compilation. If there is no match, ccache falls back
457       to running the preprocessor. The output from the preprocessor is parsed
458       to find the include files that were read. The paths and hash sums of
459       those include files are then stored in the manifest along with
460       information about the produced compilation result.
461
462       The direct mode will be disabled if any of the following holds:
463
464       ·   the environment variable CCACHE_NODIRECT is set
465
466       ·   a modification time of one of the include files is too new (needed
467           to avoid a race condition)
468
469       ·   the unifier is enabled (the environment variable CCACHE_UNIFY is
470           set)
471
472       ·   a compiler option not supported by the direct mode is used:
473
474           ·   a -Wp,X compiler option other than -Wp,-MD,path and
475               -Wp,-MMD,path
476
477           ·    -Xpreprocessor
478
479       ·   the string “__TIME__” is present outside comments and string
480           literals in the source code
481
482   The preprocessor mode
483       In the preprocessor mode, the hash is formed of the common information
484       and:
485
486       ·   the preprocessor output from running the compiler with -E
487
488       ·   the command line options except options that affect include files
489           (-I, -include, -D, etc; the theory is that these options will
490           change the preprocessor output if they have any effect at all)
491
492       ·   any standard error output generated by the preprocessor
493
494       Based on the hash, the cached compilation result can be looked up
495       directly in the cache.
496

COMPILING IN DIFFERENT DIRECTORIES

498       Some information included in the hash that identifies a unique
499       compilation may contain absolute paths:
500
501       ·   The preprocessed source code may contain absolute paths to include
502           files if the compiler option -g is used or if absolute paths are
503           given to -I and similar compiler options.
504
505       ·   Paths specified by compiler options (such as -I, -MF, etc) may be
506           absolute.
507
508       ·   The source code file path may be absolute, and that path may
509           substituted for __FILE__ macros in the source code or included in
510           warnings emitted to standard error by the preprocessor.
511
512       This means that if you compile the same code in different locations,
513       you can’t share compilation results between the different build
514       directories since you get cache misses because of the absolute build
515       directory paths that are part of the hash. To mitigate this problem,
516       you can specify a “base directory” by setting the CCACHE_BASEDIR
517       variable to an absolute path to the directory. ccache will then rewrite
518       absolute paths that are under the base directory (i.e., paths that have
519       the base directory as a prefix) to relative paths when constructing the
520       hash. A typical path to use as the base directory is your home
521       directory or another directory that is a parent of your build
522       directories. (Don’t use / as the base directory since that will make
523       ccache also rewrite paths to system header files, which doesn’t gain
524       anything.)
525
526       The drawbacks of using CCACHE_BASEDIR are:
527
528       ·   If you specify an absolute path to the source code file, __FILE__
529           macros will be expanded to a relative path instead.
530
531       ·   If you specify an absolute path to the source code file and compile
532           with -g, the source code path stored in the object file may point
533           to the wrong directory, which may prevent debuggers like GDB from
534           finding the source code. Sometimes, a work-around is to change the
535           directory explicitly with the “cd” command in GDB.
536

PRECOMPILED HEADERS

538       ccache has support for GCC’s precompiled headers. However, you have to
539       do some things to make it work properly:
540
541       ·   You must set CCACHE_SLOPPINESS to time_macros. The reason is that
542           ccache can’t tell whether __TIME__ or __DATE__ is used when using a
543           precompiled header.
544
545       ·   You must either:
546
547           ·   use the -include compiler option to include the precompiled
548               header (i.e., don’t use #include in the source code to include
549               the header); or
550
551           ·   add the -fpch-preprocess compiler option when compiling.
552
553           If you don’t do this, either the non-precompiled version of the
554           header file will be used (if available) or ccache will fall back to
555           running the real compiler and increase the statistics counter
556           “preprocessor error” (if the non-precompiled header file is not
557           available).
558

SHARING A CACHE

560       A group of developers can increase the cache hit rate by sharing a
561       cache directory. To share a cache without unpleasant side effects, the
562       following conditions should to be met:
563
564       ·   Use the same CCACHE_DIR environment variable setting.
565
566       ·   Unset the CCACHE_HARDLINK environment variable.
567
568       ·   Make sure everyone sets the CCACHE_UMASK environment variable to
569           002. This ensures that cached files are accessible to everyone in
570           the group.
571
572       ·   Make sure that all users have write permission in the entire cache
573           directory (and that you trust all users of the shared cache).
574
575       ·   Make sure that the setgid bit is set on all directories in the
576           cache. This tells the filesystem to inherit group ownership for new
577           directories. The command “find $CCACHE_DIR -type d | xargs chmod
578           g+s” might be useful for this.
579
580       The reason to avoid the hard link mode is that the hard links cause
581       unwanted side effects, as all links to a cached file share the file’s
582       modification timestamp. This results in false dependencies to be
583       triggered by timestamp-based build systems whenever another user links
584       to an existing file. Typically, users will see that their libraries and
585       binaries are relinked without reason.
586
587       You may also want to make sure that the developers have CCACHE_BASEDIR
588       set appropriately, as discussed in the previous section.
589

SHARING A CACHE ON NFS

591       It is possible to put the cache directory on an NFS filesystem (or
592       similar filesystems), but keep in mind that:
593
594       ·   Having the cache on NFS may slow down compilation. Make sure to do
595           some benchmarking to see if it’s worth it.
596
597       ·   ccache hasn’t been tested very thoroughly on NFS.
598
599       A tip is to set CCACHE_TEMPDIR to a directory on the local host to
600       avoid NFS traffic for temporary files.
601

USING CCACHE WITH OTHER COMPILER WRAPPERS

603       The recommended way of combining ccache with another compiler wrapper
604       (such as “distcc”) is by using the CCACHE_PREFIX option. You just need
605       to set the environment variable CCACHE_PREFIX to the name of the
606       wrapper (e.g. distcc) and ccache will prefix the command line with the
607       specified command when running the compiler.
608
609       Unless you set CCACHE_COMPILERCHECK to a suitable command (see the
610       description of that configuration option), it is not recommended to use
611       the form ccache anotherwrapper compiler args as the compilation
612       command. It’s also not recommended to use the masquerading technique
613       for the other compiler wrapper. The reason is that by default, ccache
614       will in both cases hash the mtime and size of the other wrapper instead
615       of the real compiler, which means that:
616
617       ·   Compiler upgrades will not be detected properly.
618
619       ·   The cached results will not be shared between compilations with and
620           without the other wrapper.
621
622       Another minor thing is that if CCACHE_PREFIX is not used, ccache will
623       needlessly invoke the other wrapper when running the preprocessor.
624

BUGS

626       ·   ccache doesn’t handle the GNU Assembler’s .incbin directive
627           correctly. This directive can be embedded in the source code inside
628           an asm statement in order to include a file verbatim in the object
629           file. If the included file is modified, ccache doesn’t pick up the
630           change since the inclusion isn’t done by the preprocessor. A
631           workaround of this problem is to set CCACHE_EXTRAFILES to the path
632           of the included file.
633

TROUBLESHOOTING

635   General
636       A general tip for getting information about what ccache is doing is to
637       enable debug logging by setting CCACHE_LOGFILE. The log contains
638       executed commands, important decisions that ccache makes, read and
639       written files, etc. Another way of keeping track of what is happening
640       is to check the output of ccache -s.
641
642   Performance
643       ccache has been written to perform well out of the box, but sometimes
644       you may have to do some adjustments of how you use the compiler and
645       ccache in order to improve performance.
646
647       Since ccache works best when I/O is fast, put the cache directory on a
648       fast storage device if possible. Having lots of free memory so that
649       files in the cache directory stay in the disk cache is also
650       preferrable.
651
652       A good way of monitoring how well ccache works is to run ccache -s
653       before and after your build and then compare the statistics counters.
654       Here are some common problems and what may be done to increase the hit
655       rate:
656
657       ·   If “cache hit (preprocessed)” has been incremented instead of
658           “cache hit (direct)”, ccache has fallen back to preprocessor mode,
659           which is generally slower. Some possible reasons are:
660
661           ·   The source code has been modified in such a way that the
662               preprocessor output is not affected.
663
664           ·   Compiler arguments that are hashed in the direct mode but not
665               in the preprocessor mode have changed (-I, -include, -D, etc)
666               and they didn’t affect the preprocessor output.
667
668           ·   The compiler option -Xpreprocessor or -Wp,X (except
669               -Wp,-MD,path and Wp,-MMD,path) is used.
670
671           ·   This was the first compilation with a new value of
672               CCACHE_BASEDIR.
673
674           ·   A modification time of one of the include files is too new
675               (created the same second as the compilation is being done).
676               This check is made to avoid a race condition. To fix this,
677               create the include file earlier in the build process, if
678               possible, or set CCACHE_SLOPPINESS to include_file_mtime if you
679               are willing to take the risk. (The race condition consists of
680               these events: the preprocessor is run; an include file is
681               modified by someone; the new include file is hashed by ccache;
682               the real compiler is run on the preprocessor’s output, which
683               contains data from the old header file; the wrong object file
684               is stored in the cache.)
685
686           ·   The __TIME__ preprocessor macro is (potentially) being used.
687               ccache turns off direct mode if “__TIME__” is present in the
688               source code outside comments and string literals. This is done
689               as a safety measure since the string indicates that a __TIME__
690               macro may affect the output. (To be sure, ccache would have to
691               run the preprocessor, but the sole point of the direct mode is
692               to avoid that.) If you know that __TIME__ isn’t used in
693               practise, or don’t care if ccache produces objects where
694               __TIME__ is expanded to something in the past, you can set
695               CCACHE_SLOPPINESS to time_macros.
696
697           ·   The __DATE__ preprocessor macro is (potentially) being used and
698               the date has changed. This is similar to how __TIME__ is
699               handled. If “__DATE__” is present in the source code outside
700               comments and string literals, ccache hashes the current date in
701               order to be able to produce the correct object file if the
702               __DATE__ macro affects the output. If you know that __DATE__
703               isn’t used in practise, or don’t care if ccache produces
704               objects where __DATE__ is expanded to something in the past,
705               you can set CCACHE_SLOPPINESS to time_macros.
706
707           ·   The __FILE__ preprocessor macro is (potentially) being used and
708               the file path has changed. If “__FILE__” is present in the
709               source code outside comments and string literals, ccache hashes
710               the current input file path in order to be able to produce the
711               correct object file if the __FILE__ macro affects the output.
712               If you know that __FILE__ isn’t used in practise, or don’t care
713               if ccache produces objects where __FILE__ is expanded to the
714               wrong path, you can set CCACHE_SLOPPINESS to file_macro.
715
716       ·   If “cache miss” has been incremented even though the same code has
717           been compiled and cached before, ccache has either detected that
718           something has changed anyway or a cleanup has been performed
719           (either explicitly or implicitly when a cache limit has been
720           reached). Some perhaps unobvious things that may result in a cache
721           miss are usage of __TIME__ or __DATE__ macros, or use of
722           automatically generated code that contains a timestamp, build
723           counter or other volatile information.
724
725       ·   If “multiple source files” has been incremented, it’s an indication
726           that the compiler has been invoked on several source code files at
727           once. ccache doesn’t support that. Compile the source code files
728           separately if possible.
729
730       ·   If “unsupported compiler option” has been incremented, enable debug
731           logging and check which option was rejected.
732
733       ·   If “preprocessor error” has been incremented, one possible reason
734           is that precompiled headers are being used. See PRECOMPILED HEADERS
735           for how to remedy this.
736
737       ·   If “can’t use precompiled header” has been incremented, see
738           PRECOMPILED HEADERS.
739
740   Errors when compiling with ccache
741       If compilation doesn’t work with ccache, but it works without it, one
742       possible reason is that the compiler can’t compile preprocessed output
743       correctly. A workaround that may work is to set CCACHE_CPP2. This will
744       make cache misses slower, though, so it is better to find and fix the
745       root cause.
746
747   Corrupt object files
748       It should be noted that ccache is susceptible to general storage
749       problems. If a bad object file sneaks into the cache for some reason,
750       it will of course stay bad. Some possible reasons for erroneous object
751       files are bad hardware (disk drive, disk controller, memory, etc),
752       buggy drivers or file systems, a bad CCACHE_PREFIX command or compiler
753       wrapper. If this happens, you can either find out which object file is
754       broken by reading the debug log and then delete the bad object file
755       from the cache, or you can simply clear the whole cache with ccache -C
756       if you don’t mind losing other cached results.
757
758       There are no reported issues about ccache producing broken object files
759       reproducibly. That doesn’t mean it can’t happen, so if you find a
760       repeatable case, please report it.
761

MORE INFORMATION

763       Credits, mailing list information, bug reporting instructions, source
764       code, etc, can be found on ccache’s web site: http://ccache.samba.org.
765

AUTHOR

767       ccache was originally written by Andrew Tridgell and is currently
768       developed and maintained by Joel Rosdahl. See AUTHORS.txt or
769       AUTHORS.html and http://ccache.samba.org/credits.html for a list of
770       contributors.
771
772
773
774ccache 3.1.4                      01/09/2011                         CCACHE(1)
Impressum