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 CAVEATS. If
23       you ever discover an undocumented case where ccache changes the output
24       of 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 compresses files in the cache to reduce disk space.
38
39   Limitations
40       ·   Only knows how to cache the compilation of a single
41           C/C++/Objective-C/Objective-C++ file. Other types of compilations
42           (multi-file compilation, linking, etc) will silently fall back to
43           running the real compiler.
44
45       ·   Only works with GCC and compilers that behave similar enough.
46
47       ·   Some compiler flags are not supported. If such a flag is detected,
48           ccache will silently fall back to running the real compiler.
49

RUN MODES

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

OPTIONS

84       These options only apply when you invoke ccache as “ccache”. When
85       invoked as a compiler (via a symlink as described in the previous
86       section), the normal compiler options apply and you should refer to the
87       compiler’s documentation.
88
89       -c, --cleanup
90           Clean up the cache by removing old cached files until the specified
91           file number and cache size limits are not exceeded. This also
92           recalculates the cache file count and size totals. Normally, there
93           is no need to initiate cleanup manually as ccache keeps the cache
94           below the specified limits at runtime and keeps statistics up to
95           date on each compilation. Forcing a cleanup is mostly useful if you
96           manually modify the cache contents or believe that the cache size
97           statistics may be inaccurate.
98
99       -C, --clear
100           Clear the entire cache, removing all cached files, but keeping the
101           configuration file.
102
103       --dump-manifest=PATH
104           Dump manifest file at PATH in text format. This is only useful when
105           debugging ccache and its behavior.
106
107       -k, --get-config=KEY
108           Print the value of configuration option KEY. See CONFIGURATION for
109           more information.
110
111       --hash-file=PATH
112           Print the hash (in format <MD4>-<size>) of the file at PATH. This
113           is only useful when debugging ccache and its behavior.
114
115       -h, --help
116           Print an options summary page.
117
118       -F, --max-files=N
119           Set the maximum number of files allowed in the cache. Use 0 for no
120           limit. The value is stored in a configuration file in the cache
121           directory and applies to all future compilations.
122
123       -M, --max-size=SIZE
124           Set the maximum size of the files stored in the cache.  SIZE should
125           be a number followed by an optional suffix: k, M, G, T (decimal),
126           Ki, Mi, Gi or Ti (binary). The default suffix is G. Use 0 for no
127           limit. The value is stored in a configuration file in the cache
128           directory and applies to all future compilations.
129
130       --print-stats
131           Print statistics counter IDs and corresponding values
132           machine-parsable (tab-separated) format.
133
134       -o, --set-config=KEY=VALUE
135           Set configuration option KEY to VALUE. See CONFIGURATION for more
136           information.
137
138       -p, --show-config
139           Print current configuration options and from where they originate
140           (environment variable, configuration file or compile-time default)
141           in human-readable format.
142
143       -s, --show-stats
144           Print a summary of configuration and statistics counters in
145           human-readable format.
146
147       -V, --version
148           Print version and copyright information.
149
150       -z, --zero-stats
151           Zero the cache statistics (but not the configuration options).
152

EXTRA OPTIONS

154       When run as a compiler, ccache usually just takes the same command line
155       options as the compiler you are using. The only exception to this is
156       the option --ccache-skip. That option can be used to tell ccache to
157       avoid interpreting the next option in any way and to pass it along to
158       the compiler as-is.
159
160           Note
161           --ccache-skip currently only tells ccache not to interpret the next
162           option as a special compiler option — the option will still be
163           included in the direct mode hash.
164
165       The reason this can be important is that ccache does need to parse the
166       command line and determine what is an input filename and what is a
167       compiler option, as it needs the input filename to determine the name
168       of the resulting object file (among other things). The heuristic ccache
169       uses when parsing the command line is that any argument that exists as
170       a file is treated as an input file name. By using --ccache-skip you can
171       force an option to not be treated as an input file name and instead be
172       passed along to the compiler as a command line option.
173
174       Another case where --ccache-skip can be useful is if ccache interprets
175       an option specially but shouldn’t, since the option has another meaning
176       for your compiler than what ccache thinks.
177

CONFIGURATION

179       ccache’s default behavior can be overridden by configuration file
180       settings, which in turn can be overridden by environment variables with
181       names starting with CCACHE_. ccache normally reads configuration from
182       two files: first a system-level configuration file and secondly a
183       cache-specific configuration file. The priority of configuration
184       settings is as follows (where 1 is highest):
185
186        1. Environment variables.
187
188        2. The cache-specific configuration file <ccachedir>/ccache.conf
189           (typically $HOME/.ccache/ccache.conf).
190
191        3. The system-wide configuration file <sysconfdir>/ccache.conf
192           (typically /etc/ccache.conf or /usr/local/etc/ccache.conf).
193
194        4. Compile-time defaults.
195
196       As a special case, if the environment variable CCACHE_CONFIGPATH is
197       set, ccache reads configuration from the specified path instead of the
198       default paths.
199
200   Configuration file syntax
201       Configuration files are in a simple “key = value” format, one setting
202       per line. Lines starting with a hash sign are comments. Blank lines are
203       ignored, as is whitespace surrounding keys and values. Example:
204
205           # Set maximum cache size to 10 GB:
206           max_size = 10G
207
208   Boolean values
209       Some settings are boolean values (i.e. truth values). In a
210       configuration file, such values must be set to the string true or
211       false. For the corresponding environment variables, the semantics are a
212       bit different: a set environment variable means “true” (even if set to
213       the empty string), the following case-insensitive negative values are
214       considered an error (rather than surprising the user): 0, false,
215       disable and no, and an unset environment variable means “false”. Each
216       boolean environment variable also has a negated form starting with
217       CCACHE_NO. For example, CCACHE_COMPRESS can be set to force compression
218       and CCACHE_NOCOMPRESS can be set to force no compression.
219
220   Configuration settings
221       Below is a list of available configuration settings. The corresponding
222       environment variable name is indicated in parentheses after each
223       configuration setting key.
224
225       base_dir (CCACHE_BASEDIR)
226           This setting should be an absolute path to a directory. ccache then
227           rewrites absolute paths into relative paths before computing the
228           hash that identifies the compilation, but only for paths under the
229           specified directory. If set to the empty string (which is the
230           default), no rewriting is done. A typical path to use as the base
231           directory is your home directory or another directory that is a
232           parent of your build directories. Don’t use / as the base directory
233           since that will make ccache also rewrite paths to system header
234           files, which doesn’t gain anything.
235
236           See also the discussion under COMPILING IN DIFFERENT DIRECTORIES.
237
238       cache_dir (CCACHE_DIR)
239           This setting specifies where ccache will keep its cached compiler
240           outputs. It will only take effect if set in the system-wide
241           configuration file or as an environment variable. The default is
242           $HOME/.ccache.
243
244       cache_dir_levels (CCACHE_NLEVELS)
245           This setting allows you to choose the number of directory levels in
246           the cache directory. The default is 2. The minimum is 1 and the
247           maximum is 8.
248
249       compiler (CCACHE_COMPILER or (deprecated) CCACHE_CC)
250           This setting can be used to force the name of the compiler to use.
251           If set to the empty string (which is the default), ccache works it
252           out from the command line.
253
254       compiler_check (CCACHE_COMPILERCHECK)
255           By default, ccache includes the modification time (“mtime”) and
256           size of the compiler in the hash to ensure that results retrieved
257           from the cache are accurate. This setting can be used to select
258           another strategy. Possible values are:
259
260           content
261               Hash the content of the compiler binary. This makes ccache very
262               slightly slower compared to the mtime setting, but makes it
263               cope better with compiler upgrades during a build bootstrapping
264               process.
265
266           mtime
267               Hash the compiler’s mtime and size, which is fast. This is the
268               default.
269
270           none
271               Don’t hash anything. This may be good for situations where you
272               can safely use the cached results even though the compiler’s
273               mtime or size has changed (e.g. if the compiler is built as
274               part of your build system and the compiler’s source has not
275               changed, or if the compiler only has changes that don’t affect
276               code generation). You should only use the none setting if you
277               know what you are doing.
278
279           string:value
280               Use value as the string to calculate hash from. This can be the
281               compiler revision number you retrieved earlier and set here via
282               environment variable.
283
284           a command string
285               Hash the standard output and standard error output of the
286               specified command. The string will be split on whitespace to
287               find out the command and arguments to run. No other
288               interpretation of the command string will be done, except that
289               the special word %compiler% will be replaced with the path to
290               the compiler. Several commands can be specified with semicolon
291               as separator. Examples:
292
293                   %compiler% -v
294
295                   %compiler% -dumpmachine; %compiler% -dumpversion
296
297               You should make sure that the specified command is as fast as
298               possible since it will be run once for each ccache invocation.
299
300               Identifying the compiler using a command is useful if you want
301               to avoid cache misses when the compiler has been rebuilt but
302               not changed.
303
304               Another case is when the compiler (as seen by ccache) actually
305               isn’t the real compiler but another compiler wrapper — in that
306               case, the default mtime method will hash the mtime and size of
307               the other compiler wrapper, which means that ccache won’t be
308               able to detect a compiler upgrade. Using a suitable command to
309               identify the compiler is thus safer, but it’s also slower, so
310               you should consider continue using the mtime method in
311               combination with the prefix_command setting if possible. See
312               USING CCACHE WITH OTHER COMPILER WRAPPERS.
313
314       compression (CCACHE_COMPRESS or CCACHE_NOCOMPRESS, see Boolean values
315       above)
316           If true, ccache will compress object files and other compiler
317           output it puts in the cache. However, this setting has no effect on
318           how files are retrieved from the cache; compressed and uncompressed
319           results will still be usable regardless of this setting. The
320           default is false.
321
322       compression_level (CCACHE_COMPRESSLEVEL)
323           This setting determines the level at which ccache will compress
324           object files. It only has effect if compression is enabled. The
325           value defaults to 6, and must be no lower than 1 (fastest, worst
326           compression) and no higher than 9 (slowest, best compression).
327
328       cpp_extension (CCACHE_EXTENSION)
329           This setting can be used to force a certain extension for the
330           intermediate preprocessed file. The default is to automatically
331           determine the extension to use for intermediate preprocessor files
332           based on the type of file being compiled, but that sometimes
333           doesn’t work. For example, when using the “aCC” compiler on HP-UX,
334           set the cpp extension to i.
335
336       debug (CCACHE_DEBUG or CCACHE_NODEBUG, see Boolean values above)
337           If true, enable the debug mode. The debug mode creates per-object
338           debug files that are helpful when debugging unexpected cache
339           misses. Note however that ccache performance will be reduced
340           slightly. See debugging for more information. The default is false.
341
342       depend_mode (CCACHE_DEPEND or CCACHE_NODEPEND, see Boolean values
343       above)
344           If true, the depend mode will be used. The default is false. See
345           THE DEPEND MODE.
346
347       direct_mode (CCACHE_DIRECT or CCACHE_NODIRECT, see Boolean values
348       above)
349           If true, the direct mode will be used. The default is true. See THE
350           DIRECT MODE.
351
352       disable (CCACHE_DISABLE or CCACHE_NODISABLE, see Boolean values above)
353           When true, ccache will just call the real compiler, bypassing the
354           cache completely. The default is false.
355
356       extra_files_to_hash (CCACHE_EXTRAFILES)
357           This setting is a list of paths to files that ccache will include
358           in the the hash sum that identifies the build. The list separator
359           is semicolon on Windows systems and colon on other systems.
360
361       hard_link (CCACHE_HARDLINK or CCACHE_NOHARDLINK, see Boolean values
362       above)
363           If true, ccache will attempt to use hard links from the cache
364           directory when creating the compiler output rather than using a
365           file copy. Hard links are never made for compressed cache files.
366           This means that you should not enable compression if you want to
367           use hard links. The default is false.
368
369               Warning
370               Do not enable this option unless you are aware of the
371               consequences. Using hard links may be slightly faster in some
372               situations, but there are several pitfalls since the resulting
373               object file will share i-node with the cached object file:
374
375            1. If the resulting object file is modified in any way, the cached
376               object file will be modified as well. For instance, if you run
377               strip object.o or echo >object.o, you will corrupt the cache.
378
379            2. Programs that rely on modification times (like “make”) can be
380               confused since ccache updates the cached files' modification
381               times as part of the automatic cache size management. This will
382               affect object files in the build tree as well, which can
383               retrigger the linking step even though nothing really has
384               changed.
385
386       hash_dir (CCACHE_HASHDIR or CCACHE_NOHASHDIR, see Boolean values above)
387           If true (which is the default), ccache will include the current
388           working directory (CWD) in the hash that is used to distinguish two
389           compilations when generating debug info (compiler option -g with
390           variations). Exception: The CWD will not be included in the hash if
391           base_dir is set (and matches the CWD) and the compiler option
392           -fdebug-prefix-map is used. See also the discussion under COMPILING
393           IN DIFFERENT DIRECTORIES.
394
395           The reason for including the CWD in the hash by default is to
396           prevent a problem with the storage of the current working directory
397           in the debug info of an object file, which can lead ccache to
398           return a cached object file that has the working directory in the
399           debug info set incorrectly.
400
401           You can disable this setting to get cache hits when compiling the
402           same source code in different directories if you don’t mind that
403           CWD in the debug info might be incorrect.
404
405       ignore_headers_in_manifest (CCACHE_IGNOREHEADERS)
406           This setting is a list of paths to files (or directories with
407           headers) that ccache will not include in the manifest list that
408           makes up the direct mode. Note that this can cause stale cache hits
409           if those headers do indeed change. The list separator is semicolon
410           on Windows systems and colon on other systems.
411
412       keep_comments_cpp (CCACHE_COMMENTS or CCACHE_NOCOMMENTS, see Boolean
413       values above)
414           If true, ccache will not discard the comments before hashing
415           preprocessor output. This can be used to check documentation with
416           -Wdocumentation.
417
418       limit_multiple (CCACHE_LIMIT_MULTIPLE)
419           Sets the limit when cleaning up. Files are deleted (in LRU order)
420           until the levels are below the limit. The default is 0.8 (= 80%).
421           See AUTOMATIC CLEANUP for more information.
422
423       log_file (CCACHE_LOGFILE)
424           If set to a file path, ccache will write information on what it is
425           doing to the specified file. This is useful for tracking down
426           problems.
427
428       max_files (CCACHE_MAXFILES)
429           This option specifies the maximum number of files to keep in the
430           cache. Use 0 for no limit (which is the default). See also CACHE
431           SIZE MANAGEMENT.
432
433       max_size (CCACHE_MAXSIZE)
434           This option specifies the maximum size of the cache. Use 0 for no
435           limit. The default value is 5G. Available suffixes: k, M, G, T
436           (decimal) and Ki, Mi, Gi, Ti (binary). The default suffix is G. See
437           also CACHE SIZE MANAGEMENT.
438
439       path (CCACHE_PATH)
440           If set, ccache will search directories in this list when looking
441           for the real compiler. The list separator is semicolon on Windows
442           systems and colon on other systems. If not set, ccache will look
443           for the first executable matching the compiler name in the normal
444           PATH that isn’t a symbolic link to ccache itself.
445
446       pch_external_checksum (CCACHE_PCH_EXTSUM or CCACHE_NOPCH_EXTSUM, see
447       Boolean values above)
448           When this option is set, and ccache finds a precompiled header
449           file, ccache will look for a file with the extension “.sum” added
450           (e.g. “pre.h.gch.sum”), and if found, it will hash this file
451           instead of the precompiled header itself to work around the
452           performance penalty of hashing very large files.
453
454       prefix_command (CCACHE_PREFIX)
455           This option adds a list of prefixes (separated by space) to the
456           command line that ccache uses when invoking the compiler. See also
457           USING CCACHE WITH OTHER COMPILER WRAPPERS.
458
459       prefix_command_cpp (CCACHE_PREFIX_CPP)
460           This option adds a list of prefixes (separated by space) to the
461           command line that ccache uses when invoking the preprocessor.
462
463       read_only (CCACHE_READONLY or CCACHE_NOREADONLY, see Boolean values
464       above)
465           If true, ccache will attempt to use existing cached object files,
466           but it will not add new results to the cache. Statistics counters
467           will still be updated, though, unless the stats option is set to
468           false.
469
470           If you are using this because your ccache directory is read-only,
471           you need to set temporary_dir since ccache will fail to create
472           temporary files otherwise. You may also want to set stats = false
473           to make ccache not even try to update stats files.
474
475       read_only_direct (CCACHE_READONLY_DIRECT or CCACHE_NOREADONLY_DIRECT,
476       see Boolean values above)
477           Just like read_only except that ccache will only try to retrieve
478           results from the cache using the direct mode, not the preprocessor
479           mode. See documentation for read_only regarding using a read-only
480           ccache directory.
481
482       recache (CCACHE_RECACHE or CCACHE_NORECACHE, see Boolean values above)
483           If true, ccache will not use any previously stored result. New
484           results will still be cached, possibly overwriting any pre-existing
485           results.
486
487       run_second_cpp (CCACHE_CPP2 or CCACHE_NOCPP2, see Boolean values above)
488           If true, ccache will first run the preprocessor to preprocess the
489           source code (see THE PREPROCESSOR MODE) and then on a cache miss
490           run the compiler on the source code to get hold of the object file.
491           This is the default.
492
493           If false, ccache will first run preprocessor to preprocess the
494           source code and then on a cache miss run the compiler on the
495           preprocessed source code instead of the original source code. This
496           makes cache misses slightly faster since the source code only has
497           to be preprocessed once. The downside is that some compilers won’t
498           produce the same result (for instance diagnostics warnings) when
499           compiling preprocessed source code.
500
501           A solution to the above mentioned downside is to set run_second_cpp
502           to false and pass -fdirectives-only (for GCC) or -frewrite-includes
503           (for Clang) to the compiler. This will cause the compiler to leave
504           the macros and other preprocessor information, and only process the
505           #include directives. When run in this way, the preprocessor
506           arguments will be passed to the compiler since it still has to do
507           some preprocessing (like macros).
508
509       sloppiness (CCACHE_SLOPPINESS)
510           By default, ccache tries to give as few false cache hits as
511           possible. However, in certain situations it’s possible that you
512           know things that ccache can’t take for granted. This setting makes
513           it possible to tell ccache to relax some checks in order to
514           increase the hit rate. The value should be a comma-separated string
515           with options. Available options are:
516
517           clang_index_store
518               Ignore the Clang compiler option -index-store-path and its
519               argument when computing the manifest hash. This is useful if
520               you use Xcode, which uses an index store path derived from the
521               local project path. Note that the index store won’t be updated
522               correctly on cache hits if you enable this option.
523
524           file_stat_matches
525               ccache normally examines a file’s contents to determine whether
526               it matches the cached version. With this option set, ccache
527               will consider a file as matching its cached version if the
528               mtimes and ctimes match.
529
530           file_stat_matches_ctime
531               Ignore ctimes when file_stat_matches is enabled. This can be
532               useful when backdating files' mtimes in a controlled way.
533
534           include_file_ctime
535               By default, ccache also will not cache a file if it includes a
536               header whose ctime is too new. This option disables that check.
537
538           include_file_mtime
539               By default, ccache will not cache a file if it includes a
540               header whose mtime is too new. This option disables that check.
541
542           locale
543               ccache includes the environment variables LANG, LC_ALL,
544               LC_CTYPE and LC_MESSAGES in the hash by default since they may
545               affect localization of compiler warning messages. Set this
546               option to tell ccache not to do that.
547
548           pch_defines
549               Be sloppy about #defines when precompiling a header file. See
550               PRECOMPILED HEADERS for more information.
551
552           system_headers
553               By default, ccache will also include all system headers in the
554               manifest. With this option set, ccache will only include system
555               headers in the hash but not add the system header files to the
556               list of include files.
557
558           time_macros
559               Ignore __DATE__ and __TIME__ being present in the source code.
560
561           See the discussion under TROUBLESHOOTING for more information.
562
563       stats (CCACHE_STATS or CCACHE_NOSTATS, see Boolean values above)
564           If true, ccache will update the statistics counters on each
565           compilation. The default is true.
566
567       temporary_dir (CCACHE_TEMPDIR)
568           This setting specifies where ccache will put temporary files. The
569           default is <cache_dir>/tmp.
570
571               Note
572               In previous versions of ccache, CCACHE_TEMPDIR had to be on the
573               same filesystem as the CCACHE_DIR path, but this requirement
574               has been relaxed.)
575
576       umask (CCACHE_UMASK)
577           This setting specifies the umask for ccache and all child processes
578           (such as the compiler). This is mostly useful when you wish to
579           share your cache with other users. Note that this also affects the
580           file permissions set on the object files created from your
581           compilations.
582

CACHE SIZE MANAGEMENT

584       By default, ccache has a 5 GB limit on the total size of files in the
585       cache and no limit on the number of files. You can set different limits
586       using the -M/--max-size and -F/--max-files options. Use ccache
587       -s/--show-stats to see the cache size and the currently configured
588       limits (in addition to other various statistics).
589
590       Cleanup can be triggered in two different ways: automatic and manual.
591
592   Automatic cleanup
593       ccache maintains counters for various statistics about the cache,
594       including the size and number of all cached files. In order to improve
595       performance and reduce issues with concurrent ccache invocations, there
596       is one statistics file for each of the sixteen subdirectories in the
597       cache.
598
599       After a new compilation result has been written to the cache, ccache
600       will update the size and file number statistics for the subdirectory
601       (one of sixteen) to which the result was written. Then, if the size
602       counter for said subdirectory is greater than max_size / 16 or the file
603       number counter is greater than max_files / 16, automatic cleanup is
604       triggered.
605
606       When automatic cleanup is triggered for a subdirectory in the cache,
607       ccache will:
608
609        1. Count all files in the subdirectory and compute their aggregated
610           size.
611
612        2. Remove files in LRU (least recently used) order until the size is
613           at most limit_multiple * max_size / 16 and the number of files is
614           at most limit_multiple * max_files / 16, where limit_multiple,
615           max_size and max_files are configuration settings.
616
617        3. Set the size and file number counters to match the files that were
618           kept.
619
620       The reason for removing more files than just those needed to not exceed
621       the max limits is that a cleanup is a fairly slow operation, so it
622       would not be a good idea to trigger it often, like after each cache
623       miss.
624
625   Manual cleanup
626       You can run ccache -c/--cleanup to force cleanup of the whole cache,
627       i.e. all of the sixteen subdirectories. This will recalculate the
628       statistics counters and make sure that the max_size and max_files
629       settings are not exceeded. Note that limit_multiple is not taken into
630       account for manual cleanup.
631

CACHE COMPRESSION

633       ccache can optionally compress all files it puts into the cache using
634       the compression library zlib. While this may involve a tiny performance
635       slowdown, it increases the number of files that fit in the cache. You
636       can turn on compression with the compression configuration setting and
637       you can also tweak the compression level with compression_level.
638

CACHE STATISTICS

640       ccache -s/--show-stats can show the following statistics:
641
642       ┌───────────────────────────┬────────────────────────────┐
643Name                       Description                
644       ├───────────────────────────┼────────────────────────────┤
645       │                           │                            │
646       │autoconf compile/link      │ Uncachable compilation or  │
647       │                           │ linking by an autoconf     │
648       │                           │ test.                      │
649       ├───────────────────────────┼────────────────────────────┤
650       │                           │                            │
651       │bad compiler arguments     │ Malformed compiler         │
652       │                           │ argument, e.g. missing a   │
653       │                           │ value for an option that   │
654       │                           │ requires an argument or    │
655       │                           │ failure to read a file     │
656       │                           │ specified by an option     │
657       │                           │ argument.                  │
658       ├───────────────────────────┼────────────────────────────┤
659       │                           │                            │
660       │cache file missing         │ A file was unexpectedly    │
661       │                           │ missing from the cache.    │
662       │                           │ This only happens in rare  │
663       │                           │ situations, e.g. if one    │
664       │                           │ ccache instance is about   │
665       │                           │ to get a file from the     │
666       │                           │ cache while another        │
667       │                           │ instance removed the file  │
668       │                           │ as part of cache cleanup.  │
669       ├───────────────────────────┼────────────────────────────┤
670       │                           │                            │
671       │cache hit (direct)         │ A result was successfully  │
672       │                           │ found using the direct     │
673       │                           │ mode.                      │
674       ├───────────────────────────┼────────────────────────────┤
675       │                           │                            │
676       │cache hit (preprocessed)   │ A result was successfully  │
677       │                           │ found using the            │
678       │                           │ preprocessor mode.         │
679       ├───────────────────────────┼────────────────────────────┤
680       │                           │                            │
681       │cache miss                 │ No result was found.       │
682       ├───────────────────────────┼────────────────────────────┤
683       │                           │                            │
684       │cache size                 │ Current size of the cache. │
685       ├───────────────────────────┼────────────────────────────┤
686       │                           │                            │
687       │called for link            │ The compiler was called    │
688       │                           │ for linking, not           │
689       │                           │ compiling.                 │
690       ├───────────────────────────┼────────────────────────────┤
691       │                           │                            │
692       │called for preprocessing   │ The compiler was called    │
693       │                           │ for preprocessing, not     │
694       │                           │ compiling.                 │
695       ├───────────────────────────┼────────────────────────────┤
696       │                           │                            │
697       │can’t use precompiled      │ Preconditions for using    │
698       │header                     │ precompiled headers were   │
699       │                           │ not fulfilled.             │
700       ├───────────────────────────┼────────────────────────────┤
701       │                           │                            │
702       │ccache internal error      │ Unexpected failure, e.g.   │
703       │                           │ due to problems            │
704       │                           │ reading/writing the cache. │
705       ├───────────────────────────┼────────────────────────────┤
706       │                           │                            │
707       │cleanups performed         │ Number of cleanups         │
708       │                           │ performed, either          │
709       │                           │ implicitly due to the      │
710       │                           │ cache size limit being     │
711       │                           │ reached or due to explicit │
712       │                           │ ccache -c/--cleanup calls. │
713       ├───────────────────────────┼────────────────────────────┤
714       │                           │                            │
715       │compile failed             │ The compilation failed. No │
716       │                           │ result stored in the       │
717       │                           │ cache.                     │
718       ├───────────────────────────┼────────────────────────────┤
719       │                           │                            │
720       │compiler check failed      │ A compiler check program   │
721       │                           │ specified by               │
722       │                           │ compiler_check             
723       │                           │ (CCACHE_COMPILERCHECK)     │
724       │                           │ failed.                    │
725       ├───────────────────────────┼────────────────────────────┤
726       │                           │                            │
727       │compiler produced empty    │ The compiler’s output file │
728       │output                     │ (typically an object file) │
729       │                           │ was empty after            │
730       │                           │ compilation.               │
731       ├───────────────────────────┼────────────────────────────┤
732       │                           │                            │
733       │compiler produced no       │ The compiler’s output file │
734       │output                     │ (typically an object file) │
735       │                           │ was missing after          │
736       │                           │ compilation.               │
737       ├───────────────────────────┼────────────────────────────┤
738       │                           │                            │
739       │compiler produced stdout   │ The compiler wrote data to │
740       │                           │ standard output. This is   │
741       │                           │ something that compilers   │
742       │                           │ normally never do, so      │
743       │                           │ ccache is not designed to  │
744       │                           │ store such output in the   │
745       │                           │ cache.                     │
746       ├───────────────────────────┼────────────────────────────┤
747       │                           │                            │
748       │couldn’t find the compiler │ The compiler to execute    │
749       │                           │ could not be found.        │
750       ├───────────────────────────┼────────────────────────────┤
751       │                           │                            │
752       │error hashing extra file   │ Failure reading a file     │
753       │                           │ specified by               │
754       │                           │ extra_files_to_hash        
755       │                           │ (CCACHE_EXTRAFILES).       │
756       ├───────────────────────────┼────────────────────────────┤
757       │                           │                            │
758       │files in cache             │ Current number of files in │
759       │                           │ the cache.                 │
760       ├───────────────────────────┼────────────────────────────┤
761       │                           │                            │
762       │multiple source files      │ The compiler was called to │
763       │                           │ compile multiple source    │
764       │                           │ files in one go. This is   │
765       │                           │ not supported by ccache.   │
766       ├───────────────────────────┼────────────────────────────┤
767       │                           │                            │
768       │no input file              │ No input file was          │
769       │                           │ specified to the compiler. │
770       ├───────────────────────────┼────────────────────────────┤
771       │                           │                            │
772       │output to a non-regular    │ The output path specified  │
773       │file                       │ with -o is not a file      │
774       │                           │ (e.g. a directory or a     │
775       │                           │ device node).              │
776       ├───────────────────────────┼────────────────────────────┤
777       │                           │                            │
778       │output to stdout           │ The compiler was           │
779       │                           │ instructed to write its    │
780       │                           │ output to standard output  │
781       │                           │ using -o -. This is not    │
782       │                           │ supported by ccache.       │
783       ├───────────────────────────┼────────────────────────────┤
784       │                           │                            │
785       │preprocessor error         │ Preprocessing the source   │
786       │                           │ code using the compiler’s  │
787       │                           │ -E option failed.          │
788       ├───────────────────────────┼────────────────────────────┤
789       │                           │                            │
790       │stats updated              │ When statistics were       │
791       │                           │ updated the last time.     │
792       ├───────────────────────────┼────────────────────────────┤
793       │                           │                            │
794       │stats zeroed               │ When ccache -z was called  │
795       │                           │ the last time.             │
796       ├───────────────────────────┼────────────────────────────┤
797       │                           │                            │
798       │unsupported code directive │ Code like the assembler    │
799       │                           │ .incbin directive was      │
800       │                           │ found. This is not         │
801       │                           │ supported by ccache.       │
802       ├───────────────────────────┼────────────────────────────┤
803       │                           │                            │
804       │unsupported compiler       │ A compiler option not      │
805       │option                     │ supported by ccache was    │
806       │                           │ found.                     │
807       ├───────────────────────────┼────────────────────────────┤
808       │                           │                            │
809       │unsupported source         │ A source language e.g.     │
810       │language                   │ specified with -x was      │
811       │                           │ unsupported by ccache.     │
812       └───────────────────────────┴────────────────────────────┘
813

HOW CCACHE WORKS

815       The basic idea is to detect when you are compiling exactly the same
816       code a second time and reuse the previously produced output. The
817       detection is done by hashing different kinds of information that should
818       be unique for the compilation and then using the hash sum to identify
819       the cached output. ccache uses MD4, a very fast cryptographic hash
820       algorithm, for the hashing. (MD4 is nowadays too weak to be useful in
821       cryptographic contexts, but it should be safe enough to be used to
822       identify recompilations.) On a cache hit, ccache is able to supply all
823       of the correct compiler outputs (including all warnings, dependency
824       file, etc) from the cache.
825
826       ccache has two ways of gathering information used to look up results in
827       the cache:
828
829       ·   the direct mode, where ccache hashes the source code and include
830           files directly
831
832       ·   the preprocessor mode, where ccache runs the preprocessor on the
833           source code and hashes the result
834
835       The direct mode is generally faster since running the preprocessor has
836       some overhead.
837
838       If no previous result is detected (i.e., there is a cache miss) using
839       the direct mode, ccache will fall back to the preprocessor mode unless
840       the depend mode is enabled. In the depend mode, ccache never runs the
841       preprocessor, not even on cache misses. Read more in THE DEPEND MODE
842       below.
843
844   Common hashed information
845       The following information is always included in the hash:
846
847       ·   the extension used by the compiler for a file with preprocessor
848           output (normally .i for C code and .ii for C++ code)
849
850       ·   the compiler’s size and modification time (or other
851           compiler-specific information specified by the compiler_check
852           setting)
853
854       ·   the name of the compiler
855
856       ·   the current directory (if the hash_dir setting is enabled)
857
858       ·   contents of files specified by the extra_files_to_hash setting (if
859           any)
860
861   The direct mode
862       In the direct mode, the hash is formed of the common information and:
863
864       ·   the input source file
865
866       ·   the command line options
867
868       Based on the hash, a data structure called “manifest” is looked up in
869       the cache. The manifest contains:
870
871       ·   references to cached compilation results (object file, dependency
872           file, etc) that were produced by previous compilations that matched
873           the hash
874
875       ·   paths to the include files that were read at the time the
876           compilation results were stored in the cache
877
878       ·   hash sums of the include files at the time the compilation results
879           were stored in the cache
880
881       The current contents of the include files are then hashed and compared
882       to the information in the manifest. If there is a match, ccache knows
883       the result of the compilation. If there is no match, ccache falls back
884       to running the preprocessor. The output from the preprocessor is parsed
885       to find the include files that were read. The paths and hash sums of
886       those include files are then stored in the manifest along with
887       information about the produced compilation result.
888
889       There is a catch with the direct mode: header files that were used by
890       the compiler are recorded, but header files that were not used, but
891       would have been used if they existed, are not. So, when ccache checks
892       if a result can be taken from the cache, it currently can’t check if
893       the existence of a new header file should invalidate the result. In
894       practice, the direct mode is safe to use in the absolute majority of
895       cases.
896
897       The direct mode will be disabled if any of the following holds:
898
899       ·   the configuration setting direct_mode is false
900
901       ·   a modification time of one of the include files is too new (needed
902           to avoid a race condition)
903
904       ·   a compiler option not supported by the direct mode is used:
905
906           ·   a -Wp,X compiler option other than -Wp,-MD,path, -Wp,-MMD,path
907               and -Wp,-D_define_
908
909           ·   -Xpreprocessor
910
911       ·   the string __TIME__ is present in the source code
912
913   The preprocessor mode
914       In the preprocessor mode, the hash is formed of the common information
915       and:
916
917       ·   the preprocessor output from running the compiler with -E
918
919       ·   the command line options except options that affect include files
920           (-I, -include, -D, etc; the theory is that these options will
921           change the preprocessor output if they have any effect at all)
922
923       ·   any standard error output generated by the preprocessor
924
925       Based on the hash, the cached compilation result can be looked up
926       directly in the cache.
927
928   The depend mode
929       If the depend mode is enabled, ccache will not use the preprocessor at
930       all. The hash used to identify results in the cache will be based on
931       the direct mode hash described above plus information about include
932       files read from the dependency file generated by the compiler with -MD
933       or -MMD.
934
935       Advantages:
936
937       ·   The ccache overhead of a cache miss will be much smaller.
938
939       ·   Not running the preprocessor at all can be good if compilation is
940           performed remotely, for instance when using distcc or similar;
941           ccache then won’t make potentially costly preprocessor calls on the
942           local machine.
943
944       Disadvantages:
945
946       ·   The cache hit rate will likely be lower since any change to
947           compiler options or source code will make the hash different.
948           Compare this with the default setup where ccache will fall back to
949           the preprocessor mode, which is tolerant to some types of changes
950           of compiler options and source code changes.
951
952       ·   If -MD is used, the manifest entries will include system header
953           files as well, thus slowing down cache hits slightly, just as using
954           -MD slows down make.
955
956       ·   If -MMD is used, the manifest entries will not include system
957           header files, which means ccache will ignore changes in them.
958
959       The depend mode will be disabled if any of the following holds:
960
961       ·   the configuration setting depend_mode is false
962
963       ·   the configuration setting run_second_cpp is false
964
965       ·   the compiler is not generating dependencies using -MD or -MMD
966

CACHE DEBUGGING

968       To find out what information ccache actually is hashing, you can enable
969       the debug mode via the configuration setting debug or by setting
970       CCACHE_DEBUG in the environment. This can be useful if you are
971       investigating why you don’t get cache hits. Note that performance will
972       be reduced slightly.
973
974       When the debug mode is enabled, ccache will create up to five
975       additional files next to the object file:
976
977       ┌───────────────────────────────┬───────────────────────────┐
978Filename                       Description               
979       ├───────────────────────────────┼───────────────────────────┤
980       │                               │                           │
981<objectfile>.ccache-input-c    │ Binary input hashed by    │
982       │                               │ both the direct mode and  │
983       │                               │ the preprocessor mode.    │
984       ├───────────────────────────────┼───────────────────────────┤
985       │                               │                           │
986<objectfile>.ccache-input-d    │ Binary input only hashed  │
987       │                               │ by the direct mode.       │
988       ├───────────────────────────────┼───────────────────────────┤
989       │                               │                           │
990<objectfile>.ccache-input-p    │ Binary input only hashed  │
991       │                               │ by the preprocessor mode. │
992       ├───────────────────────────────┼───────────────────────────┤
993       │                               │                           │
994<objectfile>.ccache-input-text │ Human-readable combined   │
995       │                               │ diffable text version of  │
996       │                               │ the three files above.    │
997       ├───────────────────────────────┼───────────────────────────┤
998       │                               │                           │
999<objectfile>.ccache-log        │ Log for this object file. │
1000       └───────────────────────────────┴───────────────────────────┘
1001
1002       In the direct mode, ccache uses the MD4 hash of the ccache-input-c +
1003       ccache-input-d data (where + means concatenation), while the
1004       ccache-input-c + ccache-input-p data is used in the preprocessor mode.
1005
1006       The ccache-input-text file is a combined text version of the three
1007       binary input files. It has three sections (“COMMON”, “DIRECT MODE” and
1008       “PREPROCESSOR MODE”), which is turn contain annotations that say what
1009       kind of data comes next.
1010
1011       To debug why you don’t get an expected cache hit for an object file,
1012       you can do something like this:
1013
1014        1. Build with debug mode enabled.
1015
1016        2. Save the <objectfile>.ccache-* files.
1017
1018        3. Build again with debug mode enabled.
1019
1020        4. Compare <objectfile>.ccache-input-text for the two builds. This
1021           together with the <objectfile>.ccache-log files should give you
1022           some clues about what is happening.
1023

COMPILING IN DIFFERENT DIRECTORIES

1025       Some information included in the hash that identifies a unique
1026       compilation can contain absolute paths:
1027
1028       ·   The preprocessed source code may contain absolute paths to include
1029           files if the compiler option -g is used or if absolute paths are
1030           given to -I and similar compiler options.
1031
1032       ·   Paths specified by compiler options (such as -I, -MF, etc) on the
1033           command line may be absolute.
1034
1035       ·   The source code file path may be absolute, and that path may
1036           substituted for __FILE__ macros in the source code or included in
1037           warnings emitted to standard error by the preprocessor.
1038
1039       This means that if you compile the same code in different locations,
1040       you can’t share compilation results between the different build
1041       directories since you get cache misses because of the absolute build
1042       directory paths that are part of the hash.
1043
1044       Here’s what can be done to enable cache hits between different build
1045       directories:
1046
1047       ·   If you build with -g (or similar) to add debug information to the
1048           object file, you must either:
1049
1050           ·   use the -fdebug-prefix-map=old=new option for relocating debug
1051               info to a common prefix (e.g.  -fdebug-prefix-map=$PWD=.); or
1052
1053           ·   set hash_dir = false.
1054
1055       ·   If you use absolute paths anywhere on the command line (e.g. the
1056           source code file path or an argument to compiler options like -I
1057           and -MF), you must to set base_dir to an absolute path to a “base
1058           directory”. ccache will then rewrite absolute paths under that
1059           directory to relative before computing the hash.
1060

PRECOMPILED HEADERS

1062       ccache has support for GCC’s precompiled headers. However, you have to
1063       do some things to make it work properly:
1064
1065       ·   You must set sloppiness to pch_defines,time_macros. The reason is
1066           that ccache can’t tell whether __TIME__ or __DATE__ is used when
1067           using a precompiled header. Further, it can’t detect changes in
1068           #defines in the source code because of how preprocessing works in
1069           combination with precompiled headers.
1070
1071       ·   You must either:
1072
1073           ·   use the -include compiler option to include the precompiled
1074               header (i.e., don’t use #include in the source code to include
1075               the header; the filename itself must be sufficient to find the
1076               header, i.e.  -I paths are not searched); or
1077
1078           ·   (for the Clang compiler) use the -include-pch compiler option
1079               to include the PCH file generated from the precompiled header;
1080               or
1081
1082           ·   (for the GCC compiler) add the -fpch-preprocess compiler option
1083               when compiling.
1084
1085           If you don’t do this, either the non-precompiled version of the
1086           header file will be used (if available) or ccache will fall back to
1087           running the real compiler and increase the statistics counter
1088           “preprocessor error” (if the non-precompiled header file is not
1089           available).
1090

SHARING A CACHE

1092       A group of developers can increase the cache hit rate by sharing a
1093       cache directory. To share a cache without unpleasant side effects, the
1094       following conditions should to be met:
1095
1096       ·   Use the same cache directory.
1097
1098       ·   Make sure that the configuration setting hard_link is false (which
1099           is the default).
1100
1101       ·   Make sure that all users are in the same group.
1102
1103       ·   Set the configuration setting umask to 002. This ensures that
1104           cached files are accessible to everyone in the group.
1105
1106       ·   Make sure that all users have write permission in the entire cache
1107           directory (and that you trust all users of the shared cache).
1108
1109       ·   Make sure that the setgid bit is set on all directories in the
1110           cache. This tells the filesystem to inherit group ownership for new
1111           directories. The following command might be useful for this:
1112
1113               find $CCACHE_DIR -type d | xargs chmod g+s
1114
1115       The reason to avoid the hard link mode is that the hard links cause
1116       unwanted side effects, as all links to a cached file share the file’s
1117       modification timestamp. This results in false dependencies to be
1118       triggered by timestamp-based build systems whenever another user links
1119       to an existing file. Typically, users will see that their libraries and
1120       binaries are relinked without reason.
1121
1122       You may also want to make sure that a base directory is set
1123       appropriately, as discussed in a previous section.
1124

SHARING A CACHE ON NFS

1126       It is possible to put the cache directory on an NFS filesystem (or
1127       similar filesystems), but keep in mind that:
1128
1129       ·   Having the cache on NFS may slow down compilation. Make sure to do
1130           some benchmarking to see if it’s worth it.
1131
1132       ·   ccache hasn’t been tested very thoroughly on NFS.
1133
1134       A tip is to set temporary_dir to a directory on the local host to avoid
1135       NFS traffic for temporary files.
1136

USING CCACHE WITH OTHER COMPILER WRAPPERS

1138       The recommended way of combining ccache with another compiler wrapper
1139       (such as “distcc”) is by letting ccache execute the compiler wrapper.
1140       This is accomplished by defining the configuration setting
1141       prefix_command, for example by setting the environment variable
1142       CCACHE_PREFIX to the name of the wrapper (e.g. distcc). ccache will
1143       then prefix the command line with the specified command when running
1144       the compiler. To specify several prefix commands, set prefix_command to
1145       a colon-separated list of commands.
1146
1147       Unless you set compiler_check to a suitable command (see the
1148       description of that configuration option), it is not recommended to use
1149       the form ccache anotherwrapper compiler args as the compilation
1150       command. It’s also not recommended to use the masquerading technique
1151       for the other compiler wrapper. The reason is that by default, ccache
1152       will in both cases hash the mtime and size of the other wrapper instead
1153       of the real compiler, which means that:
1154
1155       ·   Compiler upgrades will not be detected properly.
1156
1157       ·   The cached results will not be shared between compilations with and
1158           without the other wrapper.
1159
1160       Another minor thing is that if prefix_command is used, ccache will not
1161       invoke the other wrapper when running the preprocessor, which increases
1162       performance. You can use the prefix_command_cpp configuration setting
1163       if you also want to invoke the other wrapper when doing preprocessing
1164       (normally by adding -E).
1165

CAVEATS

1167       ·   The direct mode fails to pick up new header files in some rare
1168           scenarios. See THE DIRECT MODE above.
1169
1170       ·   When run via ccache, warning messages produced by GCC 4.9 and newer
1171           will only be colored when the environment variable GCC_COLORS is
1172           set. An alternative to setting GCC_COLORS is to pass
1173           -fdiagnostics-color explicitly when compiling (but then color codes
1174           will also be present when redirecting stderr to a file).
1175
1176       ·   If ccache guesses that the compiler may emit colored warnings, then
1177           a compilation with stderr referring to a TTY will be considered
1178           different from a compilation with a redirected stderr, thus not
1179           sharing cache entries. This happens for clang by default and for
1180           GCC when GCC_COLORS is set as mentioned above. If you want to share
1181           cache hits, you can pass -f[no-]diagnostics-color (GCC) or
1182           -f[no-]color-diagnostics (clang) explicitly when compiling (but
1183           then color codes will be either on or off for both the TTY and the
1184           redirected case).
1185

TROUBLESHOOTING

1187   General
1188       A general tip for getting information about what ccache is doing is to
1189       enable debug logging by setting the configuration option debug (or the
1190       environment variable CCACHE_DEBUG); see debugging for more information.
1191       Another way of keeping track of what is happening is to check the
1192       output of ccache -s.
1193
1194   Performance
1195       ccache has been written to perform well out of the box, but sometimes
1196       you may have to do some adjustments of how you use the compiler and
1197       ccache in order to improve performance.
1198
1199       Since ccache works best when I/O is fast, put the cache directory on a
1200       fast storage device if possible. Having lots of free memory so that
1201       files in the cache directory stay in the disk cache is also preferable.
1202
1203       A good way of monitoring how well ccache works is to run ccache -s
1204       before and after your build and then compare the statistics counters.
1205       Here are some common problems and what may be done to increase the hit
1206       rate:
1207
1208       ·   If “cache hit (preprocessed)” has been incremented instead of
1209           “cache hit (direct)”, ccache has fallen back to preprocessor mode,
1210           which is generally slower. Some possible reasons are:
1211
1212           ·   The source code has been modified in such a way that the
1213               preprocessor output is not affected.
1214
1215           ·   Compiler arguments that are hashed in the direct mode but not
1216               in the preprocessor mode have changed (-I, -include, -D, etc)
1217               and they didn’t affect the preprocessor output.
1218
1219           ·   The compiler option -Xpreprocessor or -Wp,X (except
1220               -Wp,-MD,path, -Wp,-MMD,path, and -Wp,-D_define_) is used.
1221
1222           ·   This was the first compilation with a new value of the base
1223               directory setting.
1224
1225           ·   A modification time of one of the include files is too new
1226               (created the same second as the compilation is being done).
1227               This check is made to avoid a race condition. To fix this,
1228               create the include file earlier in the build process, if
1229               possible, or set sloppiness to include_file_mtime if you are
1230               willing to take the risk. (The race condition consists of these
1231               events: the preprocessor is run; an include file is modified by
1232               someone; the new include file is hashed by ccache; the real
1233               compiler is run on the preprocessor’s output, which contains
1234               data from the old header file; the wrong object file is stored
1235               in the cache.)
1236
1237           ·   The __TIME__ preprocessor macro is (potentially) being used.
1238               ccache turns off direct mode if __TIME__ is present in the
1239               source code. This is done as a safety measure since the string
1240               indicates that a __TIME__ macro may affect the output. (To be
1241               sure, ccache would have to run the preprocessor, but the sole
1242               point of the direct mode is to avoid that.) If you know that
1243               __TIME__ isn’t used in practise, or don’t care if ccache
1244               produces objects where __TIME__ is expanded to something in the
1245               past, you can set sloppiness to time_macros.
1246
1247           ·   The __DATE__ preprocessor macro is (potentially) being used and
1248               the date has changed. This is similar to how __TIME__ is
1249               handled. If __DATE__ is present in the source code, ccache
1250               hashes the current date in order to be able to produce the
1251               correct object file if the __DATE__ macro affects the output.
1252               If you know that __DATE__ isn’t used in practise, or don’t care
1253               if ccache produces objects where __DATE__ is expanded to
1254               something in the past, you can set sloppiness to time_macros.
1255
1256           ·   The input file path has changed. ccache includes the input file
1257               path in the direct mode hash to be able to take relative
1258               include files into account and to produce a correct object file
1259               if the source code includes a __FILE__ macro.
1260
1261       ·   If “cache miss” has been incremented even though the same code has
1262           been compiled and cached before, ccache has either detected that
1263           something has changed anyway or a cleanup has been performed
1264           (either explicitly or implicitly when a cache limit has been
1265           reached). Some perhaps unobvious things that may result in a cache
1266           miss are usage of __TIME__ or __DATE__ macros, or use of
1267           automatically generated code that contains a timestamp, build
1268           counter or other volatile information.
1269
1270       ·   If “multiple source files” has been incremented, it’s an indication
1271           that the compiler has been invoked on several source code files at
1272           once. ccache doesn’t support that. Compile the source code files
1273           separately if possible.
1274
1275       ·   If “unsupported compiler option” has been incremented, enable debug
1276           logging and check which option was rejected.
1277
1278       ·   If “preprocessor error” has been incremented, one possible reason
1279           is that precompiled headers are being used. See PRECOMPILED HEADERS
1280           for how to remedy this.
1281
1282       ·   If “can’t use precompiled header” has been incremented, see
1283           PRECOMPILED HEADERS.
1284
1285   Corrupt object files
1286       It should be noted that ccache is susceptible to general storage
1287       problems. If a bad object file sneaks into the cache for some reason,
1288       it will of course stay bad. Some possible reasons for erroneous object
1289       files are bad hardware (disk drive, disk controller, memory, etc),
1290       buggy drivers or file systems, a bad prefix_command or compiler
1291       wrapper. If this happens, the easiest way of fixing it is this:
1292
1293        1. Build so that the bad object file ends up in the build tree.
1294
1295        2. Remove the bad object file from the build tree.
1296
1297        3. Rebuild with CCACHE_RECACHE set.
1298
1299       An alternative is to clear the whole cache with ccache -C if you don’t
1300       mind losing other cached results.
1301
1302       There are no reported issues about ccache producing broken object files
1303       reproducibly. That doesn’t mean it can’t happen, so if you find a
1304       repeatable case, please report it.
1305

MORE INFORMATION

1307       Credits, mailing list information, bug reporting instructions, source
1308       code, etc, can be found on ccache’s web site: https://ccache.dev.
1309

AUTHOR

1311       ccache was originally written by Andrew Tridgell and is currently
1312       developed and maintained by Joel Rosdahl. See AUTHORS.txt or
1313       AUTHORS.html and https://ccache.dev/credits.html for a list of
1314       contributors.
1315
1316
1317
1318ccache 3.7.7                      01/05/2020                         CCACHE(1)
Impressum