1CCACHE(1)                                                            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]            (ccache masquerading as the compiler)
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.
17
18       Ccache has been carefully written to always produce exactly the same
19       compiler output that you would get without the cache. The only way you
20       should be able to tell that you are using ccache is the speed.
21       Currently known exceptions to this goal are listed under CAVEATS. If
22       you discover an undocumented case where ccache changes the output of
23       your compiler, please let us know.
24

RUN MODES

26       There are two different ways to use ccache to cache a compilation:
27
28        1. Prefix your compilation command with ccache. This method is most
29           convenient if you just want to try out ccache or wish to use it for
30           some specific projects. Example:
31
32               ccache gcc -c example.c
33
34        2. Let ccache masquerade as the compiler. This method is most useful
35           when you wish to use ccache for all your compilations. To do this,
36           create a symbolic link to ccache named as the compiler. For
37           example, here is set up ccache to masquerade as gcc and g++:
38
39               cp ccache /usr/local/bin/
40               ln -s ccache /usr/local/bin/gcc
41               ln -s ccache /usr/local/bin/g++
42
43           On platforms that don’t support symbolic links you can simply copy
44           ccache to the compiler name instead for a similar effect:
45
46               cp ccache /usr/local/bin/gcc
47               cp ccache /usr/local/bin/g++
48
49           And so forth. This will work as long as the directory with symbolic
50           links or ccache copies comes before the directory with the compiler
51           (typically /usr/bin) in PATH.
52
53               Warning
54               The technique of letting ccache masquerade as the compiler
55               works well, but currently doesn’t interact well with other
56               tools that do the same thing. See USING CCACHE WITH OTHER
57               COMPILER WRAPPERS.
58

COMMAND LINE OPTIONS

60       These command line options only apply when you invoke ccache as
61       “ccache”. When ccache masquerades as a compiler (as described in the
62       previous section), the normal compiler options apply and you should
63       refer to the compiler’s documentation.
64
65   Common options
66       -c, --cleanup
67           Clean up the cache by removing old cached files until the specified
68           file number and cache size limits are not exceeded. This also
69           recalculates the cache file count and size totals. Normally, there
70           is no need to initiate cleanup manually as ccache keeps the cache
71           below the specified limits at runtime and keeps statistics up to
72           date on each compilation. Forcing a cleanup is mostly useful if you
73           manually modify the cache contents or believe that the cache size
74           statistics may be inaccurate.
75
76       -C, --clear
77           Clear the entire cache, removing all cached files, but keeping the
78           configuration file.
79
80       --config-path PATH
81           Let the command line options operate on configuration file PATH
82           instead of the default. Using this option has the same effect as
83           setting (overriding) the environment variable CCACHE_CONFIGPATH
84           temporarily.
85
86       -d, --dir PATH
87           Let the command line options operate on cache directory PATH
88           instead of the default. For example, to show statistics for a cache
89           directory at /shared/ccache you can run ccache -d /shared/ccache
90           -s. Using this option has the same effect as setting the
91           environment variable CCACHE_DIR temporarily.
92
93       --evict-namespace NAMESPACE
94           Remove files created in the given namespace from the cache.
95
96       --evict-older-than AGE
97           Remove files older than AGE from the cache. AGE should be an
98           unsigned integer with a d (days) or s (seconds) suffix. If combined
99           with --evict-namespace, only remove old files within that
100           namespace.
101
102       -h, --help
103           Print a summary of command line options.
104
105       -F NUM, --max-files NUM
106           Set the maximum number of files allowed in the cache to NUM. Use 0
107           for no limit. The value is stored in a configuration file in the
108           cache directory and applies to all future compilations.
109
110       -M SIZE, --max-size SIZE
111           Set the maximum size of the files stored in the cache. SIZE should
112           be a number followed by an optional suffix: k, M, G, T (decimal),
113           Ki, Mi, Gi or Ti (binary). The default suffix is G. Use 0 for no
114           limit. The value is stored in a configuration file in the cache
115           directory and applies to all future compilations.
116
117       -X LEVEL, --recompress LEVEL
118           Recompress the cache to level LEVEL using the Zstandard algorithm.
119           The level can be an integer, with the same semantics as the
120           compression_level configuration option, or the special value
121           uncompressed for no compression. See CACHE COMPRESSION for more
122           information. This can potentionally take a long time since all
123           files in the cache need to be visited. Only files that are
124           currently compressed with a different level than LEVEL will be
125           recompressed.
126
127       -o KEY=VALUE, --set-config KEY=VALUE
128           Set configuration option KEY to VALUE. See CONFIGURATION for more
129           information.
130
131       -x, --show-compression
132           Print cache compression statistics. See CACHE COMPRESSION for more
133           information. This can potentionally take a long time since all
134           files in the cache need to be visited.
135
136       -p, --show-config
137           Print current configuration options and from where they originate
138           (environment variable, configuration file or compile-time default)
139           in human-readable format.
140
141       --show-log-stats
142           Print statistics counters from the stats log in human-readable
143           format. See stats_log. Use -v/--verbose once or twice for more
144           details.
145
146       -s, --show-stats
147           Print a summary of configuration and statistics counters in
148           human-readable format. Use -v/--verbose once or twice for more
149           details.
150
151       -v, --verbose
152           Increase verbosity. The option can be given multiple times.
153
154       -V, --version
155           Print version and copyright information.
156
157       -z, --zero-stats
158           Zero the cache statistics (but not the configuration options).
159
160   Options for remote file-based storage
161       --trim-dir PATH
162           Remove old files from directory PATH until it is at most the size
163           specified by --trim-max-size.
164
165               Warning
166               Don’t use this option to trim the local cache. To trim the
167               local cache directory to a certain size, use
168               CCACHE_MAXSIZE=SIZE ccache -c.
169
170       --trim-max-size SIZE
171           Specify the maximum size for --trim-dir. SIZE should be a number
172           followed by an optional suffix: k, M, G, T (decimal), Ki, Mi, Gi or
173           Ti (binary). The default suffix is G.
174
175       --trim-method METHOD
176           Specify the method to trim a directory with --trim-dir. Possible
177           values are:
178
179           atime
180               LRU (least recently used) using the file access timestamp. This
181               is the default.
182
183           mtime
184               LRU (least recently used) using the file modification
185               timestamp.
186
187   Options for scripting or debugging
188       --checksum-file PATH
189           Print the checksum (128 bit XXH3) of the file at PATH (- for
190           standard input).
191
192       --extract-result PATH
193           Extract data stored in the result file at PATH (- for standard
194           input). The data will be written to ccache-result.* files in to the
195           current working directory. This option is only useful when
196           debugging ccache and its behavior.
197
198       -k KEY, --get-config KEY
199           Print the value of configuration option KEY. See CONFIGURATION for
200           more information.
201
202       --hash-file PATH
203           Print the hash (160 bit BLAKE3) of the file at PATH (- for standard
204           input). This is only useful when debugging ccache and its behavior.
205
206       --inspect PATH
207           Print the content of a result or manifest file at PATH (- for
208           standard input) to standard output in human-readable format. File
209           content embedded in a result file will however not be printed; use
210           --extract-result to extract the file content. This option is only
211           useful when debugging ccache and its behavior.
212
213       --print-stats
214           Print statistics counter IDs and corresponding values in
215           machine-parsable (tab-separated) format.
216
217   Extra options
218       When run as a compiler, ccache usually just takes the same command line
219       options as the compiler you are using. The only exception to this is
220       the option --ccache-skip. That option can be used to tell ccache to
221       avoid interpreting the next option in any way and to pass it along to
222       the compiler as-is.
223
224           Note
225           --ccache-skip currently only tells ccache not to interpret the next
226           option as a special compiler option — the option will still be
227           included in the direct mode hash.
228
229       The reason this can be important is that ccache does need to parse the
230       command line and determine what is an input filename and what is a
231       compiler option, as it needs the input filename to determine the name
232       of the resulting object file (among other things). The heuristic ccache
233       uses when parsing the command line is that any argument that exists as
234       a file is treated as an input file name. By using --ccache-skip you can
235       force an option to not be treated as an input file name and instead be
236       passed along to the compiler as a command line option.
237
238       Another case where --ccache-skip can be useful is if ccache interprets
239       an option specially but shouldn’t, since the option has another meaning
240       for your compiler than what ccache thinks.
241

CONFIGURATION

243       Ccache’s default behavior can be overridden by options in configuration
244       files, which in turn can be overridden by environment variables with
245       names starting with CCACHE_. Ccache normally reads configuration from
246       two files: first a system-level configuration file and secondly a
247       cache-specific configuration file. The priorities of configuration
248       options are as follows (where 1 is highest):
249
250        1. Environment variables.
251
252        2. The cache-specific configuration file (see below).
253
254        3. The system (read-only) configuration file <sysconfdir>/ccache.conf
255           (typically /etc/ccache.conf or /usr/local/etc/ccache.conf).
256
257        4. Compile-time defaults.
258
259       As a special case, if the environment variable CCACHE_CONFIGPATH is set
260       it specifies the configuration file, and the system configuration file
261       won’t be read.
262
263   Location of the configuration file
264       The location of the cache-specific configuration file is determined
265       like this on non-Windows systems:
266
267        1. If CCACHE_CONFIGPATH is set, use that path.
268
269        2. Otherwise, if the environment variable CCACHE_DIR is set then use
270           $CCACHE_DIR/ccache.conf.
271
272        3. Otherwise, if cache_dir is set in the system configuration file
273           then use <cache_dir>/ccache.conf.
274
275        4. Otherwise, if there is a legacy $HOME/.ccache directory then use
276           $HOME/.ccache/ccache.conf.
277
278        5. Otherwise, if XDG_CONFIG_HOME is set then use
279           $XDG_CONFIG_HOME/ccache/ccache.conf.
280
281        6. Otherwise, use $HOME/Library/Preferences/ccache/ccache.conf (macOS)
282           or $HOME/.config/ccache/ccache.conf (other systems).
283
284       On Windows, this is the method used to find the configuration file:
285
286        1. If CCACHE_CONFIGPATH is set, use that path.
287
288        2. Otherwise, if the environment variable CCACHE_DIR is set then use
289           %CCACHE_DIR%/ccache.conf.
290
291        3. Otherwise, if cache_dir is set in the system configuration file
292           then use <cache_dir>\ccache.conf. The system-wide configuration on
293           Windows is %ALLUSERSPROFILE%\ccache\ccache.conf by default. The
294           ALLUSERSPROFILE environment variable is usually C:\ProgramData.
295
296        4. Otherwise, if there is a legacy %USERPROFILE%\.ccache directory
297           then use %USERPROFILE%\.ccache\ccache.conf.
298
299        5. Otherwise, use %LOCALAPPDATA%\ccache\ccache.conf if it exists.
300
301        6. Otherwise, use %APPDATA%\ccache\ccache.conf.
302
303       See also the cache_dir configuration option for how the cache directory
304       location is determined.
305
306   Configuration file syntax
307       Configuration files are in a simple “key = value” format, one option
308       per line. Lines starting with a hash sign are comments. Blank lines are
309       ignored, as is whitespace surrounding keys and values. Example:
310
311           # Set maximum cache size to 10 GB:
312           max_size = 10G
313
314   Boolean values
315       Some configuration options are boolean values (i.e. truth values). In a
316       configuration file, such values must be set to the string true or
317       false. For the corresponding environment variables, the semantics are a
318       bit different:
319
320       •   A set environment variable means “true” (even if set to the empty
321           string).
322
323       •   The following case-insensitive negative values are considered an
324           error (instead of surprising the user): 0, false, disable and no.
325
326       •   An unset environment variable means “false”.
327
328       Each boolean environment variable also has a negated form starting with
329       CCACHE_NO. For example, CCACHE_COMPRESS can be set to force compression
330       and CCACHE_NOCOMPRESS can be set to force no compression.
331
332   Configuration options
333       Below is a list of available configuration options. The corresponding
334       environment variable name is indicated in parentheses after each
335       configuration option key.
336
337       absolute_paths_in_stderr (CCACHE_ABSSTDERR)
338           This option specifies whether ccache should rewrite relative paths
339           in the compiler’s standard error output to absolute paths. This can
340           be useful if you use base_dir with a build system (e.g. CMake with
341           the "Unix Makefiles" generator) that executes the compiler in a
342           different working directory, which makes relative paths in compiler
343           errors or warnings incorrect. The default is false.
344
345       base_dir (CCACHE_BASEDIR)
346           This option should be an absolute path to a directory. If set,
347           ccache will rewrite absolute paths into paths relative to the
348           current working directory, but only absolute paths that begin with
349           base_dir. Cache results can then be shared for compilations in
350           different directories even if the project uses absolute paths in
351           the compiler command line. See also the discussion under COMPILING
352           IN DIFFERENT DIRECTORIES. If set to the empty string (which is the
353           default), no rewriting is done.
354
355           A typical path to use as base_dir is your home directory or another
356           directory that is a parent of your project directories. Don’t use /
357           as the base directory since that will make ccache also rewrite
358           paths to system header files, which typically is contraproductive.
359
360           For example, say that Alice’s current working directory is
361           /home/alice/project1/build and that she compiles like this:
362
363               ccache gcc -I/usr/include/example -I/home/alice/project2/include -c /home/alice/project1/src/example.c
364
365           Here is what ccache will actually execute for different base_dir
366           values:
367
368               # Current working directory: /home/alice/project1/build
369
370               # With base_dir = /:
371               gcc -I../../../../usr/include/example -I../../project2/include -c ../src/example.c
372
373               # With base_dir = /home or /home/alice:
374               gcc -I/usr/include/example -I../../project2/include -c ../src/example.c
375
376               # With base_dir = /home/alice/project1 or /home/alice/project1/src:
377               gcc -I/usr/include/example -I/home/alice/project2/include -c ../src/example.c
378
379           If Bob has put project1 and project2 in /home/bob/stuff and both
380           users have set base_dir to /home or /home/$USER, then Bob will get
381           a cache hit (if they share ccache directory) since the actual
382           command line will be identical to that of Alice:
383
384               # Current working directory: /home/bob/stuff/project1/build
385
386               # With base_dir = /home or /home/bob:
387               gcc -I/usr/include/example -I../../project2/include -c ../src/example.c
388
389           Without base_dir there will be a cache miss since the absolute
390           paths will differ. With base_dir set to / there will be a cache
391           miss since the relative path to /usr/include/example will be
392           different. With base_dir set to /home/bob/stuff/project1 there will
393           a cache miss since the path to project2 will be a different
394           absolute path.
395
396               Warning
397               Rewriting absolute paths to relative is kind of a brittle hack.
398               It works OK in many cases, but there might be cases where
399               things break. One known issue is that absolute paths are not
400               reproduced in dependency files, which can mess up dependency
401               detection in tools like Make and Ninja. If possible, use
402               relative paths in the first place instead instead of using
403               base_dir.
404
405       cache_dir (CCACHE_DIR)
406           This option specifies where ccache will keep its cached compiler
407           outputs.
408
409           On non-Windows systems, the default is $HOME/.ccache if such a
410           directory exists, otherwise $XDG_CACHE_HOME/ccache if
411           XDG_CACHE_HOME is set, otherwise $HOME/Library/Caches/ccache
412           (macOS) or $HOME/.config/ccache (other systems).
413
414           On Windows, the default is %USERPROFILE%\.ccache if such a
415           directory exists, otherwise %LOCALAPPDATA%\ccache.
416
417               Warning
418               Previous ccache versions defaulted to storing the cache in
419               %APPDATA%\ccache on Windows. This can result in large network
420               file transfers of the cache in domain environments and similar
421               problems. Please check this directory for cache directories and
422               either delete them or the whole directory, or move them to the
423               %LOCALAPPDATA%\ccache directory.
424
425           See also Location of the configuration file.
426
427       compiler (CCACHE_COMPILER or (deprecated) CCACHE_CC)
428           This option can be used to force the name of the compiler to use.
429           If set to the empty string (which is the default), ccache works it
430           out from the command line.
431
432       compiler_check (CCACHE_COMPILERCHECK)
433           By default, ccache includes the modification time (“mtime”) and
434           size of the compiler in the hash to ensure that results retrieved
435           from the cache are accurate. If compiler plugins are used, these
436           plugins will also be added to the hash. This option can be used to
437           select another strategy. Possible values are:
438
439           content
440               Hash the content of the compiler binary. This makes ccache very
441               slightly slower compared to mtime, but makes it cope better
442               with compiler upgrades during a build bootstrapping process.
443
444           mtime
445               Hash the compiler’s mtime and size, which is fast. This is the
446               default.
447
448           none
449               Don’t hash anything. This may be good for situations where you
450               can safely use the cached results even though the compiler’s
451               mtime or size has changed (e.g. if the compiler is built as
452               part of your build system and the compiler’s source has not
453               changed, or if the compiler only has changes that don’t affect
454               code generation). You should only use none if you know what you
455               are doing.
456
457           string:value
458               Hash value. This can for instance be a compiler revision number
459               or another string that the build system generates to identify
460               the compiler.
461
462           a command string
463               Hash the standard output and standard error output of the
464               specified command. The string will be split on whitespace to
465               find out the command and arguments to run. No other
466               interpretation of the command string will be done, except that
467               the special word %compiler% will be replaced with the path to
468               the compiler. Several commands can be specified with semicolon
469               as separator. Examples:
470
471                   %compiler% -v
472
473                   %compiler% -dumpmachine; %compiler% -dumpversion
474
475               You should make sure that the specified command is as fast as
476               possible since it will be run once for each ccache invocation.
477
478               Identifying the compiler using a command is useful if you want
479               to avoid cache misses when the compiler has been rebuilt but
480               not changed.
481
482               Another case is when the compiler (as seen by ccache) actually
483               isn’t the real compiler but another compiler wrapper — in that
484               case, the default mtime method will hash the mtime and size of
485               the other compiler wrapper, which means that ccache won’t be
486               able to detect a compiler upgrade. Using a suitable command to
487               identify the compiler is thus safer, but it’s also slower, so
488               you should consider continue using the mtime method in
489               combination with the prefix_command option if possible. See
490               USING CCACHE WITH OTHER COMPILER WRAPPERS.
491
492       compiler_type (CCACHE_COMPILERTYPE)
493           Ccache normally guesses the compiler type based on the compiler
494           name. The compiler_type option lets you force a compiler type. This
495           can be useful if the compiler has a non-standard name but is
496           actually one of the known compiler types. Possible values are:
497
498           auto
499               Guess one of the types below based on the compiler name
500               (following symlinks). This is the default.
501
502           clang
503               Clang-based compiler.
504
505           clang-cl
506               clang-cl.
507
508           gcc
509               GCC-based compiler.
510
511           icl
512               Intel compiler on Windows.
513
514           msvc
515               Microsoft Visual C++ (MSVC).
516
517           nvcc
518               NVCC (CUDA) compiler.
519
520           other
521               Any compiler other than the known types.
522
523       compression (CCACHE_COMPRESS or CCACHE_NOCOMPRESS, see Boolean values
524       above)
525           If true, ccache will compress data it puts in the cache. However,
526           this option has no effect on how files are retrieved from the
527           cache; compressed and uncompressed results will still be usable
528           regardless of this option. The default is true.
529
530           Compression is done using the Zstandard algorithm. The algorithm is
531           fast enough that there should be little reason to turn off
532           compression to gain performance. One exception is if the cache is
533           located on a compressed file system, in which case the compression
534           performed by ccache of course is redundant.
535
536           Compression will be disabled if file cloning (the file_clone
537           option) or hard linking (the hard_link option) is enabled.
538
539       compression_level (CCACHE_COMPRESSLEVEL)
540           This option determines the level at which ccache will compress
541           object files using the real-time compression algorithm Zstandard.
542           It only has effect if compression is enabled (which it is by
543           default). Zstandard is extremely fast for decompression and very
544           fast for compression for lower compression levels. The default is
545           0.
546
547           Semantics of compression_level:
548
549           > 0
550               A positive value corresponds to normal Zstandard compression
551               levels. Lower levels (e.g. 1) mean faster compression but worse
552               compression ratio. Higher levels (e.g. 19) mean slower
553               compression but better compression ratio. The maximum possible
554               value depends on the libzstd version, but at least up to 19 is
555               available for all versions. Decompression speed is essentially
556               the same for all levels. As a rule of thumb, use level 5 or
557               lower since higher levels may slow down compilations
558               noticeably. Higher levels are however useful when recompressing
559               the cache with command line option -X/--recompress.
560
561           < 0
562               A negative value corresponds to Zstandard’s “ultra-fast”
563               compression levels, which are even faster than level 1 but with
564               less good compression ratios. For instance, level -3
565               corresponds to --fast=3 for the zstd command line tool. In
566               practice, there is little use for levels lower than -5 or so.
567
568           0 (default)
569               The value 0 means that ccache will choose a suitable level,
570               currently 1.
571
572           See the Zstandard documentation <http://zstd.net> for more
573           information.
574
575       cpp_extension (CCACHE_EXTENSION)
576           This option can be used to force a certain extension for the
577           intermediate preprocessed file. The default is to automatically
578           determine the extension to use for intermediate preprocessor files
579           based on the type of file being compiled, but that sometimes
580           doesn’t work. For example, when using the “aCC” compiler on HP-UX,
581           set the cpp extension to i.
582
583       debug (CCACHE_DEBUG or CCACHE_NODEBUG, see Boolean values above)
584           If true, enable the debug mode. The debug mode creates per-object
585           debug files that are helpful when debugging unexpected cache
586           misses. Note however that ccache performance will be reduced
587           slightly. See CACHE DEBUGGING for more information. The default is
588           false.
589
590       debug_dir (CCACHE_DEBUGDIR)
591           Specifies where to write per-object debug files if the debug mode
592           is enabled. If set to the empty string, the files will be written
593           next to the object file. If set to a directory, the debug files
594           will be written with full absolute paths in that directory,
595           creating it if needed. The default is the empty string.
596
597           For example, if debug_dir is set to /example, the current working
598           directory is /home/user and the object file is build/output.o then
599           the debug log will be written to
600           /example/home/user/build/output.o.ccache-log. See also CACHE
601           DEBUGGING.
602
603       depend_mode (CCACHE_DEPEND or CCACHE_NODEPEND, see Boolean values
604       above)
605           If true, the depend mode will be used. The default is false. See
606           The depend mode.
607
608       direct_mode (CCACHE_DIRECT or CCACHE_NODIRECT, see Boolean values
609       above)
610           If true, the direct mode will be used. The default is true. See The
611           direct mode.
612
613       disable (CCACHE_DISABLE or CCACHE_NODISABLE, see Boolean values above)
614           When true, ccache will just call the real compiler, bypassing the
615           cache completely. The default is false.
616
617       extra_files_to_hash (CCACHE_EXTRAFILES)
618           This option is a list of paths to files that ccache will include in
619           the the hash sum that identifies the build. The list separator is
620           semicolon on Windows systems and colon on other systems.
621
622       file_clone (CCACHE_FILECLONE or CCACHE_NOFILECLONE, see Boolean values
623       above)
624           If true, ccache will attempt to use file cloning (also known as
625           “copy on write”, “CoW” or “reflinks”) to store and fetch cached
626           compiler results. file_clone has priority over hard_link. The
627           default is false.
628
629           Files stored by cloning cannot be compressed, so the cache size
630           will likely be significantly larger if this option is enabled.
631           However, performance may be improved depending on the use case.
632
633           Unlike the hard_link option, file_clone is completely safe to use,
634           but not all file systems support the feature. For such file
635           systems, ccache will fall back to use plain copying (or hard links
636           if hard_link is enabled).
637
638       hard_link (CCACHE_HARDLINK or CCACHE_NOHARDLINK, see Boolean values
639       above)
640           If true, ccache will attempt to use hard links to store and fetch
641           cached object files. The default is false.
642
643           Files stored via hard links cannot be compressed, so the cache size
644           will likely be significantly larger if this option is enabled.
645           However, performance may be improved depending on the use case.
646
647               Warning
648               Do not enable this option unless you are aware of these
649               caveats:
650
651           •   If the resulting file is modified, the file in the cache will
652               also be modified since they share content, which corrupts the
653               cache entry. As of version 4.0, ccache makes stored and fetched
654               object files read-only as a safety measure. Furthermore, a
655               simple integrity check is made for cached object files by
656               verifying that their sizes are correct. This means that
657               mistakes like strip file.o or echo >file.o will be detected
658               even if the object file is made writeable, but a modification
659               that doesn’t change the file size will not.
660
661           •   Programs that don’t expect that files from two different
662               identical compilations are hard links to each other can fail.
663
664           •   Programs that rely on modification times (like make) can be
665               confused if several users (or one user with several build
666               trees) use the same cache directory. The reason for this is
667               that the object files share i-nodes and therefore modification
668               times. If file.o is in build tree A (hard-linked from the
669               cache) and file.o then is produced by ccache in build tree B by
670               hard-linking from the cache, the modification timestamp will be
671               updated for file.o in build tree A as well. This can retrigger
672               relinking in build tree A even though nothing really has
673               changed.
674
675       hash_dir (CCACHE_HASHDIR or CCACHE_NOHASHDIR, see Boolean values above)
676           If true (which is the default), ccache will include the current
677           working directory (CWD) in the hash that is used to distinguish two
678           compilations when generating debug info (compiler option -g with
679           variations). Exception: The CWD will not be included in the hash if
680           base_dir is set (and matches the CWD) and the compiler option
681           -fdebug-prefix-map is used. See also the discussion under COMPILING
682           IN DIFFERENT DIRECTORIES.
683
684           The reason for including the CWD in the hash by default is to
685           prevent a problem with the storage of the current working directory
686           in the debug info of an object file, which can lead ccache to
687           return a cached object file that has the working directory in the
688           debug info set incorrectly.
689
690           You can disable this option to get cache hits when compiling the
691           same source code in different directories if you don’t mind that
692           CWD in the debug info might be incorrect.
693
694       ignore_headers_in_manifest (CCACHE_IGNOREHEADERS)
695           This option is a list of paths to files (or directories with
696           headers) that ccache will not include in the manifest list that
697           makes up the direct mode. Note that this can cause stale cache hits
698           if those headers do indeed change. The list separator is semicolon
699           on Windows systems and colon on other systems.
700
701       ignore_options (CCACHE_IGNOREOPTIONS)
702           This option is a space-delimited list of compiler options that
703           ccache will exclude from the hash. Excluding a compiler option from
704           the hash can be useful when you know it doesn’t affect the result
705           (but ccache doesn’t know that), or when it does and you don’t care.
706           If a compiler option in the list is suffixed with an asterisk (*)
707           it will be matched as a prefix. For example, -fmessage-length=*
708           will match both -fmessage-length=20 and -fmessage-length=70.
709
710       inode_cache (CCACHE_INODECACHE or CCACHE_NOINODECACHE, see Boolean
711       values above)
712           If true, ccache will cache source file hashes based on device,
713           inode and timestamps. This reduces the time spent on hashing
714           include files since the result can be resused between compilations.
715           The default is true. The feature requires temporary_dir to be
716           located on a local filesystem of a supported type.
717
718               Note
719               The inode cache feature is currently not available on Windows.
720
721       keep_comments_cpp (CCACHE_COMMENTS or CCACHE_NOCOMMENTS, see Boolean
722       values above)
723           If true, ccache will not discard the comments before hashing
724           preprocessor output. The default is false. This can be used to
725           check documentation with -Wdocumentation.
726
727       limit_multiple (CCACHE_LIMIT_MULTIPLE)
728           Sets the limit when cleaning up. Files are deleted (in LRU order)
729           until the levels are below the limit. The default is 0.8 (= 80%).
730           See Automatic cleanup for more information.
731
732       log_file (CCACHE_LOGFILE)
733           If set to a file path, ccache will write information on what it is
734           doing to the specified file. This is useful for tracking down
735           problems.
736
737           If set to syslog, ccache will log using syslog() instead of to a
738           file. If you use rsyslogd, you can add something like this to
739           /etc/rsyslog.conf or a file in /etc/rsyslog.d:
740
741               # log ccache to file
742               :programname, isequal, "ccache"         /var/log/ccache
743               # remove from syslog
744               & ~
745
746       max_files (CCACHE_MAXFILES)
747           This option specifies the maximum number of files to keep in the
748           cache. Use 0 for no limit (which is the default). See also CACHE
749           SIZE MANAGEMENT.
750
751       max_size (CCACHE_MAXSIZE)
752           This option specifies the maximum size of the cache. Use 0 for no
753           limit. The default value is 5G. Available suffixes: k, M, G, T
754           (decimal) and Ki, Mi, Gi, Ti (binary). The default suffix is G. See
755           also CACHE SIZE MANAGEMENT.
756
757       msvc_dep_prefix (CCACHE_MSVC_DEP_PREFIX)
758           This option specifies the prefix of included files output for MSVC
759           compiler. The default prefix is “Note: including file:”. If you use
760           a localized compiler, this should be set accordingly.
761
762       namespace (CCACHE_NAMESPACE)
763           If set, the namespace string will be added to the hashed data for
764           each compilation. This will make the associated cache entries
765           logically separate from cache entries with other namespaces, but
766           they will still share the same storage space. Cache entries can
767           also be selectively removed from the local cache with the command
768           line option --evict-namespace, potentially in combination with
769           --evict-older-than.
770
771           For instance, if you use the same local cache for several disparate
772           projects, you can use a unique namespace string for each one. This
773           allows you to remove cache entries that belong to a certain project
774           if you stop working with that project.
775
776       path (CCACHE_PATH)
777           If set, ccache will search directories in this list when looking
778           for the real compiler. The list separator is semicolon on Windows
779           systems and colon on other systems. If not set, ccache will look
780           for the first executable matching the compiler name in the normal
781           PATH that isn’t a symbolic link to ccache itself.
782
783       pch_external_checksum (CCACHE_PCH_EXTSUM or CCACHE_NOPCH_EXTSUM, see
784       Boolean values above)
785           When this option is set, and ccache finds a precompiled header
786           file, ccache will look for a file with the extension “.sum” added
787           (e.g. “pre.h.gch.sum”), and if found, it will hash this file
788           instead of the precompiled header itself to work around the
789           performance penalty of hashing very large files.
790
791       prefix_command (CCACHE_PREFIX)
792           This option adds a list of prefixes (separated by space) to the
793           command line that ccache uses when invoking the compiler. See also
794           USING CCACHE WITH OTHER COMPILER WRAPPERS.
795
796       prefix_command_cpp (CCACHE_PREFIX_CPP)
797           This option adds a list of prefixes (separated by space) to the
798           command line that ccache uses when invoking the preprocessor.
799
800       read_only (CCACHE_READONLY or CCACHE_NOREADONLY, see Boolean values
801       above)
802           If true, ccache will attempt to use existing cached results, but it
803           will not add new results to any cache backend. Statistics counters
804           will still be updated, though, unless the stats option is set to
805           false.
806
807           If you are using this because your ccache directory is read-only,
808           you need to set temporary_dir since ccache will fail to create
809           temporary files otherwise. You may also want to set stats to false
810           make ccache not even try to update stats files.
811
812       read_only_direct (CCACHE_READONLY_DIRECT or CCACHE_NOREADONLY_DIRECT,
813       see Boolean values above)
814           Just like read_only except that ccache will only try to retrieve
815           results from the cache using the direct mode, not the preprocessor
816           mode. See documentation for read_only regarding using a read-only
817           ccache directory.
818
819       recache (CCACHE_RECACHE or CCACHE_NORECACHE, see Boolean values above)
820           If true, ccache will not use any previously stored result. New
821           results will still be cached, possibly overwriting any pre-existing
822           results.
823
824       remote_only (CCACHE_REMOTE_ONLY or CCACHE_NOREMOTE_ONLY, see Boolean
825       values above)
826           If true, ccache will only use remote storage. The default is false.
827           Note that cache statistics counters will still be kept in the local
828           cache directory unless stats is false. See also Storage
829           interaction.
830
831       remote_storage (CCACHE_REMOTE_STORAGE)
832           This option specifies one or several storage backends (separated by
833           space) to query after checking the local cache (unless remote_only
834           is true). See [Remote storage backends] for documentation of syntax
835           and available backends.
836
837           Examples:
838
839file:/shared/nfs/directory
840
841file:///shared/nfs/one|read-only file:///shared/nfs/two
842
843http://example.com/cache
844
845redis://example.com
846
847                   Note
848                   In previous ccache versions this option was called
849                   secondary_storage (CCACHE_SECONDARY_STORAGE), which can
850                   still be used as an alias.
851
852       reshare (CCACHE_RESHARE or CCACHE_NORESHARE, see Boolean values above)
853           If true, ccache will write results to remote storage even for local
854           storage cache hits. The default is false.
855
856       run_second_cpp (CCACHE_CPP2 or CCACHE_NOCPP2, see Boolean values above)
857           If true, ccache will first run the preprocessor to preprocess the
858           source code (see The preprocessor mode) and then on a cache miss
859           run the compiler on the source code to get hold of the object file.
860           This is the default.
861
862           If false, ccache will first run preprocessor to preprocess the
863           source code and then on a cache miss run the compiler on the
864           preprocessed source code instead of the original source code. This
865           makes cache misses slightly faster since the source code only has
866           to be preprocessed once. The downside is that some compilers won’t
867           produce the same result (for instance diagnostics warnings) when
868           compiling preprocessed source code.
869
870           A solution to the above mentioned downside is to set run_second_cpp
871           to false and pass -fdirectives-only (for GCC) or -frewrite-includes
872           (for Clang) to the compiler. This will cause the compiler to leave
873           the macros and other preprocessor information, and only process the
874           #include directives. When run in this way, the preprocessor
875           arguments will be passed to the compiler since it still has to do
876           some preprocessing (like macros).
877
878           This option is ignored with MSVC, as there is no way to make it
879           compile without preprocessing first.
880
881       sloppiness (CCACHE_SLOPPINESS)
882           By default, ccache tries to give as few false cache hits as
883           possible. However, in certain situations it’s possible that you
884           know things that ccache can’t take for granted. This option makes
885           it possible to tell ccache to relax some checks in order to
886           increase the hit rate. The value should be a comma-separated string
887           with one or several of the following values:
888
889           clang_index_store
890               Ignore the Clang compiler option -index-store-path and its
891               argument when computing the manifest hash. This is useful if
892               you use Xcode, which uses an index store path derived from the
893               local project path. Note that the index store won’t be updated
894               correctly on cache hits if you enable this sloppiness.
895
896           file_stat_matches
897               Ccache normally examines a file’s contents to determine whether
898               it matches the cached version. With this sloppiness set, ccache
899               will consider a file as matching its cached version if the
900               mtimes and ctimes match.
901
902           file_stat_matches_ctime
903               Ignore ctimes when file_stat_matches is enabled. This can be
904               useful when backdating files' mtimes in a controlled way.
905
906           gcno_cwd
907               By default, ccache will include the current working directory
908               in the hash when producing a .gcno file (when compiling with
909               -ftest-coverage or --coverage). This is because GCC 9+ includes
910               the current working directory in the .gcno file. The gcno_cwd
911               sloppiness makes ccache not hash the current working directory
912               so that you can get cache hits when compiling in different
913               directories, with the tradeoff of potentially getting an
914               incorrect directory in the .gcno file. gcno_cwd also disables
915               hashing of the current working directory if -fprofile-abs-path
916               is used.
917
918           include_file_ctime
919               By default, ccache will disable the direct mode if an include
920               file has too new ctime. This sloppiness disables that check.
921               See also [Handling of newly created header files].
922
923           include_file_mtime
924               By default, ccache will disable the direct mode if an include
925               file has too new mtime. This sloppiness disables that check.
926               See also [Handling of newly created header files].
927
928           ivfsoverlay
929               Ignore the Clang compiler option -ivfsoverlay and its argument.
930               This is useful if you use Xcode, which uses a virtual file
931               system (VFS) for things like combining Objective-C and Swift
932               code.
933
934           locale
935               Ccache includes the environment variables LANG, LC_ALL,
936               LC_CTYPE and LC_MESSAGES in the hash by default since they may
937               affect localization of compiler warning messages. Set this
938               sloppiness to tell ccache not to do that.
939
940           modules
941               By default, ccache will not cache compilations if -fmodules is
942               used since it cannot hash the state of compiler’s internal
943               representation of relevant modules. This sloppiness allows
944               caching in such a case. See C++ MODULES for more information.
945
946           pch_defines
947               Be sloppy about #define directives when precompiling a header
948               file. See PRECOMPILED HEADERS for more information.
949
950           random_seed
951               Ignore the -frandom-seed option and its arguments when
952               computing the input hash. This is useful if your build system
953               generates different seeds between builds and you are OK with
954               reusing cached results.
955
956           system_headers
957               By default, ccache will also include all system headers in the
958               manifest. With this sloppiness set, ccache will only include
959               system headers in the hash but not add the system header files
960               to the list of include files.
961
962           time_macros
963               Ignore __DATE__, __TIME__ and __TIMESTAMP__ being present in
964               the source code.
965
966           See the discussion under TROUBLESHOOTING for more information.
967
968       stats (CCACHE_STATS or CCACHE_NOSTATS, see Boolean values above)
969           If true, ccache will update the statistics counters on each
970           compilation. The default is true.
971
972       stats_log (CCACHE_STATSLOG)
973           If set to a file path, ccache will write statistics counter updates
974           to the specified file. This is useful for getting statistics for
975           individual builds. To show a summary of the current stats log, use
976           ccache --show-log-stats.
977
978               Note
979               Lines in the stats log starting with a hash sign (#) are
980               comments.
981
982       temporary_dir (CCACHE_TEMPDIR)
983           This option specifies where ccache will put temporary files. The
984           default is $XDG_RUNTIME_DIR/ccache-tmp (typically
985           /run/user/<UID>/ccache-tmp) if XDG_RUNTIME_DIR is set and the
986           directory exists, otherwise <cache_dir>/tmp.
987
988               Note
989               In previous versions of ccache, CCACHE_TEMPDIR had to be on the
990               same filesystem as the CCACHE_DIR path, but this requirement
991               has been relaxed.
992
993       umask (CCACHE_UMASK)
994           This option (an octal integer) specifies the umask for files and
995           directories in the cache directory. This is mostly useful when you
996           wish to share your cache with other users.
997

REMOTE STORAGE BACKENDS

999       The remote_storage option lets you configure ccache to use one or
1000       several remote storage backends. By default, the local cache directory
1001       located in cache_dir will be queried first and remote storage second,
1002       but remote_only can be set to true to disable local storage. Note that
1003       cache statistics counters will still be kept in the local cache
1004       directory — remote storage backends only store compilation results and
1005       manifests.
1006
1007       A remote storage backend is specified with a URL, optionally followed
1008       by a pipe (|) and a pipe-separated list of attributes. An attribute is
1009       key=value or just key as a short form of key=true. Attribute values
1010       must be percent-encoded
1011       <https://en.wikipedia.org/wiki/Percent-encoding> if they contain
1012       percent, pipe or space characters.
1013
1014   Attributes for all backends
1015       These optional attributes are available for all remote storage
1016       backends:
1017
1018read-only: If true, only read from this backend, don’t write. The
1019           default is false.
1020
1021shards: A comma-separated list of names for sharding (partitioning)
1022           the cache entries using Rendezvous hashing
1023           <https://en.wikipedia.org/wiki/Rendezvous_hashing>, typically to
1024           spread the cache over a server cluster. When set, the storage URL
1025           must contain an asterisk (*), which will be replaced by one of the
1026           shard names to form a real URL. A shard name can optionally have an
1027           appended weight within parentheses to indicate how much of the key
1028           space should be associated with that shard. A shard with weight w
1029           will contain w/S of the cache, where S is the sum of all shard
1030           weights. A weight could for instance be set to represent the
1031           available memory for a memory cache on a specific server. The
1032           default weight is 1.
1033
1034           Examples:
1035
1036redis://cache-*.example.com|shards=a(3),b(1),c(1.5) will put
1037               55% (3/5.5) of the cache on redis://cache-a.example.com, 18%
1038               (1/5.5) on redis://cache-b.example.com and 27% (1.5/5.5) on
1039               redis://cache-c.example.com.
1040
1041http://example.com/*|shards=alpha,beta will put 50% of the
1042               cache on http://example.com/alpha and 50% on
1043               http://example.com/beta.
1044
1045   Storage interaction
1046       The table below describes the interaction between local and remote
1047       storage on cache hits and misses if remote_only is false (which is the
1048       default):
1049
1050       ┌──────────────┬────────────────┬───────────────────┐
1051       │              │                │                   │
1052Local storage Remote storage What happens      
1053       ├──────────────┼────────────────┼───────────────────┤
1054       │              │                │                   │
1055       │miss          │ miss           │ Compile, write to │
1056       │              │                │ local, write to   │
1057       │              │                │ remote[1]         │
1058       ├──────────────┼────────────────┼───────────────────┤
1059       │              │                │                   │
1060       │miss          │ hit            │ Read from remote, │
1061       │              │                │ write to local    │
1062       ├──────────────┼────────────────┼───────────────────┤
1063       │              │                │                   │
1064       │hit           │ -              │ Read from local,  │
1065       │              │                │ don’t write to    │
1066       │              │                │ remote[2]         │
1067       └──────────────┴────────────────┴───────────────────┘
1068
1069       [1] Unless remote storage has attribute read-only=true.
1070       [2] Unless local storage is set to share its cache hits with the
1071       reshare option.
1072
1073       If remote_only is true:
1074
1075       ┌──────────────┬────────────────┬─────────────────────┐
1076       │              │                │                     │
1077Local storage Remote storage What happens        
1078       ├──────────────┼────────────────┼─────────────────────┤
1079       │              │                │                     │
1080       │-             │ miss           │ Compile, write to   │
1081       │              │                │ remote, don’t write │
1082       │              │                │ to local            │
1083       ├──────────────┼────────────────┼─────────────────────┤
1084       │              │                │                     │
1085       │-             │ hit            │ Read from remote,   │
1086       │              │                │ don’t write to      │
1087       │              │                │ local               │
1088       └──────────────┴────────────────┴─────────────────────┘
1089
1090   File storage backend
1091       URL format: file:DIRECTORY or file://[HOST]DIRECTORY
1092
1093       This backend stores data as separate files in a directory structure
1094       below DIRECTORY, similar (but not identical) to the local cache
1095       storage. A typical use case for this backend would be sharing a cache
1096       on an NFS directory. DIRECTORY must start with a slash. HOST can be the
1097       empty string or localhost. On Windows, HOST can also be the name of a
1098       server hosting a shared folder.
1099
1100           Important
1101           ccache will not perform any cleanup of the storage — that has to be
1102           done by other means, for instance by running ccache --trim-dir
1103           periodically.
1104
1105       Examples:
1106
1107file:/shared/nfs/directory
1108
1109file:///shared/nfs/directory|umask=002|update-mtime=true
1110
1111file://example.com/shared/folder
1112
1113       Optional attributes:
1114
1115layout: How to store file under the cache directory. Available
1116           values:
1117
1118flat: Store all files directly under the cache directory.
1119
1120subdirs: Store files in 256 subdirectories of the cache
1121               directory.
1122
1123           The default is subdirs.
1124
1125umask: This attribute (an octal integer) overrides the umask to use
1126           for files and directories in the cache directory.
1127
1128update-mtime: If true, update the modification time (mtime) of
1129           cache entries that are read. The default is false.
1130
1131   HTTP storage backend
1132       URL format: http://HOST[:PORT][/PATH]
1133
1134       This backend stores data in an HTTP-compatible server. The required
1135       HTTP methods are GET, PUT and DELETE.
1136
1137           Important
1138           ccache will not perform any cleanup of the storage — that has to be
1139           done by other means, for instance by running ccache --trim-dir
1140           periodically.
1141
1142           Note
1143           HTTPS is not supported.
1144
1145           Tip
1146           See How to set up HTTP storage
1147           <https://ccache.dev/howto/http-storage.html> for hints on how to
1148           set up an HTTP server for use with ccache.
1149
1150       Examples:
1151
1152http://localhost
1153
1154http://someusername:p4ssw0rd@example.com/cache/
1155
1156http://localhost:8080|layout=bazel|connect-timeout=50
1157
1158       Optional attributes:
1159
1160bearer-token: Bearer token used to authorize the HTTP requests.
1161
1162connect-timeout: Timeout (in ms) for network connection. The
1163           default is 100.
1164
1165keep-alive: If true, keep the HTTP connection to the storage server
1166           open to avoid reconnects. The default is true.
1167
1168layout: How to map key names to the path part of the URL. Available
1169           values:
1170
1171bazel: Store values in a format compatible with the Bazel HTTP
1172               caching protocol. More specifically, the entries will be stored
1173               as 64 hex digits under the /ac/ part of the cache.
1174
1175                   Note
1176                   You may have to disable verification of action cache values
1177                   in the server for this to work since ccache entries are not
1178                   valid action result metadata values.
1179
1180flat: Append the key directly to the path part of the URL (with
1181               a leading slash if needed).
1182
1183subdirs: Append the first two characters of the key to the URL
1184               (with a leading slash if needed), followed by a slash and the
1185               rest of the key. This divides the entries into 256 buckets.
1186
1187           The default is subdirs.
1188
1189operation-timeout: Timeout (in ms) for HTTP requests. The default
1190           is 10000.
1191
1192   Redis storage backend
1193       URL formats:
1194
1195       redis://[[USERNAME:]PASSWORD@]HOST[:PORT][/DBNUMBER]
1196       redis+unix:SOCKET_PATH[?db=DBNUMBER]
1197       redis+unix://[[USERNAME:]PASSWORD@localhost]SOCKET_PATH[?db=DBNUMBER]
1198
1199       This backend stores data in a Redis <https://redis.io> (or
1200       Redis-compatible) server. There are implementations for both
1201       memory-based and disk-based storage. PORT defaults to 6379 and DBNUMBER
1202       defaults to 0.
1203
1204           Note
1205           ccache will not perform any cleanup of the Redis storage, but you
1206           can configure LRU eviction <https://redis.io/topics/lru-cache>.
1207
1208           Tip
1209           See How to set up Redis
1210           <https://ccache.dev/howto/redis-storage.html> storage"  for hints
1211           on setting up a Redis server for use with ccache.
1212
1213           Tip
1214           You can set up a cluster of Redis servers using the shards
1215           attribute described in REMOTE STORAGE BACKENDS.
1216
1217       Examples:
1218
1219redis://localhost
1220
1221redis://p4ssw0rd@cache.example.com:6379/0|connect-timeout=50
1222
1223redis+unix:/run/redis.sock
1224
1225redis+unix:///run/redis.sock
1226
1227redis+unix://p4ssw0rd@localhost/run/redis.sock?db=0
1228
1229       Optional attributes:
1230
1231connect-timeout: Timeout (in ms) for network connection. The
1232           default is 100.
1233
1234operation-timeout: Timeout (in ms) for Redis commands. The default
1235           is 10000.
1236

CACHE SIZE MANAGEMENT

1238       By default, ccache has a 5 GB limit on the total size of files in the
1239       cache and no limit on the number of files. You can set different limits
1240       using the command line options -M/--max-size and -F/--max-files. Use
1241       the -s/--show-stats option to see the cache size and the currently
1242       configured limits (in addition to other various statistics).
1243
1244       Cleanup can be triggered in two different ways: automatic and manual.
1245
1246   Automatic cleanup
1247       Ccache maintains counters for various statistics about the cache,
1248       including the size and number of all cached files. In order to improve
1249       performance and reduce issues with concurrent ccache invocations, there
1250       is one statistics file for each of the sixteen subdirectories in the
1251       cache.
1252
1253       After a new compilation result has been written to the cache, ccache
1254       will update the size and file number statistics for the subdirectory
1255       (one of sixteen) to which the result was written. Then, if the size
1256       counter for said subdirectory is greater than max_size / 16 or the file
1257       number counter is greater than max_files / 16, automatic cleanup is
1258       triggered.
1259
1260       When automatic cleanup is triggered for a subdirectory in the cache,
1261       ccache will:
1262
1263        1. Count all files in the subdirectory and compute their aggregated
1264           size.
1265
1266        2. Remove files in LRU (least recently used) order until the size is
1267           at most limit_multiple * max_size / 16 and the number of files is
1268           at most limit_multiple * max_files / 16, where limit_multiple,
1269           max_size and max_files are configuration options.
1270
1271        3. Set the size and file number counters to match the files that were
1272           kept.
1273
1274       The reason for removing more files than just those needed to not exceed
1275       the max limits is that a cleanup is a fairly slow operation, so it
1276       would not be a good idea to trigger it often, like after each cache
1277       miss.
1278
1279       The LRU cleanup makes use of the file modification time (mtime) of
1280       cache entries; ccache updates mtime of the cache entries read on a
1281       cache hit to mark them as "recently used".
1282
1283   Manual cleanup
1284       You can run ccache -c/--cleanup to force cleanup of the whole cache,
1285       i.e. all of the sixteen subdirectories. This will recalculate the
1286       statistics counters and make sure that the configuration options
1287       max_size and max_files are not exceeded. Note that limit_multiple is
1288       not taken into account for manual cleanup.
1289

CACHE COMPRESSION

1291       Ccache will by default compress all data it puts into the cache using
1292       the compression algorithm Zstandard <http://zstd.net> (zstd) using
1293       compression level 1. The algorithm is fast enough that there should be
1294       little reason to turn off compression to gain performance. One
1295       exception is if the cache is located on a compressed file system, in
1296       which case the compression performed by ccache of course is redundant.
1297       See the documentation for the configuration options compression and
1298       compression_level for more information.
1299
1300       You can use the command line option -x/--show-compression to print
1301       information related to compression. Example:
1302
1303           Total data:           14.8 GB (16.0 GB disk blocks)
1304           Compressed data:      11.3 GB (30.6% of original size)
1305             Original size:      36.9 GB
1306             Compression ratio: 3.267 x  (69.4% space savings)
1307           Incompressible data:   3.5 GB
1308
1309       Notes:
1310
1311       •   The “disk blocks” size is the cache size when taking disk block
1312           size into account. This value should match the “Cache size” value
1313           from “ccache --show-stats”. The other size numbers refer to actual
1314           content sizes.
1315
1316       •   “Compressed data” refers to result and manifest files stored in the
1317           cache.
1318
1319       •   “Incompressible data” refers to files that are always stored
1320           uncompressed (triggered by enabling file_clone or hard_link) or
1321           unknown files (for instance files created by older ccache
1322           versions).
1323
1324       •   The compression ratio is affected by compression_level.
1325
1326       The cache data can also be recompressed to another compression level
1327       (or made uncompressed) with the command line option -X/--recompress. If
1328       you choose to disable compression by default or to use a low
1329       compression level, you can (re)compress newly cached data with a higher
1330       compression level after the build or at another time when there are
1331       more CPU cycles available, for instance every night. Full recompression
1332       potentially takes a lot of time, but only files that are currently
1333       compressed with a different level than the target level will be
1334       recompressed.
1335

CACHE STATISTICS

1337       ccache --show-stats shows a summary of statistics, including cache
1338       size, cleanups (number of performed cleanups, either implicitly due to
1339       a cache size limit being reached or due to explicit ccache -c calls),
1340       overall hit rate, hit rate for direct/preprocessed modes and hit rate
1341       for local and remote storage.
1342
1343       The summary also includes counters called “Errors” and “Uncacheable”,
1344       which are sums of more detailed counters. To see those detailed
1345       counters, use the -v/--verbose flag. The verbose mode can show the
1346       following counters:
1347
1348       ┌───────────────────────────┬────────────────────────────┐
1349       │                           │                            │
1350Counter                    Description                
1351       ├───────────────────────────┼────────────────────────────┤
1352       │                           │                            │
1353       │Autoconf compile/link      │ Uncacheable compilation or │
1354       │                           │ linking by an Autoconf     │
1355       │                           │ test.                      │
1356       ├───────────────────────────┼────────────────────────────┤
1357       │                           │                            │
1358       │Bad compiler arguments     │ Malformed compiler         │
1359       │                           │ argument, e.g. missing a   │
1360       │                           │ value for a compiler       │
1361       │                           │ option that requires an    │
1362       │                           │ argument or failure to     │
1363       │                           │ read a file specified by a │
1364       │                           │ compiler option argument.  │
1365       ├───────────────────────────┼────────────────────────────┤
1366       │                           │                            │
1367       │Called for linking         │ The compiler was called    │
1368       │                           │ for linking, not           │
1369       │                           │ compiling. Ccache only     │
1370       │                           │ supports compilation of a  │
1371       │                           │ single file, i.e. calling  │
1372       │                           │ the compiler with the -c   
1373       │                           │ option to produce a single │
1374       │                           │ object file from a single  │
1375       │                           │ source file.               │
1376       ├───────────────────────────┼────────────────────────────┤
1377       │                           │                            │
1378       │Called for preprocessing   │ The compiler was called    │
1379       │                           │ for preprocessing, not     │
1380       │                           │ compiling.                 │
1381       ├───────────────────────────┼────────────────────────────┤
1382       │                           │                            │
1383       │Could not use modules      │ Preconditions for using    │
1384       │                           │ C++ MODULES were not       │
1385       │                           │ fulfilled.                 │
1386       ├───────────────────────────┼────────────────────────────┤
1387       │                           │                            │
1388       │Could not use precompiled  │ Preconditions for using    │
1389       │header                     │ precompiled headers were   │
1390       │                           │ not fulfilled.             │
1391       ├───────────────────────────┼────────────────────────────┤
1392       │                           │                            │
1393       │Could not write to output  │ The output path specified  │
1394       │file                       │ with -o could not be       │
1395       │                           │ written to.                │
1396       ├───────────────────────────┼────────────────────────────┤
1397       │                           │                            │
1398       │Compilation failed         │ The compilation failed. No │
1399       │                           │ result stored in the       │
1400       │                           │ cache.                     │
1401       ├───────────────────────────┼────────────────────────────┤
1402       │                           │                            │
1403       │Compiler check failed      │ A compiler check program   │
1404       │                           │ specified by               │
1405       │                           │ compiler_check             
1406       │                           │ (CCACHE_COMPILERCHECK)     │
1407       │                           │ failed.                    │
1408       ├───────────────────────────┼────────────────────────────┤
1409       │                           │                            │
1410       │Compiler output file       │ One of the files expected  │
1411       │missing                    │ to be produced by the      │
1412       │                           │ compiler was missing after │
1413       │                           │ compilation.               │
1414       ├───────────────────────────┼────────────────────────────┤
1415       │                           │                            │
1416       │Compiler produced empty    │ The compiler’s output file │
1417       │output                     │ (typically an object file) │
1418       │                           │ was empty after            │
1419       │                           │ compilation.               │
1420       ├───────────────────────────┼────────────────────────────┤
1421       │                           │                            │
1422       │Could not find the         │ The compiler to execute    │
1423       │compiler                   │ could not be found.        │
1424       ├───────────────────────────┼────────────────────────────┤
1425       │                           │                            │
1426       │Error hashing extra file   │ Failure reading a file     │
1427       │                           │ specified by               │
1428       │                           │ extra_files_to_hash        
1429       │                           │ (CCACHE_EXTRAFILES).       │
1430       ├───────────────────────────┼────────────────────────────┤
1431       │                           │                            │
1432       │Forced recache             │ CCACHE_RECACHE was used to │
1433       │                           │ overwrite an existing      │
1434       │                           │ result.                    │
1435       ├───────────────────────────┼────────────────────────────┤
1436       │                           │                            │
1437       │Internal error             │ Unexpected failure, e.g.   │
1438       │                           │ due to problems            │
1439       │                           │ reading/writing the cache. │
1440       ├───────────────────────────┼────────────────────────────┤
1441       │                           │                            │
1442       │Missing cache file         │ A file was unexpectedly    │
1443       │                           │ missing from the cache.    │
1444       │                           │ This only happens in rare  │
1445       │                           │ situations, e.g. if one    │
1446       │                           │ ccache instance is about   │
1447       │                           │ to get a file from the     │
1448       │                           │ cache while another        │
1449       │                           │ instance removed the file  │
1450       │                           │ as part of cache cleanup.  │
1451       ├───────────────────────────┼────────────────────────────┤
1452       │                           │                            │
1453       │Multiple source files      │ The compiler was called to │
1454       │                           │ compile multiple source    │
1455       │                           │ files in one go. This is   │
1456       │                           │ not supported by ccache.   │
1457       ├───────────────────────────┼────────────────────────────┤
1458       │                           │                            │
1459       │No input file              │ No input file was          │
1460       │                           │ specified to the compiler. │
1461       ├───────────────────────────┼────────────────────────────┤
1462       │                           │                            │
1463       │Output to stdout           │ The compiler was           │
1464       │                           │ instructed to write its    │
1465       │                           │ output to standard output  │
1466       │                           │ using -o -. This is not    │
1467       │                           │ supported by ccache.       │
1468       ├───────────────────────────┼────────────────────────────┤
1469       │                           │                            │
1470       │Preprocessing failed       │ Preprocessing the source   │
1471       │                           │ code using the compiler’s  │
1472       │                           │ -E option failed.          │
1473       ├───────────────────────────┼────────────────────────────┤
1474       │                           │                            │
1475       │Unsupported code directive │ Code like the assembler    │
1476       │                           │ .incbin directive was      │
1477       │                           │ found. This is not         │
1478       │                           │ supported by ccache.       │
1479       ├───────────────────────────┼────────────────────────────┤
1480       │                           │                            │
1481       │Unsupported compiler       │ A compiler option not      │
1482       │option                     │ supported by ccache was    │
1483       │                           │ found.                     │
1484       ├───────────────────────────┼────────────────────────────┤
1485       │                           │                            │
1486       │Unsupported environment    │ An environment variable    │
1487       │variable                   │ not supported by ccache    │
1488       │                           │ was set.                   │
1489       ├───────────────────────────┼────────────────────────────┤
1490       │                           │                            │
1491       │Unsupported source         │ A source language e.g.     │
1492       │language                   │ specified with -x was      │
1493       │                           │ unsupported by ccache.     │
1494       └───────────────────────────┴────────────────────────────┘
1495

HOW CCACHE WORKS

1497       The basic idea is to detect when you are compiling exactly the same
1498       code a second time and reuse the previously produced output. The
1499       detection is done by hashing different kinds of information that should
1500       be unique for the compilation and then using the hash sum to identify
1501       the cached output. Ccache uses BLAKE3, a very fast cryptographic hash
1502       algorithm, for the hashing. On a cache hit, ccache is able to supply
1503       all of the correct compiler outputs (including all warnings, dependency
1504       file, etc) from the cache. Data stored in the cache is checksummed with
1505       XXH3, an extremely fast non-cryptographic algorithm, to detect
1506       corruption.
1507
1508       Ccache has two ways of gathering information used to look up results in
1509       the cache:
1510
1511       •   the preprocessor mode, where ccache runs the preprocessor on the
1512           source code and hashes the result
1513
1514       •   the direct mode, where ccache hashes the source code and include
1515           files directly
1516
1517       The direct mode is generally faster since running the preprocessor has
1518       some overhead.
1519
1520       If no previous result is detected (i.e., there is a cache miss) using
1521       the direct mode, ccache will fall back to the preprocessor mode unless
1522       the depend mode is enabled. In the depend mode, ccache never runs the
1523       preprocessor, not even on cache misses. Read more in The depend mode
1524       below.
1525
1526   Common hashed information
1527       The following information is always included in the hash:
1528
1529       •   the extension used by the compiler for a file with preprocessor
1530           output (normally .i for C code and .ii for C++ code)
1531
1532       •   the compiler’s size and modification time (or other
1533           compiler-specific information specified by compiler_check)
1534
1535       •   the name of the compiler
1536
1537       •   the current directory (if hash_dir is enabled)
1538
1539       •   contents of files specified by extra_files_to_hash (if any)
1540
1541   The preprocessor mode
1542       In the preprocessor mode, the hash is formed of the common information
1543       and:
1544
1545       •   the preprocessor output from running the compiler with -E
1546
1547       •   the command line options except those that affect include files
1548           (-I, -include, -D, etc; the theory is that these command line
1549           options will change the preprocessor output if they have any effect
1550           at all)
1551
1552       •   any standard error output generated by the preprocessor
1553
1554       Based on the hash, the cached compilation result can be looked up
1555       directly in the cache.
1556
1557   The direct mode
1558       In the direct mode, the hash is formed of the common information and:
1559
1560       •   the input source file
1561
1562       •   the compiler options
1563
1564       Based on the hash, a data structure called “manifest” is looked up in
1565       the cache. The manifest contains:
1566
1567       •   references to cached compilation results (object file, dependency
1568           file, etc) that were produced by previous compilations that matched
1569           the hash
1570
1571       •   paths to the include files that were read at the time the
1572           compilation results were stored in the cache
1573
1574       •   hash sums of the include files at the time the compilation results
1575           were stored in the cache
1576
1577       The current contents of the include files are then hashed and compared
1578       to the information in the manifest. If there is a match, ccache knows
1579       the result of the compilation. If there is no match, ccache falls back
1580       to running the preprocessor. The output from the preprocessor is parsed
1581       to find the include files that were read. The paths and hash sums of
1582       those include files are then stored in the manifest along with
1583       information about the produced compilation result.
1584
1585       There is a catch with the direct mode: header files that were used by
1586       the compiler are recorded, but header files that were not used, but
1587       would have been used if they existed, are not. So, when ccache checks
1588       if a result can be taken from the cache, it currently can’t check if
1589       the existence of a new header file should invalidate the result. In
1590       practice, the direct mode is safe to use in the absolute majority of
1591       cases.
1592
1593       The direct mode will be disabled if any of the following holds:
1594
1595direct_mode is false
1596
1597       •   a modification time of one of the include files is too new (needed
1598           to avoid a race condition)
1599
1600       •   a compiler option not supported by the direct mode is used:
1601
1602           •   a -Wp,* compiler option other than -Wp,-MD,<path>,
1603               -Wp,-MMD,<path> and -Wp,-D<define>
1604
1605-Xpreprocessor
1606
1607       •   the string __TIME__ is present in the source code
1608
1609   The depend mode
1610       If the depend mode is enabled, ccache will not use the preprocessor at
1611       all. The hash used to identify results in the cache will be based on
1612       the direct mode hash described above plus information about include
1613       files read from the dependency list generated by MSVC with
1614       /showIncludes, or the dependency file generated by other compilers with
1615       -MD or -MMD.
1616
1617       Advantages:
1618
1619       •   The ccache overhead of a cache miss will be much smaller.
1620
1621       •   Not running the preprocessor at all can be good if compilation is
1622           performed remotely, for instance when using distcc or similar;
1623           ccache then won’t make potentially costly preprocessor calls on the
1624           local machine.
1625
1626       Disadvantages:
1627
1628       •   The cache hit rate will likely be lower since any change to
1629           compiler options or source code will make the hash different.
1630           Compare this with the default setup where ccache will fall back to
1631           the preprocessor mode, which is tolerant to some types of changes
1632           of compiler options and source code changes.
1633
1634       •   If -MD is used, the manifest entries will include system header
1635           files as well, thus slowing down cache hits slightly, just as using
1636           -MD slows down make. This is also the case for MSVC with
1637           /showIncludes.
1638
1639       •   If -MMD is used, the manifest entries will not include system
1640           header files, which means ccache will ignore changes in them.
1641
1642       The depend mode will be disabled if any of the following holds:
1643
1644depend_mode is false.
1645
1646run_second_cpp is false.
1647
1648       •   The compiler is not generating dependencies using -MD or -MMD (for
1649           MSVC, /showIncludes is added automatically if not specified by the
1650           user).
1651

HANDLING OF NEWLY CREATED HEADER FILES

1653       If modification time (mtime) or status change time (ctime) of one of
1654       the include files is equal to (or newer than) the time compilation is
1655       being done, ccache disables the direct mode (or, in the case of a
1656       precompiled header, disables caching completely). This done as a safety
1657       measure to avoid a race condition (see below).
1658
1659       To be able to use a newly created header files in direct mode (or use a
1660       newly precompiled header), either:
1661
1662       •   create the include file earlier in the build process, or
1663
1664       •   set sloppiness to include_file_ctime,include_file_mtime if you are
1665           willing to take the risk, for instance if you know that your build
1666           system is robust enough not to trigger the race condition.
1667
1668       For reference, the race condition mentioned above consists of these
1669       events:
1670
1671        1. The preprocessor is run.
1672
1673        2. An include file is modified by someone.
1674
1675        3. The new include file is hashed by ccache.
1676
1677        4. The real compiler is run on the preprocessor’s output, which
1678           contains data from the old header file.
1679
1680        5. The wrong object file is stored in the cache.
1681

CACHE DEBUGGING

1683       To find out what information ccache actually is hashing, you can enable
1684       the debug mode via the configuration option debug or by setting
1685       CCACHE_DEBUG in the environment. This can be useful if you are
1686       investigating why you don’t get cache hits. Note that performance will
1687       be reduced slightly.
1688
1689       When the debug mode is enabled, ccache will create up to five
1690       additional files next to the object file:
1691
1692       ┌───────────────────────────────────────────┬───────────────────────────┐
1693       │                                           │                           │
1694Filename                                   Description               
1695       ├───────────────────────────────────────────┼───────────────────────────┤
1696       │                                           │                           │
1697<objectfile>.<timestamp>.ccache-input-c    │ Binary input hashed by    │
1698       │                                           │ both the direct mode and  │
1699       │                                           │ the preprocessor mode.    │
1700       ├───────────────────────────────────────────┼───────────────────────────┤
1701       │                                           │                           │
1702<objectfile>.<timestamp>.ccache-input-d    │ Binary input only hashed  │
1703       │                                           │ by the direct mode.       │
1704       ├───────────────────────────────────────────┼───────────────────────────┤
1705       │                                           │                           │
1706<objectfile>.<timestamp>.ccache-input-p    │ Binary input only hashed  │
1707       │                                           │ by the preprocessor mode. │
1708       ├───────────────────────────────────────────┼───────────────────────────┤
1709       │                                           │                           │
1710<objectfile>.<timestamp>.ccache-input-text │ Human-readable combined   │
1711       │                                           │ diffable text version of  │
1712       │                                           │ the three files above.    │
1713       ├───────────────────────────────────────────┼───────────────────────────┤
1714       │                                           │                           │
1715<objectfile>.<timestamp>.ccache-log        │ Log for this object file. │
1716       └───────────────────────────────────────────┴───────────────────────────┘
1717
1718            The timestamp format is
1719           `<year><month><day>_<hour><minute><second>_<microsecond>`.
1720
1721       If debug_dir (environment variable CCACHE_DEBUGDIR) is set, the files
1722       above will be written to that directory with full absolute paths
1723       instead of next to the object file.
1724
1725       In the direct mode, ccache uses the 160 bit BLAKE3 hash of the
1726       “ccache-input-c” + “ccache-input-d” data (where + means concatenation),
1727       while the “ccache-input-c” + “ccache-input-p” data is used in the
1728       preprocessor mode.
1729
1730       The “ccache-input-text” file is a combined text version of the three
1731       binary input files. It has three sections (“COMMON”, “DIRECT MODE” and
1732       “PREPROCESSOR MODE”), which is turn contain annotations that say what
1733       kind of data comes next.
1734
1735       To debug why you don’t get an expected cache hit for an object file,
1736       you can do something like this:
1737
1738        1. Enable debug (CCACHE_DEBUG).
1739
1740        2. Build.
1741
1742        3. Clean and build again.
1743
1744        4. Compare the <objectfile>.<timestamp>.ccache-input-text files for
1745           the two builds. This together with the
1746           <objectfile>.<timestamp>.ccache-log files should give you some
1747           clues about what is happening.
1748

COMPILING IN DIFFERENT DIRECTORIES

1750       Some information included in the hash that identifies a unique
1751       compilation can contain absolute paths:
1752
1753       •   The preprocessed source code may contain absolute paths to include
1754           files if the compiler option -g is used or if absolute paths are
1755           given to -I and similar compiler options.
1756
1757       •   Paths specified by compiler options (such as -I, -MF, etc) on the
1758           command line may be absolute.
1759
1760       •   The source code file path may be absolute, and that path may
1761           substituted for __FILE__ macros in the source code or included in
1762           warnings emitted to standard error by the preprocessor.
1763
1764       This means that if you compile the same code in different locations,
1765       you can’t share compilation results between the different build
1766       directories since you get cache misses because of the absolute build
1767       directory paths that are part of the hash.
1768
1769       Here’s what can be done to enable cache hits between different build
1770       directories:
1771
1772       •   If you build with -g (or similar) to add debug information to the
1773           object file, you must either:
1774
1775           •   use the compiler option -fdebug-prefix-map=<old>=<new> for
1776               relocating debug info to a common prefix (e.g.
1777               -fdebug-prefix-map=$PWD=.); or
1778
1779           •   set hash_dir = false.
1780
1781       •   If you use absolute paths anywhere on the command line (e.g. the
1782           source code file path or an argument to compiler options like -I
1783           and -MF), you must set base_dir to an absolute path to a “base
1784           directory”. Ccache will then rewrite absolute paths under that
1785           directory to relative before computing the hash.
1786

PRECOMPILED HEADERS

1788       Ccache has support for precompiled headers with GCC and Clang. However,
1789       you have to do some things to make it work properly:
1790
1791       •   You must set sloppiness to pch_defines,time_macros. The reason is
1792           that ccache can’t tell whether __TIME__, __DATE__ or __TIMESTAMP__
1793           is used when using a precompiled header. Further, it can’t detect
1794           changes in #defines in the source code because of how preprocessing
1795           works in combination with precompiled headers.
1796
1797       •   You may also want to include include_file_mtime,include_file_ctime
1798           in sloppiness. See HANDLING OF NEWLY CREATED HEADER FILES.
1799
1800       •   You must either:
1801
1802           •   use the compiler option -include to include the precompiled
1803               header (i.e., don’t use #include in the source code to include
1804               the header; the filename itself must be sufficient to find the
1805               header, i.e. -I paths are not searched); or
1806
1807           •   (for the Clang compiler) use the compiler option -include-pch
1808               to include the PCH file generated from the precompiled header;
1809               or
1810
1811           •   (for the GCC compiler) add the compiler option -fpch-preprocess
1812               when compiling.
1813
1814       •   If you use Clang, you must compile with -fno-pch-timestamp.
1815
1816       If you don’t do this, either the non-precompiled version of the header
1817       file will be used (if available) or ccache will fall back to running
1818       the real compiler and increase the statistics counter “Preprocessing
1819       failed” (if the non-precompiled header file is not available).
1820

C++ MODULES

1822       Ccache has support for Clang’s -fmodules option. In practice ccache
1823       only additionally hashes module.modulemap files; it does not know how
1824       Clang handles its cached binary form of modules so those are ignored.
1825       This should not matter in practice: as long as everything else
1826       (including module.modulemap files) is the same the cached result should
1827       work. Still, you must set sloppiness to modules to allow caching.
1828
1829       You must use both direct mode and depend mode. When using the
1830       preprocessor mode Clang does not provide enough information to allow
1831       hashing of module.modulemap files.
1832

SHARING A LOCAL CACHE

1834       A group of developers can increase the cache hit rate by sharing a
1835       local cache directory. To share a local cache without unpleasant side
1836       effects, the following conditions should to be met:
1837
1838       •   Use the same cache directory.
1839
1840       •   Make sure that the configuration option hard_link is false (which
1841           is the default).
1842
1843       •   Make sure that all users are in the same group.
1844
1845       •   Set the configuration option umask to 002. This ensures that cached
1846           files are accessible to everyone in the group.
1847
1848       •   Make sure that all users have write permission in the entire cache
1849           directory (and that you trust all users of the shared cache).
1850
1851       •   Make sure that the setgid bit is set on all directories in the
1852           cache. This tells the filesystem to inherit group ownership for new
1853           directories. The following command might be useful for this:
1854
1855               find $CCACHE_DIR -type d | xargs chmod g+s
1856
1857       The reason to avoid the hard link mode is that the hard links cause
1858       unwanted side effects, as all links to a cached file share the file’s
1859       modification timestamp. This results in false dependencies to be
1860       triggered by timestamp-based build systems whenever another user links
1861       to an existing file. Typically, users will see that their libraries and
1862       binaries are relinked without reason.
1863
1864       You may also want to make sure that a base directory is set
1865       appropriately, as discussed in a previous section.
1866

SHARING A CACHE ON NFS

1868       It is possible to put the cache directory on an NFS filesystem (or
1869       similar filesystems), but keep in mind that:
1870
1871       •   Having the cache on NFS may slow down compilation. Make sure to do
1872           some benchmarking to see if it’s worth it.
1873
1874       •   Ccache hasn’t been tested very thoroughly on NFS.
1875
1876       A tip is to set temporary_dir to a directory on the local host to avoid
1877       NFS traffic for temporary files.
1878
1879       It is recommended to use the same operating system version when using a
1880       shared cache. If operating system versions are different then system
1881       include files will likely be different and there will be few or no
1882       cache hits between the systems. One way of improving cache hit rate in
1883       that case is to set sloppiness to system_headers to ignore system
1884       headers.
1885
1886       An alternative to putting the main cache directory on NFS is to set up
1887       a remote storage file cache.
1888

USING CCACHE WITH OTHER COMPILER WRAPPERS

1890       The recommended way of combining ccache with another compiler wrapper
1891       (such as “distcc”) is by letting ccache execute the compiler wrapper.
1892       This is accomplished by defining prefix_command, for example by setting
1893       the environment variable CCACHE_PREFIX to the name of the wrapper (e.g.
1894       distcc). Ccache will then prefix the command line with the specified
1895       command when running the compiler. To specify several prefix commands,
1896       set prefix_command to a colon-separated list of commands.
1897
1898       Unless you set compiler_check to a suitable command (see the
1899       description of that configuration option), it is not recommended to use
1900       the form ccache anotherwrapper compiler args as the compilation
1901       command. It’s also not recommended to use the masquerading technique
1902       for the other compiler wrapper. The reason is that by default, ccache
1903       will in both cases hash the mtime and size of the other wrapper instead
1904       of the real compiler, which means that:
1905
1906       •   Compiler upgrades will not be detected properly.
1907
1908       •   The cached results will not be shared between compilations with and
1909           without the other wrapper.
1910
1911       Another minor thing is that if prefix_command is used, ccache will not
1912       invoke the other wrapper when running the preprocessor, which increases
1913       performance. You can use prefix_command_cpp if you also want to invoke
1914       the other wrapper when doing preprocessing (normally by adding -E).
1915

CAVEATS

1917       •   The direct mode fails to pick up new header files in some rare
1918           scenarios. See The direct mode above.
1919

TROUBLESHOOTING

1921   General
1922       A general tip for getting information about what ccache is doing is to
1923       enable debug logging by setting the configuration option debug (or the
1924       environment variable CCACHE_DEBUG); see CACHE DEBUGGING for more
1925       information. Another way of keeping track of what is happening is to
1926       check the output of ccache -s.
1927
1928   Performance
1929       Ccache has been written to perform well out of the box, but sometimes
1930       you may have to do some adjustments of how you use the compiler and
1931       ccache in order to improve performance.
1932
1933       Since ccache works best when I/O is fast, put the cache directory on a
1934       fast storage device if possible. Having lots of free memory so that
1935       files in the cache directory stay in the disk cache is also preferable.
1936
1937       A good way of monitoring how well ccache works is to run ccache -s
1938       before and after your build and then compare the statistics counters.
1939       Here are some common problems and what may be done to increase the hit
1940       rate:
1941
1942       •   If the counter for preprocessed cache hits has been incremented
1943           instead of the one for direct cache hits, ccache has fallen back to
1944           preprocessor mode, which is generally slower. Some possible reasons
1945           are:
1946
1947           •   The source code has been modified in such a way that the
1948               preprocessor output is not affected.
1949
1950           •   Compiler arguments that are hashed in the direct mode but not
1951               in the preprocessor mode have changed (-I, -include, -D, etc)
1952               and they didn’t affect the preprocessor output.
1953
1954           •   The compiler option -Xpreprocessor or -Wp,* (except
1955               -Wp,-MD,<path>, -Wp,-MMD,<path>, and -Wp,-D<define>) is used.
1956
1957           •   This was the first compilation with a new value of the base
1958               directory.
1959
1960           •   A modification or status change time of one of the include
1961               files is too new (created the same second as the compilation is
1962               being done). See HANDLING OF NEWLY CREATED HEADER FILES.
1963
1964           •   The __TIME__ preprocessor macro is (potentially) being used.
1965               Ccache turns off direct mode if __TIME__ is present in the
1966               source code. This is done as a safety measure since the string
1967               indicates that a __TIME__ macro may affect the output. (To be
1968               sure, ccache would have to run the preprocessor, but the sole
1969               point of the direct mode is to avoid that.) If you know that
1970               __TIME__ isn’t used in practise, or don’t care if ccache
1971               produces objects where __TIME__ is expanded to something in the
1972               past, you can set sloppiness to time_macros.
1973
1974           •   The __DATE__ preprocessor macro is (potentially) being used and
1975               the date has changed. This is similar to how __TIME__ is
1976               handled. If __DATE__ is present in the source code, ccache
1977               hashes the current date in order to be able to produce the
1978               correct object file if the __DATE__ macro affects the output.
1979               If you know that __DATE__ isn’t used in practise, or don’t care
1980               if ccache produces objects where __DATE__ is expanded to
1981               something in the past, you can set sloppiness to time_macros.
1982
1983           •   The __TIMESTAMP__ preprocessor macro is (potentially) being
1984               used and the source file’s modification time has changed. This
1985               is similar to how __TIME__ is handled. If __TIMESTAMP__ is
1986               present in the source code, ccache hashes the string
1987               representation of the source file’s modification time in order
1988               to be able to produce the correct object file if the
1989               __TIMESTAMP__ macro affects the output. If you know that
1990               __TIMESTAMP__ isn’t used in practise, or don’t care if ccache
1991               produces objects where __TIMESTAMP__ is expanded to something
1992               in the past, you can set sloppiness to time_macros.
1993
1994           •   The input file path has changed. Ccache includes the input file
1995               path in the direct mode hash to be able to take relative
1996               include files into account and to produce a correct object file
1997               if the source code includes a __FILE__ macro.
1998
1999       •   If a cache hit counter was not incremented even though the same
2000           code has been compiled and cached before, ccache has either
2001           detected that something has changed anyway or a cleanup has been
2002           performed (either explicitly or implicitly when a cache limit has
2003           been reached). Some perhaps unobvious things that may result in a
2004           cache miss are usage of __TIME__, __DATE__ or __TIMESTAMP__ macros,
2005           or use of automatically generated code that contains a timestamp,
2006           build counter or other volatile information.
2007
2008       •   If “Multiple source files” has been incremented, it’s an indication
2009           that the compiler has been invoked on several source code files at
2010           once. Ccache doesn’t support that. Compile the source code files
2011           separately if possible.
2012
2013       •   If “Unsupported compiler option” has been incremented, enable debug
2014           logging and check which compiler option was rejected.
2015
2016       •   If “Preprocessing failed” has been incremented, one possible reason
2017           is that precompiled headers are being used. See PRECOMPILED HEADERS
2018           for how to remedy this.
2019
2020       •   If “Could not use precompiled header” has been incremented, see
2021           PRECOMPILED HEADERS.
2022
2023       •   If “Could not use modules” has been incremented, see C++ MODULES.
2024
2025   Corrupt object files
2026       It should be noted that ccache is susceptible to general storage
2027       problems. If a bad object file sneaks into the cache for some reason,
2028       it will of course stay bad. Some possible reasons for erroneous object
2029       files are bad hardware (disk drive, disk controller, memory, etc),
2030       buggy drivers or file systems, a bad prefix_command or compiler
2031       wrapper. If this happens, the easiest way of fixing it is this:
2032
2033        1. Build so that the bad object file ends up in the build tree.
2034
2035        2. Remove the bad object file from the build tree.
2036
2037        3. Rebuild with CCACHE_RECACHE set.
2038
2039       An alternative is to clear the whole cache with ccache -C if you don’t
2040       mind losing other cached results.
2041
2042       There are no reported issues about ccache producing broken object files
2043       reproducibly. That doesn’t mean it can’t happen, so if you find a
2044       repeatable case, please report it.
2045

MORE INFORMATION

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

AUTHOR

2051       Ccache was originally written by Andrew Tridgell and is currently
2052       developed and maintained by Joel Rosdahl. See AUTHORS.txt or
2053       AUTHORS.html and https://ccache.dev/credits.html for a list of
2054       contributors.
2055
2056
2057
2058Ccache 4.7.4                      2022-12-10                         CCACHE(1)
Impressum