Imported Upstream version 3.5.1
[platform/upstream/ccache.git] / doc / ccache.1
1 '\" t
2 .\"     Title: ccache
3 .\"    Author: [see the "Author" section]
4 .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
5 .\"      Date: 01/03/2019
6 .\"    Manual: ccache Manual
7 .\"    Source: ccache 3.5.1
8 .\"  Language: English
9 .\"
10 .TH "CCACHE" "1" "01/03/2019" "ccache 3\&.5\&.1" "ccache Manual"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18 .ie \n(.g .ds Aq \(aq
19 .el       .ds Aq '
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
24 .nh
25 .\" disable justification (adjust text to left margin only)
26 .ad l
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
30 .SH "NAME"
31 ccache \- a fast C/C++ compiler cache
32 .SH "SYNOPSIS"
33 .sp
34 .nf
35 \fBccache\fR [\fIoptions\fR]
36 \fBccache\fR \fIcompiler\fR [\fIcompiler options\fR]
37 \fIcompiler\fR [\fIcompiler options\fR]                   (via symbolic link)
38 .fi
39 .SH "DESCRIPTION"
40 .sp
41 ccache is a compiler cache\&. It speeds up recompilation by caching the result of previous compilations and detecting when the same compilation is being done again\&. Supported languages are C, C++, Objective\-C and Objective\-C++\&.
42 .sp
43 ccache has been carefully written to always produce exactly the same compiler output that you would get without the cache\&. The only way you should be able to tell that you are using ccache is the speed\&. Currently known exceptions to this goal are listed under CAVEATS\&. If you ever discover an undocumented case where ccache changes the output of your compiler, please let us know\&.
44 .SS "Features"
45 .sp
46 .RS 4
47 .ie n \{\
48 \h'-04'\(bu\h'+03'\c
49 .\}
50 .el \{\
51 .sp -1
52 .IP \(bu 2.3
53 .\}
54 Keeps statistics on hits/misses\&.
55 .RE
56 .sp
57 .RS 4
58 .ie n \{\
59 \h'-04'\(bu\h'+03'\c
60 .\}
61 .el \{\
62 .sp -1
63 .IP \(bu 2.3
64 .\}
65 Automatic cache size management\&.
66 .RE
67 .sp
68 .RS 4
69 .ie n \{\
70 \h'-04'\(bu\h'+03'\c
71 .\}
72 .el \{\
73 .sp -1
74 .IP \(bu 2.3
75 .\}
76 Can cache compilations that generate warnings\&.
77 .RE
78 .sp
79 .RS 4
80 .ie n \{\
81 \h'-04'\(bu\h'+03'\c
82 .\}
83 .el \{\
84 .sp -1
85 .IP \(bu 2.3
86 .\}
87 Easy installation\&.
88 .RE
89 .sp
90 .RS 4
91 .ie n \{\
92 \h'-04'\(bu\h'+03'\c
93 .\}
94 .el \{\
95 .sp -1
96 .IP \(bu 2.3
97 .\}
98 Low overhead\&.
99 .RE
100 .sp
101 .RS 4
102 .ie n \{\
103 \h'-04'\(bu\h'+03'\c
104 .\}
105 .el \{\
106 .sp -1
107 .IP \(bu 2.3
108 .\}
109 Optionally compresses files in the cache to reduce disk space\&.
110 .RE
111 .SS "Limitations"
112 .sp
113 .RS 4
114 .ie n \{\
115 \h'-04'\(bu\h'+03'\c
116 .\}
117 .el \{\
118 .sp -1
119 .IP \(bu 2.3
120 .\}
121 Only knows how to cache the compilation of a single C/C++/Objective\-C/Objective\-C++ file\&. Other types of compilations (multi\-file compilation, linking, etc) will silently fall back to running the real compiler\&.
122 .RE
123 .sp
124 .RS 4
125 .ie n \{\
126 \h'-04'\(bu\h'+03'\c
127 .\}
128 .el \{\
129 .sp -1
130 .IP \(bu 2.3
131 .\}
132 Only works with GCC and compilers that behave similar enough\&.
133 .RE
134 .sp
135 .RS 4
136 .ie n \{\
137 \h'-04'\(bu\h'+03'\c
138 .\}
139 .el \{\
140 .sp -1
141 .IP \(bu 2.3
142 .\}
143 Some compiler flags are not supported\&. If such a flag is detected, ccache will silently fall back to running the real compiler\&.
144 .RE
145 .SH "RUN MODES"
146 .sp
147 There are two ways to use ccache\&. You can either prefix your compilation commands with \fBccache\fR or you can let ccache masquerade as the compiler by creating a symbolic link (named as the compiler) to ccache\&. The first method is most convenient if you just want to try out ccache or wish to use it for some specific projects\&. The second method is most useful for when you wish to use ccache for all your compilations\&.
148 .sp
149 To use the first method, just make sure that \fBccache\fR is in your \fBPATH\fR\&.
150 .sp
151 To use the symlinks method, do something like this:
152 .sp
153 .if n \{\
154 .RS 4
155 .\}
156 .nf
157 cp ccache /usr/local/bin/
158 ln \-s ccache /usr/local/bin/gcc
159 ln \-s ccache /usr/local/bin/g++
160 ln \-s ccache /usr/local/bin/cc
161 ln \-s ccache /usr/local/bin/c++
162 .fi
163 .if n \{\
164 .RE
165 .\}
166 .sp
167 And so forth\&. This will work as long as the directory with symlinks comes before the path to the compiler (which is usually in \fB/usr/bin\fR)\&. After installing you may wish to run \(lqwhich gcc\(rq to make sure that the correct link is being used\&.
168 .if n \{\
169 .sp
170 .\}
171 .RS 4
172 .it 1 an-trap
173 .nr an-no-space-flag 1
174 .nr an-break-flag 1
175 .br
176 .ps +1
177 \fBWarning\fR
178 .ps -1
179 .br
180 .sp
181 The technique of letting ccache masquerade as the compiler works well, but currently doesn\(cqt interact well with other tools that do the same thing\&. See USING CCACHE WITH OTHER COMPILER WRAPPERS\&.
182 .sp .5v
183 .RE
184 .if n \{\
185 .sp
186 .\}
187 .RS 4
188 .it 1 an-trap
189 .nr an-no-space-flag 1
190 .nr an-break-flag 1
191 .br
192 .ps +1
193 \fBWarning\fR
194 .ps -1
195 .br
196 .sp
197 Do not use a hard link, use a symbolic link\&. A hard link will cause \(lqinteresting\(rq problems\&.
198 .sp .5v
199 .RE
200 .SH "OPTIONS"
201 .sp
202 These options only apply when you invoke ccache as \(lqccache\(rq\&. When invoked as a compiler (via a symlink as described in the previous section), the normal compiler options apply and you should refer to the compiler\(cqs documentation\&.
203 .PP
204 \fB\fB\-c, \-\-cleanup\fR\fR
205 .RS 4
206 Clean up the cache by removing old cached files until the specified file number and cache size limits are not exceeded\&. This also recalculates the cache file count and size totals\&. Normally, there is no need to initiate cleanup manually as ccache keeps the cache below the specified limits at runtime and keeps statistics up to date on each compilation\&. Forcing a cleanup is mostly useful if you manually modify the cache contents or believe that the cache size statistics may be inaccurate\&.
207 .RE
208 .PP
209 \fB\fB\-C, \-\-clear\fR\fR
210 .RS 4
211 Clear the entire cache, removing all cached files, but keeping the configuration file\&.
212 .RE
213 .PP
214 \fB\fB\-F, \-\-max\-files\fR\fR=\fIN\fR
215 .RS 4
216 Set the maximum number of files allowed in the cache\&. Use 0 for no limit\&. The value is stored in a configuration file in the cache directory and applies to all future compilations\&.
217 .RE
218 .PP
219 \fB\fB\-h, \-\-help\fR\fR
220 .RS 4
221 Print an options summary page\&.
222 .RE
223 .PP
224 \fB\fB\-M, \-\-max\-size\fR\fR=\fISIZE\fR
225 .RS 4
226 Set the maximum size of the files stored in the cache\&.
227 \fISIZE\fR
228 should be a number followed by an optional suffix: k, M, G, T (decimal), Ki, Mi, Gi or Ti (binary)\&. The default suffix is G\&. Use 0 for no limit\&. The value is stored in a configuration file in the cache directory and applies to all future compilations\&.
229 .RE
230 .PP
231 \fB\fB\-o, \-\-set\-config\fR\fR=\fIKEY=VALUE\fR
232 .RS 4
233 Set configuration
234 \fIKEY\fR
235 to
236 \fIVALUE\fR\&. See
237 CONFIGURATION
238 for more information\&.
239 .RE
240 .PP
241 \fB\fB\-p, \-\-print\-config\fR\fR
242 .RS 4
243 Print current configuration options and from where they originate (environment variable, configuration file or compile\-time default)\&.
244 .RE
245 .PP
246 \fB\fB\-s, \-\-show\-stats\fR\fR
247 .RS 4
248 Print the current statistics summary for the cache\&.
249 .RE
250 .PP
251 \fB\fB\-V, \-\-version\fR\fR
252 .RS 4
253 Print version and copyright information\&.
254 .RE
255 .PP
256 \fB\fB\-z, \-\-zero\-stats\fR\fR
257 .RS 4
258 Zero the cache statistics (but not the configuration options)\&.
259 .RE
260 .SH "EXTRA OPTIONS"
261 .sp
262 When run as a compiler, ccache usually just takes the same command line options as the compiler you are using\&. The only exception to this is the option \fB\-\-ccache\-skip\fR\&. That option can be used to tell ccache to avoid interpreting the next option in any way and to pass it along to the compiler as\-is\&.
263 .if n \{\
264 .sp
265 .\}
266 .RS 4
267 .it 1 an-trap
268 .nr an-no-space-flag 1
269 .nr an-break-flag 1
270 .br
271 .ps +1
272 \fBNote\fR
273 .ps -1
274 .br
275 .sp
276 \fB\-\-ccache\-skip\fR currently only tells ccache not to interpret the next option as a special compiler option \(em the option will still be included in the direct mode hash\&.
277 .sp .5v
278 .RE
279 .sp
280 The reason this can be important is that ccache does need to parse the command line and determine what is an input filename and what is a compiler option, as it needs the input filename to determine the name of the resulting object file (among other things)\&. The heuristic ccache uses when parsing the command line is that any argument that exists as a file is treated as an input file name\&. By using \fB\-\-ccache\-skip\fR you can force an option to not be treated as an input file name and instead be passed along to the compiler as a command line option\&.
281 .sp
282 Another case where \fB\-\-ccache\-skip\fR can be useful is if ccache interprets an option specially but shouldn\(cqt, since the option has another meaning for your compiler than what ccache thinks\&.
283 .SH "CONFIGURATION"
284 .sp
285 ccache\(cqs default behavior can be overridden by configuration file settings, which in turn can be overridden by environment variables with names starting with \fBCCACHE_\fR\&. ccache normally reads configuration from two files: first a system\-level configuration file and secondly a cache\-specific configuration file\&. The priority of configuration settings is as follows (where 1 is highest):
286 .sp
287 .RS 4
288 .ie n \{\
289 \h'-04' 1.\h'+01'\c
290 .\}
291 .el \{\
292 .sp -1
293 .IP "  1." 4.2
294 .\}
295 Environment variables\&.
296 .RE
297 .sp
298 .RS 4
299 .ie n \{\
300 \h'-04' 2.\h'+01'\c
301 .\}
302 .el \{\
303 .sp -1
304 .IP "  2." 4.2
305 .\}
306 The cache\-specific configuration file
307 \fB\fI<ccachedir>\fR\fR\fB/ccache\&.conf\fR
308 (typically
309 \fB$HOME/\&.ccache/ccache\&.conf\fR)\&.
310 .RE
311 .sp
312 .RS 4
313 .ie n \{\
314 \h'-04' 3.\h'+01'\c
315 .\}
316 .el \{\
317 .sp -1
318 .IP "  3." 4.2
319 .\}
320 The system\-wide configuration file
321 \fB\fI<sysconfdir>\fR\fR\fB/ccache\&.conf\fR
322 (typically
323 \fB/etc/ccache\&.conf\fR
324 or
325 \fB/usr/local/etc/ccache\&.conf\fR)\&.
326 .RE
327 .sp
328 .RS 4
329 .ie n \{\
330 \h'-04' 4.\h'+01'\c
331 .\}
332 .el \{\
333 .sp -1
334 .IP "  4." 4.2
335 .\}
336 Compile\-time defaults\&.
337 .RE
338 .sp
339 As a special case, if the environment variable \fBCCACHE_CONFIGPATH\fR is set, ccache reads configuration from the specified path instead of the default paths\&.
340 .SS "Configuration file syntax"
341 .sp
342 Configuration files are in a simple \(lqkey = value\(rq format, one setting per line\&. Lines starting with a hash sign are comments\&. Blank lines are ignored, as is whitespace surrounding keys and values\&. Example:
343 .sp
344 .if n \{\
345 .RS 4
346 .\}
347 .nf
348 # Set maximum cache size to 10 GB:
349 max_size = 10G
350 .fi
351 .if n \{\
352 .RE
353 .\}
354 .SS "Boolean values"
355 .sp
356 Some settings are boolean values (i\&.e\&. truth values)\&. In a configuration file, such values must be set to the string \fBtrue\fR or \fBfalse\fR\&. For the corresponding environment variables, the semantics are a bit different: a set environment variable means \(lqtrue\(rq (even if set to the empty string), the following case\-insensitive negative values are considered an error (rather than surprising the user): \fB0\fR, \fBfalse\fR, \fBdisable\fR and \fBno\fR, and an unset environment variable means \(lqfalse\(rq\&. Each boolean environment variable also has a negated form starting with \fBCCACHE_NO\fR\&. For example, \fBCCACHE_COMPRESS\fR can be set to force compression and \fBCCACHE_NOCOMPRESS\fR can be set to force no compression\&.
357 .SS "Configuration settings"
358 .sp
359 Below is a list of available configuration settings\&. The corresponding environment variable name is indicated in parentheses after each configuration setting key\&.
360 .PP
361 \fBbase_dir\fR (\fBCCACHE_BASEDIR\fR)
362 .RS 4
363 This setting should be an absolute path to a directory\&. ccache then rewrites absolute paths into relative paths before computing the hash that identifies the compilation, but only for paths under the specified directory\&. If set to the empty string (which is the default), no rewriting is done\&. A typical path to use as the base directory is your home directory or another directory that is a parent of your build directories\&. Don\(cqt use
364 \fB/\fR
365 as the base directory since that will make ccache also rewrite paths to system header files, which doesn\(cqt gain anything\&.
366 .sp
367 See also the discussion under
368 COMPILING IN DIFFERENT DIRECTORIES\&.
369 .RE
370 .PP
371 \fBcache_dir\fR (\fBCCACHE_DIR\fR)
372 .RS 4
373 This setting specifies where ccache will keep its cached compiler outputs\&. It will only take effect if set in the system\-wide configuration file or as an environment variable\&. The default is
374 \fB$HOME/\&.ccache\fR\&.
375 .RE
376 .PP
377 \fBcache_dir_levels\fR (\fBCCACHE_NLEVELS\fR)
378 .RS 4
379 This setting allows you to choose the number of directory levels in the cache directory\&. The default is 2\&. The minimum is 1 and the maximum is 8\&.
380 .RE
381 .PP
382 \fBcompiler\fR (\fBCCACHE_COMPILER\fR or (deprecated) \fBCCACHE_CC\fR)
383 .RS 4
384 This setting can be used to force the name of the compiler to use\&. If set to the empty string (which is the default), ccache works it out from the command line\&.
385 .RE
386 .PP
387 \fBcompiler_check\fR (\fBCCACHE_COMPILERCHECK\fR)
388 .RS 4
389 By default, ccache includes the modification time (\(lqmtime\(rq) and size of the compiler in the hash to ensure that results retrieved from the cache are accurate\&. This setting can be used to select another strategy\&. Possible values are:
390 .PP
391 \fBcontent\fR
392 .RS 4
393 Hash the content of the compiler binary\&. This makes ccache very slightly slower compared to the
394 \fBmtime\fR
395 setting, but makes it cope better with compiler upgrades during a build bootstrapping process\&.
396 .RE
397 .PP
398 \fBmtime\fR
399 .RS 4
400 Hash the compiler\(cqs mtime and size, which is fast\&. This is the default\&.
401 .RE
402 .PP
403 \fBnone\fR
404 .RS 4
405 Don\(cqt hash anything\&. This may be good for situations where you can safely use the cached results even though the compiler\(cqs mtime or size has changed (e\&.g\&. if the compiler is built as part of your build system and the compiler\(cqs source has not changed, or if the compiler only has changes that don\(cqt affect code generation)\&. You should only use the
406 \fBnone\fR
407 setting if you know what you are doing\&.
408 .RE
409 .PP
410 \fBstring:value\fR
411 .RS 4
412 Use
413 \fBvalue\fR
414 as the string to calculate hash from\&. This can be the compiler revision number you retrieved earlier and set here via environment variable\&.
415 .RE
416 .PP
417 \fIa command string\fR
418 .RS 4
419 Hash the standard output and standard error output of the specified command\&. The string will be split on whitespace to find out the command and arguments to run\&. No other interpretation of the command string will be done, except that the special word
420 \fB%compiler%\fR
421 will be replaced with the path to the compiler\&. Several commands can be specified with semicolon as separator\&. Examples:
422 .sp
423 .if n \{\
424 .RS 4
425 .\}
426 .nf
427 %compiler% \-v
428 .fi
429 .if n \{\
430 .RE
431 .\}
432 .sp
433 .if n \{\
434 .RS 4
435 .\}
436 .nf
437 %compiler% \-dumpmachine; %compiler% \-dumpversion
438 .fi
439 .if n \{\
440 .RE
441 .\}
442 .sp
443 You should make sure that the specified command is as fast as possible since it will be run once for each ccache invocation\&.
444 .sp
445 Identifying the compiler using a command is useful if you want to avoid cache misses when the compiler has been rebuilt but not changed\&.
446 .sp
447 Another case is when the compiler (as seen by ccache) actually isn\(cqt the real compiler but another compiler wrapper \(em in that case, the default
448 \fBmtime\fR
449 method will hash the mtime and size of the other compiler wrapper, which means that ccache won\(cqt be able to detect a compiler upgrade\&. Using a suitable command to identify the compiler is thus safer, but it\(cqs also slower, so you should consider continue using the
450 \fBmtime\fR
451 method in combination with the
452 \fBprefix_command\fR
453 setting if possible\&. See
454 USING CCACHE WITH OTHER COMPILER WRAPPERS\&.
455 .RE
456 .RE
457 .PP
458 \fBcompression\fR (\fBCCACHE_COMPRESS\fR or \fBCCACHE_NOCOMPRESS\fR, see Boolean values above)
459 .RS 4
460 If true, ccache will compress object files and other compiler output it puts in the cache\&. However, this setting has no effect on how files are retrieved from the cache; compressed and uncompressed results will still be usable regardless of this setting\&. The default is false\&.
461 .RE
462 .PP
463 \fBcompression_level\fR (\fBCCACHE_COMPRESSLEVEL\fR)
464 .RS 4
465 This setting determines the level at which ccache will compress object files\&. It only has effect if
466 \fBcompression\fR
467 is enabled\&. The value defaults to 6, and must be no lower than 1 (fastest, worst compression) and no higher than 9 (slowest, best compression)\&.
468 .RE
469 .PP
470 \fBcpp_extension\fR (\fBCCACHE_EXTENSION\fR)
471 .RS 4
472 This setting can be used to force a certain extension for the intermediate preprocessed file\&. The default is to automatically determine the extension to use for intermediate preprocessor files based on the type of file being compiled, but that sometimes doesn\(cqt work\&. For example, when using the \(lqaCC\(rq compiler on HP\-UX, set the cpp extension to
473 \fBi\fR\&.
474 .RE
475 .PP
476 \fBdebug\fR (\fBCCACHE_DEBUG\fR or \fBCCACHE_NODEBUG\fR, see Boolean values above)
477 .RS 4
478 If true, enable the debug mode\&. The debug mode creates per\-object debug files that are helpful when debugging unexpected cache misses\&. Note however that ccache performance will be reduced slightly\&. See
479 debugging
480 for more information\&. The default is false\&.
481 .RE
482 .PP
483 \fBdirect_mode\fR (\fBCCACHE_DIRECT\fR or \fBCCACHE_NODIRECT\fR, see Boolean values above)
484 .RS 4
485 If true, the direct mode will be used\&. The default is true\&. See
486 THE DIRECT MODE\&.
487 .RE
488 .PP
489 \fBdisable\fR (\fBCCACHE_DISABLE\fR or \fBCCACHE_NODISABLE\fR, see Boolean values above)
490 .RS 4
491 When true, ccache will just call the real compiler, bypassing the cache completely\&. The default is false\&.
492 .RE
493 .PP
494 \fBextra_files_to_hash\fR (\fBCCACHE_EXTRAFILES\fR)
495 .RS 4
496 This setting is a list of paths to files that ccache will include in the the hash sum that identifies the build\&. The list separator is semicolon on Windows systems and colon on other systems\&.
497 .RE
498 .PP
499 \fBhard_link\fR (\fBCCACHE_HARDLINK\fR or \fBCCACHE_NOHARDLINK\fR, see Boolean values above)
500 .RS 4
501 If true, ccache will attempt to use hard links from the cache directory when creating the compiler output rather than using a file copy\&. Hard links are never made for compressed cache files\&. This means that you should not enable compression if you want to use hard links\&. The default is false\&.
502 .if n \{\
503 .sp
504 .\}
505 .RS 4
506 .it 1 an-trap
507 .nr an-no-space-flag 1
508 .nr an-break-flag 1
509 .br
510 .ps +1
511 \fBWarning\fR
512 .ps -1
513 .br
514 Do not enable this option unless you are aware of the consequences\&. Using hard links may be slightly faster in some situations, but there are several pitfalls since the resulting object file will share i\-node with the cached object file:
515 .sp .5v
516 .RE
517 .sp
518 .RS 4
519 .ie n \{\
520 \h'-04' 1.\h'+01'\c
521 .\}
522 .el \{\
523 .sp -1
524 .IP "  1." 4.2
525 .\}
526 If the resulting object file is modified in any way, the cached object file will be modified as well\&. For instance, if you run
527 \fBstrip object\&.o\fR
528 or
529 echo >object\&.o, you will corrupt the cache\&.
530 .RE
531 .sp
532 .RS 4
533 .ie n \{\
534 \h'-04' 2.\h'+01'\c
535 .\}
536 .el \{\
537 .sp -1
538 .IP "  2." 4.2
539 .\}
540 Programs that rely on modification times (like \(lqmake\(rq) can be confused since ccache updates the cached files\*(Aq modification times as part of the automatic cache size management\&. This will affect object files in the build tree as well, which can retrigger the linking step even though nothing really has changed\&.
541 .RE
542 .RE
543 .PP
544 \fBhash_dir\fR (\fBCCACHE_HASHDIR\fR or \fBCCACHE_NOHASHDIR\fR, see Boolean values above)
545 .RS 4
546 If true (which is the default), ccache will include the current working directory (CWD) in the hash that is used to distinguish two compilations when generating debug info (compiler option
547 \fB\-g\fR
548 with variations)\&. Exception: The CWD will not be included in the hash if
549 \fBbase_dir\fR
550 is set (and matches the CWD) and the compiler option
551 \fB\-fdebug\-prefix\-map\fR
552 is used\&. See also the discussion under
553 COMPILING IN DIFFERENT DIRECTORIES\&.
554 .sp
555 The reason for including the CWD in the hash by default is to prevent a problem with the storage of the current working directory in the debug info of an object file, which can lead ccache to return a cached object file that has the working directory in the debug info set incorrectly\&.
556 .sp
557 You can disable this setting to get cache hits when compiling the same source code in different directories if you don\(cqt mind that CWD in the debug info might be incorrect\&.
558 .RE
559 .PP
560 \fBignore_headers_in_manifest\fR (\fBCCACHE_IGNOREHEADERS\fR)
561 .RS 4
562 This setting is a list of paths to files (or directories with headers) that ccache will
563 \fBnot\fR
564 include in the manifest list that makes up the direct mode\&. Note that this can cause stale cache hits if those headers do indeed change\&. The list separator is semicolon on Windows systems and colon on other systems\&.
565 .RE
566 .PP
567 \fBkeep_comments_cpp\fR (\fBCCACHE_COMMENTS\fR or \fBCCACHE_NOCOMMENTS\fR, see Boolean values above)
568 .RS 4
569 If true, ccache will not discard the comments before hashing preprocessor output\&. This can be used to check documentation with
570 \fB\-Wdocumentation\fR\&.
571 .RE
572 .PP
573 \fBlimit_multiple\fR (\fBCCACHE_LIMIT_MULTIPLE\fR)
574 .RS 4
575 Sets the limit when cleaning up\&. Files are deleted (in LRU order) until the levels are below the limit\&. The default is 0\&.8 (= 80%)\&. See
576 AUTOMATIC CLEANUP
577 for more information\&.
578 .RE
579 .PP
580 \fBlog_file\fR (\fBCCACHE_LOGFILE\fR)
581 .RS 4
582 If set to a file path, ccache will write information on what it is doing to the specified file\&. This is useful for tracking down problems\&.
583 .RE
584 .PP
585 \fBmax_files\fR (\fBCCACHE_MAXFILES\fR)
586 .RS 4
587 This option specifies the maximum number of files to keep in the cache\&. Use 0 for no limit (which is the default)\&. See also
588 CACHE SIZE MANAGEMENT\&.
589 .RE
590 .PP
591 \fBmax_size\fR (\fBCCACHE_MAXSIZE\fR)
592 .RS 4
593 This option specifies the maximum size of the cache\&. Use 0 for no limit\&. The default value is 5G\&. Available suffixes: k, M, G, T (decimal) and Ki, Mi, Gi, Ti (binary)\&. The default suffix is G\&. See also
594 CACHE SIZE MANAGEMENT\&.
595 .RE
596 .PP
597 \fBpath\fR (\fBCCACHE_PATH\fR)
598 .RS 4
599 If set, ccache will search directories in this list when looking for the real compiler\&. The list separator is semicolon on Windows systems and colon on other systems\&. If not set, ccache will look for the first executable matching the compiler name in the normal
600 \fBPATH\fR
601 that isn\(cqt a symbolic link to ccache itself\&.
602 .RE
603 .PP
604 \fBpch_external_checksum\fR (\fBCCACHE_PCH_EXTSUM\fR or \fBCCACHE_NOPCH_EXTSUM\fR, see Boolean values above)
605 .RS 4
606 When this option is set, and ccache finds a precompiled header file, ccache will look for a file with the extension \(lq\&.sum\(rq added (e\&.g\&. \(lqpre\&.h\&.gch\&.sum\(rq), and if found, it will hash this file instead of the precompiled header itself to work around the performance penalty of hashing very large files\&.
607 .RE
608 .PP
609 \fBprefix_command\fR (\fBCCACHE_PREFIX\fR)
610 .RS 4
611 This option adds a list of prefixes (separated by space) to the command line that ccache uses when invoking the compiler\&. See also
612 USING CCACHE WITH OTHER COMPILER WRAPPERS\&.
613 .RE
614 .PP
615 \fBprefix_command_cpp\fR (\fBCCACHE_PREFIX_CPP\fR)
616 .RS 4
617 This option adds a list of prefixes (separated by space) to the command line that ccache uses when invoking the preprocessor\&.
618 .RE
619 .PP
620 \fBread_only\fR (\fBCCACHE_READONLY\fR or \fBCCACHE_NOREADONLY\fR, see Boolean values above)
621 .RS 4
622 If true, ccache will attempt to use existing cached object files, but it will not to try to add anything new to the cache\&. If you are using this because your ccache directory is read\-only, then you need to set
623 \fBtemporary_dir\fR
624 as otherwise ccache will fail to create temporary files\&.
625 .RE
626 .PP
627 \fBread_only_direct\fR (\fBCCACHE_READONLY_DIRECT\fR or \fBCCACHE_NOREADONLY_DIRECT\fR, see Boolean values above)
628 .RS 4
629 Just like
630 \fBread_only\fR
631 except that ccache will only try to retrieve results from the cache using the direct mode, not the preprocessor mode\&. See documentation for
632 \fBread_only\fR
633 regarding using a read\-only ccache directory\&.
634 .RE
635 .PP
636 \fBrecache\fR (\fBCCACHE_RECACHE\fR or \fBCCACHE_NORECACHE\fR, see Boolean values above)
637 .RS 4
638 If true, ccache will not use any previously stored result\&. New results will still be cached, possibly overwriting any pre\-existing results\&.
639 .RE
640 .PP
641 \fBrun_second_cpp\fR (\fBCCACHE_CPP2\fR or \fBCCACHE_NOCPP2\fR, see Boolean values above)
642 .RS 4
643 If true, ccache will first run the preprocessor to preprocess the source code (see
644 THE PREPROCESSOR MODE) and then on a cache miss run the compiler on the source code to get hold of the object file\&. This is the default\&.
645 .sp
646 If false, ccache will first run preprocessor to preprocess the source code and then on a cache miss run the compiler on the
647 \fIpreprocessed source code\fR
648 instead of the original source code\&. This makes cache misses slightly faster since the source code only has to be preprocessed once\&. The downside is that some compilers won\(cqt produce the same result (for instance diagnostics warnings) when compiling preprocessed source code\&.
649 .sp
650 A solution to the above mentioned downside is to set
651 \fBrun_second_cpp\fR
652 to false and pass
653 \fB\-fdirectives\-only\fR
654 (for GCC) or
655 \fB\-frewrite\-includes\fR
656 (for Clang) to the compiler\&. This will cause the compiler to leave the macros and other preprocessor information, and only process the
657 \fB#include\fR
658 directives\&. When run in this way, the preprocessor arguments will be passed to the compiler since it still has to do
659 \fIsome\fR
660 preprocessing (like macros)\&.
661 .RE
662 .PP
663 \fBsloppiness\fR (\fBCCACHE_SLOPPINESS\fR)
664 .RS 4
665 By default, ccache tries to give as few false cache hits as possible\&. However, in certain situations it\(cqs possible that you know things that ccache can\(cqt take for granted\&. This setting makes it possible to tell ccache to relax some checks in order to increase the hit rate\&. The value should be a comma\-separated string with options\&. Available options are:
666 .PP
667 \fBfile_macro\fR
668 .RS 4
669 Ignore
670 \fB__FILE__\fR
671 being present in the source\&.
672 .RE
673 .PP
674 \fBfile_stat_matches\fR
675 .RS 4
676 ccache normally examines a file\(cqs contents to determine whether it matches the cached version\&. With this option set, ccache will consider a file as matching its cached version if the mtimes and ctimes match\&.
677 .RE
678 .PP
679 \fBfile_stat_matches_ctime\fR
680 .RS 4
681 Ignore ctimes when
682 \fBfile_stat_matches\fR
683 is enabled\&. This can be useful when backdating files\*(Aq mtimes in a controlled way\&.
684 .RE
685 .PP
686 \fBinclude_file_ctime\fR
687 .RS 4
688 By default, ccache also will not cache a file if it includes a header whose ctime is too new\&. This option disables that check\&.
689 .RE
690 .PP
691 \fBinclude_file_mtime\fR
692 .RS 4
693 By default, ccache will not cache a file if it includes a header whose mtime is too new\&. This option disables that check\&.
694 .RE
695 .PP
696 \fBno_system_headers\fR
697 .RS 4
698 By default, ccache will also include all system headers in the manifest\&. With this option set, ccache will only include system headers in the hash but not add the system header files to the list of include files\&.
699 .RE
700 .PP
701 \fBpch_defines\fR
702 .RS 4
703 Be sloppy about
704 \fB#define\fRs when precompiling a header file\&. See
705 PRECOMPILED HEADERS
706 for more information\&.
707 .RE
708 .PP
709 \fBtime_macros\fR
710 .RS 4
711 Ignore
712 \fB__DATE__\fR
713 and
714 \fB__TIME__\fR
715 being present in the source code\&.
716 .RE
717 .sp
718 See the discussion under
719 TROUBLESHOOTING
720 for more information\&.
721 .RE
722 .PP
723 \fBstats\fR (\fBCCACHE_STATS\fR or \fBCCACHE_NOSTATS\fR, see Boolean values above)
724 .RS 4
725 If true, ccache will update the statistics counters on each compilation\&. The default is true\&.
726 .RE
727 .PP
728 \fBtemporary_dir\fR (\fBCCACHE_TEMPDIR\fR)
729 .RS 4
730 This setting specifies where ccache will put temporary files\&. The default is
731 \fB<cache_dir>/tmp\fR\&.
732 .if n \{\
733 .sp
734 .\}
735 .RS 4
736 .it 1 an-trap
737 .nr an-no-space-flag 1
738 .nr an-break-flag 1
739 .br
740 .ps +1
741 \fBNote\fR
742 .ps -1
743 .br
744 In previous versions of ccache,
745 \fBCCACHE_TEMPDIR\fR
746 had to be on the same filesystem as the
747 \fBCCACHE_DIR\fR
748 path, but this requirement has been relaxed\&.)
749 .sp .5v
750 .RE
751 .RE
752 .PP
753 \fBumask\fR (\fBCCACHE_UMASK\fR)
754 .RS 4
755 This setting specifies the umask for ccache and all child processes (such as the compiler)\&. This is mostly useful when you wish to share your cache with other users\&. Note that this also affects the file permissions set on the object files created from your compilations\&.
756 .RE
757 .PP
758 \fBunify\fR (\fBCCACHE_UNIFY\fR or \fBCCACHE_NOUNIFY\fR, see Boolean values above)
759 .RS 4
760 If true, ccache will use a C/C++ unifier when hashing the preprocessor output if the
761 \fB\-g\fR
762 option is not used\&. The unifier is slower than a normal hash, so setting this environment variable loses a little bit of speed, but it means that ccache can take advantage of not recompiling when the changes to the source code consist of reformatting only\&. Note that enabling the unifier changes the hash, so cached compilations produced when the unifier is enabled cannot be reused when the unifier is disabled, and vice versa\&. Enabling the unifier may result in incorrect line number information in compiler warning messages and expansions of the
763 \fB__LINE__\fR
764 macro\&.
765 .RE
766 .SH "CACHE SIZE MANAGEMENT"
767 .sp
768 By default, ccache has a 5 GB limit on the total size of files in the cache and no limit on the number of files\&. You can set different limits using the \fB\-M\fR/\fB\-\-max\-size\fR and \fB\-F\fR/\fB\-\-max\-files\fR options\&. Use \fBccache \-s/\-\-show\-stats\fR to see the cache size and the currently configured limits (in addition to other various statistics)\&.
769 .sp
770 Cleanup can be triggered in two different ways: automatic and manual\&.
771 .SS "Automatic cleanup"
772 .sp
773 ccache maintains counters for various statistics about the cache, including the size and number of all cached files\&. In order to improve performance and reduce issues with concurrent ccache invocations, there is one statistics file for each of the sixteen subdirectories in the cache\&.
774 .sp
775 After a new compilation result has been written to the cache, ccache will update the size and file number statistics for the subdirectory (one of sixteen) to which the result was written\&. Then, if the size counter for said subdirectory is greater than \fBmax_size / 16\fR or the file number counter is greater than \fBmax_files / 16\fR, automatic cleanup is triggered\&.
776 .sp
777 When automatic cleanup is triggered for a subdirectory in the cache, ccache will:
778 .sp
779 .RS 4
780 .ie n \{\
781 \h'-04' 1.\h'+01'\c
782 .\}
783 .el \{\
784 .sp -1
785 .IP "  1." 4.2
786 .\}
787 Count all files in the subdirectory and compute their aggregated size\&.
788 .RE
789 .sp
790 .RS 4
791 .ie n \{\
792 \h'-04' 2.\h'+01'\c
793 .\}
794 .el \{\
795 .sp -1
796 .IP "  2." 4.2
797 .\}
798 Remove files in LRU (least recently used) order until the size is at most
799 \fBlimit_multiple * max_size / 16\fR
800 and the number of files is at most
801 \fBlimit_multiple * max_files / 16\fR, where
802 \fBlimit_multiple\fR,
803 \fBmax_size\fR
804 and
805 \fBmax_files\fR
806 are configuration settings\&.
807 .RE
808 .sp
809 .RS 4
810 .ie n \{\
811 \h'-04' 3.\h'+01'\c
812 .\}
813 .el \{\
814 .sp -1
815 .IP "  3." 4.2
816 .\}
817 Set the size and file number counters to match the files that were kept\&.
818 .RE
819 .sp
820 The reason for removing more files than just those needed to not exceed the max limits is that a cleanup is a fairly slow operation, so it would not be a good idea to trigger it often, like after each cache miss\&.
821 .SS "Manual cleanup"
822 .sp
823 You can run \fBccache \-c/\-\-cleanup\fR to force cleanup of the whole cache, i\&.e\&. all of the sixteen subdirectories\&. This will recalculate the statistics counters and make sure that the \fBmax_size\fR and \fBmax_files\fR settings are not exceeded\&. Note that \fBlimit_multiple\fR is not taken into account for manual cleanup\&.
824 .SH "CACHE COMPRESSION"
825 .sp
826 ccache can optionally compress all files it puts into the cache using the compression library zlib\&. While this may involve a tiny performance slowdown, it increases the number of files that fit in the cache\&. You can turn on compression with the \fBcompression\fR configuration setting and you can also tweak the compression level with \fBcompression_level\fR\&.
827 .SH "CACHE STATISTICS"
828 .sp
829 \fBccache \-s/\-\-show\-stats\fR can show the following statistics:
830 .TS
831 allbox tab(:);
832 ltB ltB.
833 T{
834 Name
835 T}:T{
836 Description
837 T}
838 .T&
839 lt lt
840 lt lt
841 lt lt
842 lt lt
843 lt lt
844 lt lt
845 lt lt
846 lt lt
847 lt lt
848 lt lt
849 lt lt
850 lt lt
851 lt lt
852 lt lt
853 lt lt
854 lt lt
855 lt lt
856 lt lt
857 lt lt
858 lt lt
859 lt lt
860 lt lt
861 lt lt
862 lt lt
863 lt lt
864 lt lt
865 lt lt
866 lt lt
867 lt lt
868 lt lt.
869 T{
870 .sp
871 autoconf compile/link
872 T}:T{
873 .sp
874 Uncachable compilation or linking by an autoconf test\&.
875 T}
876 T{
877 .sp
878 bad compiler arguments
879 T}:T{
880 .sp
881 Malformed compiler argument, e\&.g\&. missing a value for an option that requires an argument or failure to read a file specified by an option argument\&.
882 T}
883 T{
884 .sp
885 cache file missing
886 T}:T{
887 .sp
888 A file was unexpectedly missing from the cache\&. This only happens in rare situations, e\&.g\&. if one ccache instance is about to get a file from the cache while another instance removed the file as part of cache cleanup\&.
889 T}
890 T{
891 .sp
892 cache hit (direct)
893 T}:T{
894 .sp
895 A result was successfully found using the direct mode\&.
896 T}
897 T{
898 .sp
899 cache hit (preprocessed)
900 T}:T{
901 .sp
902 A result was successfully found using the preprocessor mode\&.
903 T}
904 T{
905 .sp
906 cache miss
907 T}:T{
908 .sp
909 No result was found\&.
910 T}
911 T{
912 .sp
913 cache size
914 T}:T{
915 .sp
916 Current size of the cache\&.
917 T}
918 T{
919 .sp
920 called for link
921 T}:T{
922 .sp
923 The compiler was called for linking, not compiling\&.
924 T}
925 T{
926 .sp
927 called for preprocessing
928 T}:T{
929 .sp
930 The compiler was called for preprocessing, not compiling\&.
931 T}
932 T{
933 .sp
934 can\(cqt use precompiled header
935 T}:T{
936 .sp
937 Preconditions for using precompiled headers were not fulfilled\&.
938 T}
939 T{
940 .sp
941 ccache internal error
942 T}:T{
943 .sp
944 Unexpected failure, e\&.g\&. due to problems reading/writing the cache\&.
945 T}
946 T{
947 .sp
948 cleanups performed
949 T}:T{
950 .sp
951 Number of cleanups performed, either implicitly due to the cache size limit being reached or due to explicit \fBccache \-c/\-\-cleanup\fR calls\&.
952 T}
953 T{
954 .sp
955 compile failed
956 T}:T{
957 .sp
958 The compilation failed\&. No result stored in the cache\&.
959 T}
960 T{
961 .sp
962 compiler check failed
963 T}:T{
964 .sp
965 A compiler check program specified by \fBcompiler_check\fR (\fBCCACHE_COMPILERCHECK\fR) failed\&.
966 T}
967 T{
968 .sp
969 compiler produced empty output
970 T}:T{
971 .sp
972 The compiler\(cqs output file (typically an object file) was empty after compilation\&.
973 T}
974 T{
975 .sp
976 compiler produced no output
977 T}:T{
978 .sp
979 The compiler\(cqs output file (typically an object file) was missing after compilation\&.
980 T}
981 T{
982 .sp
983 compiler produced stdout
984 T}:T{
985 .sp
986 The compiler wrote data to standard output\&. This is something that compilers normally never do, so ccache is not designed to store such output in the cache\&.
987 T}
988 T{
989 .sp
990 couldn\(cqt find the compiler
991 T}:T{
992 .sp
993 The compiler to execute could not be found\&.
994 T}
995 T{
996 .sp
997 error hashing extra file
998 T}:T{
999 .sp
1000 Failure reading a file specified by \fBextra_files_to_hash\fR (\fBCCACHE_EXTRAFILES\fR)\&.
1001 T}
1002 T{
1003 .sp
1004 files in cache
1005 T}:T{
1006 .sp
1007 Current number of files in the cache\&.
1008 T}
1009 T{
1010 .sp
1011 multiple source files
1012 T}:T{
1013 .sp
1014 The compiler was called to compile multiple source files in one go\&. This is not supported by ccache\&.
1015 T}
1016 T{
1017 .sp
1018 no input file
1019 T}:T{
1020 .sp
1021 No input file was specified to the compiler\&.
1022 T}
1023 T{
1024 .sp
1025 output to a non\-regular file
1026 T}:T{
1027 .sp
1028 The output path specified with \fB\-o\fR is not a file (e\&.g\&. a directory or a device node)\&.
1029 T}
1030 T{
1031 .sp
1032 output to stdout
1033 T}:T{
1034 .sp
1035 The compiler was instructed to write its output to standard output using \fB\-o \-\fR\&. This is not supported by ccache\&.
1036 T}
1037 T{
1038 .sp
1039 preprocessor error
1040 T}:T{
1041 .sp
1042 Preprocessing the source code using the compiler\(cqs \fB\-E\fR option failed\&.
1043 T}
1044 T{
1045 .sp
1046 stats updated
1047 T}:T{
1048 .sp
1049 When statistics were updated the last time\&.
1050 T}
1051 T{
1052 .sp
1053 stats zeroed
1054 T}:T{
1055 .sp
1056 When \fBccache \-z\fR was called the last time\&.
1057 T}
1058 T{
1059 .sp
1060 unsupported code directive
1061 T}:T{
1062 .sp
1063 Code like the assembler \fB\&.incbin\fR directive was found\&. This is not supported by ccache\&.
1064 T}
1065 T{
1066 .sp
1067 unsupported compiler option
1068 T}:T{
1069 .sp
1070 A compiler option not supported by ccache was found\&.
1071 T}
1072 T{
1073 .sp
1074 unsupported source language
1075 T}:T{
1076 .sp
1077 A source language e\&.g\&. specified with \fB\-x\fR was unsupported by ccache\&.
1078 T}
1079 .TE
1080 .sp 1
1081 .SH "HOW CCACHE WORKS"
1082 .sp
1083 The basic idea is to detect when you are compiling exactly the same code a second time and reuse the previously produced output\&. The detection is done by hashing different kinds of information that should be unique for the compilation and then using the hash sum to identify the cached output\&. ccache uses MD4, a very fast cryptographic hash algorithm, for the hashing\&. (MD4 is nowadays too weak to be useful in cryptographic contexts, but it should be safe enough to be used to identify recompilations\&.) On a cache hit, ccache is able to supply all of the correct compiler outputs (including all warnings, dependency file, etc) from the cache\&.
1084 .sp
1085 ccache has two ways of doing the detection:
1086 .sp
1087 .RS 4
1088 .ie n \{\
1089 \h'-04'\(bu\h'+03'\c
1090 .\}
1091 .el \{\
1092 .sp -1
1093 .IP \(bu 2.3
1094 .\}
1095 the
1096 \fBdirect mode\fR, where ccache hashes the source code and include files directly
1097 .RE
1098 .sp
1099 .RS 4
1100 .ie n \{\
1101 \h'-04'\(bu\h'+03'\c
1102 .\}
1103 .el \{\
1104 .sp -1
1105 .IP \(bu 2.3
1106 .\}
1107 the
1108 \fBpreprocessor mode\fR, where ccache runs the preprocessor on the source code and hashes the result
1109 .RE
1110 .sp
1111 The direct mode is generally faster since running the preprocessor has some overhead\&.
1112 .SS "Common hashed information"
1113 .sp
1114 For both modes, the following information is included in the hash:
1115 .sp
1116 .RS 4
1117 .ie n \{\
1118 \h'-04'\(bu\h'+03'\c
1119 .\}
1120 .el \{\
1121 .sp -1
1122 .IP \(bu 2.3
1123 .\}
1124 the extension used by the compiler for a file with preprocessor output (normally
1125 \fB\&.i\fR
1126 for C code and
1127 \fB\&.ii\fR
1128 for C++ code)
1129 .RE
1130 .sp
1131 .RS 4
1132 .ie n \{\
1133 \h'-04'\(bu\h'+03'\c
1134 .\}
1135 .el \{\
1136 .sp -1
1137 .IP \(bu 2.3
1138 .\}
1139 the compiler\(cqs size and modification time (or other compiler\-specific information specified by the
1140 \fBcompiler_check\fR
1141 setting)
1142 .RE
1143 .sp
1144 .RS 4
1145 .ie n \{\
1146 \h'-04'\(bu\h'+03'\c
1147 .\}
1148 .el \{\
1149 .sp -1
1150 .IP \(bu 2.3
1151 .\}
1152 the name of the compiler
1153 .RE
1154 .sp
1155 .RS 4
1156 .ie n \{\
1157 \h'-04'\(bu\h'+03'\c
1158 .\}
1159 .el \{\
1160 .sp -1
1161 .IP \(bu 2.3
1162 .\}
1163 the current directory (if the
1164 \fBhash_dir\fR
1165 setting is enabled)
1166 .RE
1167 .sp
1168 .RS 4
1169 .ie n \{\
1170 \h'-04'\(bu\h'+03'\c
1171 .\}
1172 .el \{\
1173 .sp -1
1174 .IP \(bu 2.3
1175 .\}
1176 contents of files specified by the
1177 \fBextra_files_to_hash\fR
1178 setting (if any)
1179 .RE
1180 .SS "The direct mode"
1181 .sp
1182 In the direct mode, the hash is formed of the common information and:
1183 .sp
1184 .RS 4
1185 .ie n \{\
1186 \h'-04'\(bu\h'+03'\c
1187 .\}
1188 .el \{\
1189 .sp -1
1190 .IP \(bu 2.3
1191 .\}
1192 the input source file
1193 .RE
1194 .sp
1195 .RS 4
1196 .ie n \{\
1197 \h'-04'\(bu\h'+03'\c
1198 .\}
1199 .el \{\
1200 .sp -1
1201 .IP \(bu 2.3
1202 .\}
1203 the command line options
1204 .RE
1205 .sp
1206 Based on the hash, a data structure called \(lqmanifest\(rq is looked up in the cache\&. The manifest contains:
1207 .sp
1208 .RS 4
1209 .ie n \{\
1210 \h'-04'\(bu\h'+03'\c
1211 .\}
1212 .el \{\
1213 .sp -1
1214 .IP \(bu 2.3
1215 .\}
1216 references to cached compilation results (object file, dependency file, etc) that were produced by previous compilations that matched the hash
1217 .RE
1218 .sp
1219 .RS 4
1220 .ie n \{\
1221 \h'-04'\(bu\h'+03'\c
1222 .\}
1223 .el \{\
1224 .sp -1
1225 .IP \(bu 2.3
1226 .\}
1227 paths to the include files that were read at the time the compilation results were stored in the cache
1228 .RE
1229 .sp
1230 .RS 4
1231 .ie n \{\
1232 \h'-04'\(bu\h'+03'\c
1233 .\}
1234 .el \{\
1235 .sp -1
1236 .IP \(bu 2.3
1237 .\}
1238 hash sums of the include files at the time the compilation results were stored in the cache
1239 .RE
1240 .sp
1241 The current contents of the include files are then hashed and compared to the information in the manifest\&. If there is a match, ccache knows the result of the compilation\&. If there is no match, ccache falls back to running the preprocessor\&. The output from the preprocessor is parsed to find the include files that were read\&. The paths and hash sums of those include files are then stored in the manifest along with information about the produced compilation result\&.
1242 .sp
1243 There is a catch with the direct mode: header files that were used by the compiler are recorded, but header files that were \fBnot\fR used, but would have been used if they existed, are not\&. So, when ccache checks if a result can be taken from the cache, it currently can\(cqt check if the existence of a new header file should invalidate the result\&. In practice, the direct mode is safe to use in the absolute majority of cases\&.
1244 .sp
1245 The direct mode will be disabled if any of the following holds:
1246 .sp
1247 .RS 4
1248 .ie n \{\
1249 \h'-04'\(bu\h'+03'\c
1250 .\}
1251 .el \{\
1252 .sp -1
1253 .IP \(bu 2.3
1254 .\}
1255 the configuration setting
1256 \fBdirect_mode\fR
1257 is false
1258 .RE
1259 .sp
1260 .RS 4
1261 .ie n \{\
1262 \h'-04'\(bu\h'+03'\c
1263 .\}
1264 .el \{\
1265 .sp -1
1266 .IP \(bu 2.3
1267 .\}
1268 a modification time of one of the include files is too new (needed to avoid a race condition)
1269 .RE
1270 .sp
1271 .RS 4
1272 .ie n \{\
1273 \h'-04'\(bu\h'+03'\c
1274 .\}
1275 .el \{\
1276 .sp -1
1277 .IP \(bu 2.3
1278 .\}
1279 a compiler option not supported by the direct mode is used:
1280 .sp
1281 .RS 4
1282 .ie n \{\
1283 \h'-04'\(bu\h'+03'\c
1284 .\}
1285 .el \{\
1286 .sp -1
1287 .IP \(bu 2.3
1288 .\}
1289 a
1290 \fB\-Wp,\fR\fB\fIX\fR\fR
1291 compiler option other than
1292 \fB\-Wp,\-MD,\fR\fB\fIpath\fR\fR,
1293 \fB\-Wp,\-MMD,\fR\fB\fIpath\fR\fR
1294 and
1295 \fB\-Wp,\-D_define_\fR
1296 .RE
1297 .sp
1298 .RS 4
1299 .ie n \{\
1300 \h'-04'\(bu\h'+03'\c
1301 .\}
1302 .el \{\
1303 .sp -1
1304 .IP \(bu 2.3
1305 .\}
1306 \fB\-Xpreprocessor\fR
1307 .RE
1308 .RE
1309 .sp
1310 .RS 4
1311 .ie n \{\
1312 \h'-04'\(bu\h'+03'\c
1313 .\}
1314 .el \{\
1315 .sp -1
1316 .IP \(bu 2.3
1317 .\}
1318 the string
1319 \fB__TIME__\fR
1320 is present in the source code
1321 .RE
1322 .SS "The preprocessor mode"
1323 .sp
1324 In the preprocessor mode, the hash is formed of the common information and:
1325 .sp
1326 .RS 4
1327 .ie n \{\
1328 \h'-04'\(bu\h'+03'\c
1329 .\}
1330 .el \{\
1331 .sp -1
1332 .IP \(bu 2.3
1333 .\}
1334 the preprocessor output from running the compiler with
1335 \fB\-E\fR
1336 .RE
1337 .sp
1338 .RS 4
1339 .ie n \{\
1340 \h'-04'\(bu\h'+03'\c
1341 .\}
1342 .el \{\
1343 .sp -1
1344 .IP \(bu 2.3
1345 .\}
1346 the command line options except options that affect include files (\fB\-I\fR,
1347 \fB\-include\fR,
1348 \fB\-D\fR, etc; the theory is that these options will change the preprocessor output if they have any effect at all)
1349 .RE
1350 .sp
1351 .RS 4
1352 .ie n \{\
1353 \h'-04'\(bu\h'+03'\c
1354 .\}
1355 .el \{\
1356 .sp -1
1357 .IP \(bu 2.3
1358 .\}
1359 any standard error output generated by the preprocessor
1360 .RE
1361 .sp
1362 Based on the hash, the cached compilation result can be looked up directly in the cache\&.
1363 .SH "CACHE DEBUGGING"
1364 .sp
1365 To find out what information ccache actually is hashing, you can enable the debug mode via the configuration setting \fBdebug\fR or by setting \fBCCACHE_DEBUG\fR in the environment\&. This can be useful if you are investigating why you don\(cqt get cache hits\&. Note that performance will be reduced slightly\&.
1366 .sp
1367 When the debug mode is enabled, ccache will create up to five additional files next to the object file:
1368 .TS
1369 allbox tab(:);
1370 ltB ltB.
1371 T{
1372 Filename
1373 T}:T{
1374 Description
1375 T}
1376 .T&
1377 lt lt
1378 lt lt
1379 lt lt
1380 lt lt
1381 lt lt.
1382 T{
1383 .sp
1384 \fB<objectfile>\&.ccache\-input\-c\fR
1385 T}:T{
1386 .sp
1387 Binary input hashed by both the direct mode and the preprocessor mode\&.
1388 T}
1389 T{
1390 .sp
1391 \fB<objectfile>\&.ccache\-input\-d\fR
1392 T}:T{
1393 .sp
1394 Binary input only hashed by the direct mode\&.
1395 T}
1396 T{
1397 .sp
1398 \fB<objectfile>\&.ccache\-input\-p\fR
1399 T}:T{
1400 .sp
1401 Binary input only hashed by the preprocessor mode\&.
1402 T}
1403 T{
1404 .sp
1405 \fB<objectfile>\&.ccache\-input\-text\fR
1406 T}:T{
1407 .sp
1408 Human\-readable combined diffable text version of the three files above\&.
1409 T}
1410 T{
1411 .sp
1412 \fB<objectfile>\&.ccache\-log\fR
1413 T}:T{
1414 .sp
1415 Log for this object file\&.
1416 T}
1417 .TE
1418 .sp 1
1419 .sp
1420 In the direct mode, ccache uses the MD4 hash of the \fBccache\-input\-c\fR + \fBccache\-input\-d\fR data (where \fB+\fR means concatenation), while the \fBccache\-input\-c\fR + \fBccache\-input\-p\fR data is used in the preprocessor mode\&.
1421 .sp
1422 The \fBccache\-input\-text\fR file is a combined text version of the three binary input files\&. It has three sections (\(lqCOMMON\(rq, \(lqDIRECT MODE\(rq and \(lqPREPROCESSOR MODE\(rq), which is turn contain annotations that say what kind of data comes next\&.
1423 .sp
1424 To debug why you don\(cqt get an expected cache hit for an object file, you can do something like this:
1425 .sp
1426 .RS 4
1427 .ie n \{\
1428 \h'-04' 1.\h'+01'\c
1429 .\}
1430 .el \{\
1431 .sp -1
1432 .IP "  1." 4.2
1433 .\}
1434 Build with debug mode enabled\&.
1435 .RE
1436 .sp
1437 .RS 4
1438 .ie n \{\
1439 \h'-04' 2.\h'+01'\c
1440 .\}
1441 .el \{\
1442 .sp -1
1443 .IP "  2." 4.2
1444 .\}
1445 Save the
1446 \fB<objectfile>\&.ccache\-*\fR
1447 files\&.
1448 .RE
1449 .sp
1450 .RS 4
1451 .ie n \{\
1452 \h'-04' 3.\h'+01'\c
1453 .\}
1454 .el \{\
1455 .sp -1
1456 .IP "  3." 4.2
1457 .\}
1458 Build again with debug mode enabled\&.
1459 .RE
1460 .sp
1461 .RS 4
1462 .ie n \{\
1463 \h'-04' 4.\h'+01'\c
1464 .\}
1465 .el \{\
1466 .sp -1
1467 .IP "  4." 4.2
1468 .\}
1469 Compare
1470 \fB<objectfile>\&.ccache\-input\-text\fR
1471 for the two builds\&. This together with the
1472 \fB<objectfile>\&.ccache\-log\fR
1473 files should give you some clues about what is happening\&.
1474 .RE
1475 .SH "COMPILING IN DIFFERENT DIRECTORIES"
1476 .sp
1477 Some information included in the hash that identifies a unique compilation can contain absolute paths:
1478 .sp
1479 .RS 4
1480 .ie n \{\
1481 \h'-04'\(bu\h'+03'\c
1482 .\}
1483 .el \{\
1484 .sp -1
1485 .IP \(bu 2.3
1486 .\}
1487 The preprocessed source code may contain absolute paths to include files if the compiler option
1488 \fB\-g\fR
1489 is used or if absolute paths are given to
1490 \fB\-I\fR
1491 and similar compiler options\&.
1492 .RE
1493 .sp
1494 .RS 4
1495 .ie n \{\
1496 \h'-04'\(bu\h'+03'\c
1497 .\}
1498 .el \{\
1499 .sp -1
1500 .IP \(bu 2.3
1501 .\}
1502 Paths specified by compiler options (such as
1503 \fB\-I\fR,
1504 \fB\-MF\fR, etc) on the command line may be absolute\&.
1505 .RE
1506 .sp
1507 .RS 4
1508 .ie n \{\
1509 \h'-04'\(bu\h'+03'\c
1510 .\}
1511 .el \{\
1512 .sp -1
1513 .IP \(bu 2.3
1514 .\}
1515 The source code file path may be absolute, and that path may substituted for
1516 \fB__FILE__\fR
1517 macros in the source code or included in warnings emitted to standard error by the preprocessor\&.
1518 .RE
1519 .sp
1520 This means that if you compile the same code in different locations, you can\(cqt share compilation results between the different build directories since you get cache misses because of the absolute build directory paths that are part of the hash\&.
1521 .sp
1522 Here\(cqs what can be done to enable cache hits between different build directories:
1523 .sp
1524 .RS 4
1525 .ie n \{\
1526 \h'-04'\(bu\h'+03'\c
1527 .\}
1528 .el \{\
1529 .sp -1
1530 .IP \(bu 2.3
1531 .\}
1532 If you build with
1533 \fB\-g\fR
1534 (or similar) to add debug information to the object file, you must either:
1535 .sp
1536 .RS 4
1537 .ie n \{\
1538 \h'-04'\(bu\h'+03'\c
1539 .\}
1540 .el \{\
1541 .sp -1
1542 .IP \(bu 2.3
1543 .\}
1544 use the
1545 \fB\-fdebug\-prefix\-map=\fR\fB\fIold\fR\fR\fB=\fR\fB\fInew\fR\fR
1546 option for relocating debug info to a common prefix (e\&.g\&.
1547 \fB\-fdebug\-prefix\-map=$PWD=\&.\fR); or
1548 .RE
1549 .sp
1550 .RS 4
1551 .ie n \{\
1552 \h'-04'\(bu\h'+03'\c
1553 .\}
1554 .el \{\
1555 .sp -1
1556 .IP \(bu 2.3
1557 .\}
1558 set
1559 \fBhash_dir = false\fR\&.
1560 .RE
1561 .RE
1562 .sp
1563 .RS 4
1564 .ie n \{\
1565 \h'-04'\(bu\h'+03'\c
1566 .\}
1567 .el \{\
1568 .sp -1
1569 .IP \(bu 2.3
1570 .\}
1571 If you use absolute paths anywhere on the command line (e\&.g\&. the source code file path or an argument to compiler options like
1572 \fB\-I\fR
1573 and
1574 \fB\-MF\fR), you must to set
1575 \fBbase_dir\fR
1576 to an absolute path to a \(lqbase directory\(rq\&. ccache will then rewrite absolute paths under that directory to relative before computing the hash\&.
1577 .RE
1578 .SH "PRECOMPILED HEADERS"
1579 .sp
1580 ccache has support for GCC\(cqs precompiled headers\&. However, you have to do some things to make it work properly:
1581 .sp
1582 .RS 4
1583 .ie n \{\
1584 \h'-04'\(bu\h'+03'\c
1585 .\}
1586 .el \{\
1587 .sp -1
1588 .IP \(bu 2.3
1589 .\}
1590 You must set
1591 \fBsloppiness\fR
1592 to
1593 \fBpch_defines,time_macros\fR\&. The reason is that ccache can\(cqt tell whether
1594 \fB__TIME__\fR
1595 or
1596 \fB__DATE__\fR
1597 is used when using a precompiled header\&. Further, it can\(cqt detect changes in
1598 \fB#define\fRs in the source code because of how preprocessing works in combination with precompiled headers\&.
1599 .RE
1600 .sp
1601 .RS 4
1602 .ie n \{\
1603 \h'-04'\(bu\h'+03'\c
1604 .\}
1605 .el \{\
1606 .sp -1
1607 .IP \(bu 2.3
1608 .\}
1609 You must either:
1610 .sp
1611 .RS 4
1612 .ie n \{\
1613 \h'-04'\(bu\h'+03'\c
1614 .\}
1615 .el \{\
1616 .sp -1
1617 .IP \(bu 2.3
1618 .\}
1619 use the
1620 \fB\-include\fR
1621 compiler option to include the precompiled header (i\&.e\&., don\(cqt use
1622 \fB#include\fR
1623 in the source code to include the header); or
1624 .RE
1625 .sp
1626 .RS 4
1627 .ie n \{\
1628 \h'-04'\(bu\h'+03'\c
1629 .\}
1630 .el \{\
1631 .sp -1
1632 .IP \(bu 2.3
1633 .\}
1634 (for the Clang compiler) use the
1635 \fB\-include\-pch\fR
1636 compiler option to include the PCH file generated from the precompiled header; or
1637 .RE
1638 .sp
1639 .RS 4
1640 .ie n \{\
1641 \h'-04'\(bu\h'+03'\c
1642 .\}
1643 .el \{\
1644 .sp -1
1645 .IP \(bu 2.3
1646 .\}
1647 add the
1648 \fB\-fpch\-preprocess\fR
1649 compiler option when compiling\&.
1650 .RE
1651 .sp
1652 If you don\(cqt do this, either the non\-precompiled version of the header file will be used (if available) or ccache will fall back to running the real compiler and increase the statistics counter \(lqpreprocessor error\(rq (if the non\-precompiled header file is not available)\&.
1653 .RE
1654 .SH "SHARING A CACHE"
1655 .sp
1656 A group of developers can increase the cache hit rate by sharing a cache directory\&. To share a cache without unpleasant side effects, the following conditions should to be met:
1657 .sp
1658 .RS 4
1659 .ie n \{\
1660 \h'-04'\(bu\h'+03'\c
1661 .\}
1662 .el \{\
1663 .sp -1
1664 .IP \(bu 2.3
1665 .\}
1666 Use the same cache directory\&.
1667 .RE
1668 .sp
1669 .RS 4
1670 .ie n \{\
1671 \h'-04'\(bu\h'+03'\c
1672 .\}
1673 .el \{\
1674 .sp -1
1675 .IP \(bu 2.3
1676 .\}
1677 Make sure that the configuration setting
1678 \fBhard_link\fR
1679 is false (which is the default)\&.
1680 .RE
1681 .sp
1682 .RS 4
1683 .ie n \{\
1684 \h'-04'\(bu\h'+03'\c
1685 .\}
1686 .el \{\
1687 .sp -1
1688 .IP \(bu 2.3
1689 .\}
1690 Make sure that all users are in the same group\&.
1691 .RE
1692 .sp
1693 .RS 4
1694 .ie n \{\
1695 \h'-04'\(bu\h'+03'\c
1696 .\}
1697 .el \{\
1698 .sp -1
1699 .IP \(bu 2.3
1700 .\}
1701 Set the configuration setting
1702 \fBumask\fR
1703 to 002\&. This ensures that cached files are accessible to everyone in the group\&.
1704 .RE
1705 .sp
1706 .RS 4
1707 .ie n \{\
1708 \h'-04'\(bu\h'+03'\c
1709 .\}
1710 .el \{\
1711 .sp -1
1712 .IP \(bu 2.3
1713 .\}
1714 Make sure that all users have write permission in the entire cache directory (and that you trust all users of the shared cache)\&.
1715 .RE
1716 .sp
1717 .RS 4
1718 .ie n \{\
1719 \h'-04'\(bu\h'+03'\c
1720 .\}
1721 .el \{\
1722 .sp -1
1723 .IP \(bu 2.3
1724 .\}
1725 Make sure that the setgid bit is set on all directories in the cache\&. This tells the filesystem to inherit group ownership for new directories\&. The following command might be useful for this:
1726 .sp
1727 .if n \{\
1728 .RS 4
1729 .\}
1730 .nf
1731 find $CCACHE_DIR \-type d | xargs chmod g+s
1732 .fi
1733 .if n \{\
1734 .RE
1735 .\}
1736 .RE
1737 .sp
1738 The reason to avoid the hard link mode is that the hard links cause unwanted side effects, as all links to a cached file share the file\(cqs modification timestamp\&. This results in false dependencies to be triggered by timestamp\-based build systems whenever another user links to an existing file\&. Typically, users will see that their libraries and binaries are relinked without reason\&.
1739 .sp
1740 You may also want to make sure that a base directory is set appropriately, as discussed in a previous section\&.
1741 .SH "SHARING A CACHE ON NFS"
1742 .sp
1743 It is possible to put the cache directory on an NFS filesystem (or similar filesystems), but keep in mind that:
1744 .sp
1745 .RS 4
1746 .ie n \{\
1747 \h'-04'\(bu\h'+03'\c
1748 .\}
1749 .el \{\
1750 .sp -1
1751 .IP \(bu 2.3
1752 .\}
1753 Having the cache on NFS may slow down compilation\&. Make sure to do some benchmarking to see if it\(cqs worth it\&.
1754 .RE
1755 .sp
1756 .RS 4
1757 .ie n \{\
1758 \h'-04'\(bu\h'+03'\c
1759 .\}
1760 .el \{\
1761 .sp -1
1762 .IP \(bu 2.3
1763 .\}
1764 ccache hasn\(cqt been tested very thoroughly on NFS\&.
1765 .RE
1766 .sp
1767 A tip is to set \fBtemporary_dir\fR to a directory on the local host to avoid NFS traffic for temporary files\&.
1768 .SH "USING CCACHE WITH OTHER COMPILER WRAPPERS"
1769 .sp
1770 The recommended way of combining ccache with another compiler wrapper (such as \(lqdistcc\(rq) is by letting ccache execute the compiler wrapper\&. This is accomplished by defining the configuration setting \fBprefix_command\fR, for example by setting the environment variable \fBCCACHE_PREFIX\fR to the name of the wrapper (e\&.g\&. \fBdistcc\fR)\&. ccache will then prefix the command line with the specified command when running the compiler\&. To specify several prefix commands, set \fBprefix_command\fR to a colon\-separated list of commands\&.
1771 .sp
1772 Unless you set \fBcompiler_check\fR to a suitable command (see the description of that configuration option), it is not recommended to use the form \fBccache anotherwrapper compiler args\fR as the compilation command\&. It\(cqs also not recommended to use the masquerading technique for the other compiler wrapper\&. The reason is that by default, ccache will in both cases hash the mtime and size of the other wrapper instead of the real compiler, which means that:
1773 .sp
1774 .RS 4
1775 .ie n \{\
1776 \h'-04'\(bu\h'+03'\c
1777 .\}
1778 .el \{\
1779 .sp -1
1780 .IP \(bu 2.3
1781 .\}
1782 Compiler upgrades will not be detected properly\&.
1783 .RE
1784 .sp
1785 .RS 4
1786 .ie n \{\
1787 \h'-04'\(bu\h'+03'\c
1788 .\}
1789 .el \{\
1790 .sp -1
1791 .IP \(bu 2.3
1792 .\}
1793 The cached results will not be shared between compilations with and without the other wrapper\&.
1794 .RE
1795 .sp
1796 Another minor thing is that if \fBprefix_command\fR is used, ccache will not invoke the other wrapper when running the preprocessor, which increases performance\&. You can use the \fBprefix_command_cpp\fR configuration setting if you also want to invoke the other wrapper when doing preprocessing (normally by adding \fB\-E\fR)\&.
1797 .SH "CAVEATS"
1798 .sp
1799 .RS 4
1800 .ie n \{\
1801 \h'-04'\(bu\h'+03'\c
1802 .\}
1803 .el \{\
1804 .sp -1
1805 .IP \(bu 2.3
1806 .\}
1807 The direct mode fails to pick up new header files in some rare scenarios\&. See
1808 THE DIRECT MODE
1809 above\&.
1810 .RE
1811 .sp
1812 .RS 4
1813 .ie n \{\
1814 \h'-04'\(bu\h'+03'\c
1815 .\}
1816 .el \{\
1817 .sp -1
1818 .IP \(bu 2.3
1819 .\}
1820 When run via ccache, warning messages produced by GCC 4\&.9 and newer will only be colored when the environment variable
1821 \fBGCC_COLORS\fR
1822 is set\&. An alternative to setting
1823 \fBGCC_COLORS\fR
1824 is to pass
1825 \fB\-fdiagnostics\-color\fR
1826 explicitly when compiling (but then color codes will also be present when redirecting stderr to a file)\&.
1827 .RE
1828 .sp
1829 .RS 4
1830 .ie n \{\
1831 \h'-04'\(bu\h'+03'\c
1832 .\}
1833 .el \{\
1834 .sp -1
1835 .IP \(bu 2.3
1836 .\}
1837 If ccache guesses that the compiler may emit colored warnings, then a compilation with stderr referring to a TTY will be considered different from a compilation with a redirected stderr, thus not sharing cache entries\&. This happens for clang by default and for GCC when
1838 \fBGCC_COLORS\fR
1839 is set as mentioned above\&. If you want to share cache hits, you can pass
1840 \fB\-f[no\-]diagnostics\-color\fR
1841 (GCC) or
1842 \fB\-f[no\-]color\-diagnostics\fR
1843 (clang) explicitly when compiling (but then color codes will be either on or off for both the TTY and the redirected case)\&.
1844 .RE
1845 .SH "TROUBLESHOOTING"
1846 .SS "General"
1847 .sp
1848 A general tip for getting information about what ccache is doing is to enable debug logging by setting \fBlog_file\fR\&. The log contains executed commands, important decisions that ccache makes, read and written files, etc\&. Another way of keeping track of what is happening is to check the output of \fBccache \-s\fR\&.
1849 .SS "Performance"
1850 .sp
1851 ccache has been written to perform well out of the box, but sometimes you may have to do some adjustments of how you use the compiler and ccache in order to improve performance\&.
1852 .sp
1853 Since ccache works best when I/O is fast, put the cache directory on a fast storage device if possible\&. Having lots of free memory so that files in the cache directory stay in the disk cache is also preferable\&.
1854 .sp
1855 A good way of monitoring how well ccache works is to run \fBccache \-s\fR before and after your build and then compare the statistics counters\&. Here are some common problems and what may be done to increase the hit rate:
1856 .sp
1857 .RS 4
1858 .ie n \{\
1859 \h'-04'\(bu\h'+03'\c
1860 .\}
1861 .el \{\
1862 .sp -1
1863 .IP \(bu 2.3
1864 .\}
1865 If \(lqcache hit (preprocessed)\(rq has been incremented instead of \(lqcache hit (direct)\(rq, ccache has fallen back to preprocessor mode, which is generally slower\&. Some possible reasons are:
1866 .sp
1867 .RS 4
1868 .ie n \{\
1869 \h'-04'\(bu\h'+03'\c
1870 .\}
1871 .el \{\
1872 .sp -1
1873 .IP \(bu 2.3
1874 .\}
1875 The source code has been modified in such a way that the preprocessor output is not affected\&.
1876 .RE
1877 .sp
1878 .RS 4
1879 .ie n \{\
1880 \h'-04'\(bu\h'+03'\c
1881 .\}
1882 .el \{\
1883 .sp -1
1884 .IP \(bu 2.3
1885 .\}
1886 Compiler arguments that are hashed in the direct mode but not in the preprocessor mode have changed (\fB\-I\fR,
1887 \fB\-include\fR,
1888 \fB\-D\fR, etc) and they didn\(cqt affect the preprocessor output\&.
1889 .RE
1890 .sp
1891 .RS 4
1892 .ie n \{\
1893 \h'-04'\(bu\h'+03'\c
1894 .\}
1895 .el \{\
1896 .sp -1
1897 .IP \(bu 2.3
1898 .\}
1899 The compiler option
1900 \fB\-Xpreprocessor\fR
1901 or
1902 \fB\-Wp,\fR\fB\fIX\fR\fR
1903 (except
1904 \fB\-Wp,\-MD,\fR\fB\fIpath\fR\fR,
1905 \fB\-Wp,\-MMD,\fR\fB\fIpath\fR\fR, and
1906 \fB\-Wp,\-D_define_\fR) is used\&.
1907 .RE
1908 .sp
1909 .RS 4
1910 .ie n \{\
1911 \h'-04'\(bu\h'+03'\c
1912 .\}
1913 .el \{\
1914 .sp -1
1915 .IP \(bu 2.3
1916 .\}
1917 This was the first compilation with a new value of the base directory setting\&.
1918 .RE
1919 .sp
1920 .RS 4
1921 .ie n \{\
1922 \h'-04'\(bu\h'+03'\c
1923 .\}
1924 .el \{\
1925 .sp -1
1926 .IP \(bu 2.3
1927 .\}
1928 A modification time of one of the include files is too new (created the same second as the compilation is being done)\&. This check is made to avoid a race condition\&. To fix this, create the include file earlier in the build process, if possible, or set
1929 \fBsloppiness\fR
1930 to
1931 \fBinclude_file_mtime\fR
1932 if you are willing to take the risk\&. (The race condition consists of these events: the preprocessor is run; an include file is modified by someone; the new include file is hashed by ccache; the real compiler is run on the preprocessor\(cqs output, which contains data from the old header file; the wrong object file is stored in the cache\&.)
1933 .RE
1934 .sp
1935 .RS 4
1936 .ie n \{\
1937 \h'-04'\(bu\h'+03'\c
1938 .\}
1939 .el \{\
1940 .sp -1
1941 .IP \(bu 2.3
1942 .\}
1943 The
1944 \fB__TIME__\fR
1945 preprocessor macro is (potentially) being used\&. ccache turns off direct mode if
1946 \fB__TIME__\fR
1947 is present in the source code\&. This is done as a safety measure since the string indicates that a
1948 \fB__TIME__\fR
1949 macro
1950 \fImay\fR
1951 affect the output\&. (To be sure, ccache would have to run the preprocessor, but the sole point of the direct mode is to avoid that\&.) If you know that
1952 \fB__TIME__\fR
1953 isn\(cqt used in practise, or don\(cqt care if ccache produces objects where
1954 \fB__TIME__\fR
1955 is expanded to something in the past, you can set
1956 \fBsloppiness\fR
1957 to
1958 \fBtime_macros\fR\&.
1959 .RE
1960 .sp
1961 .RS 4
1962 .ie n \{\
1963 \h'-04'\(bu\h'+03'\c
1964 .\}
1965 .el \{\
1966 .sp -1
1967 .IP \(bu 2.3
1968 .\}
1969 The
1970 \fB__DATE__\fR
1971 preprocessor macro is (potentially) being used and the date has changed\&. This is similar to how
1972 \fB__TIME__\fR
1973 is handled\&. If
1974 \fB__DATE__\fR
1975 is present in the source code, ccache hashes the current date in order to be able to produce the correct object file if the
1976 \fB__DATE__\fR
1977 macro affects the output\&. If you know that
1978 \fB__DATE__\fR
1979 isn\(cqt used in practise, or don\(cqt care if ccache produces objects where
1980 \fB__DATE__\fR
1981 is expanded to something in the past, you can set
1982 \fBsloppiness\fR
1983 to
1984 \fBtime_macros\fR\&.
1985 .RE
1986 .sp
1987 .RS 4
1988 .ie n \{\
1989 \h'-04'\(bu\h'+03'\c
1990 .\}
1991 .el \{\
1992 .sp -1
1993 .IP \(bu 2.3
1994 .\}
1995 The
1996 \fB__FILE__\fR
1997 preprocessor macro is (potentially) being used and the file path has changed\&. If
1998 \fB__FILE__\fR
1999 is present in the source code, ccache hashes the current input file path in order to be able to produce the correct object file if the
2000 \fB__FILE__\fR
2001 macro affects the output\&. If you know that
2002 \fB__FILE__\fR
2003 isn\(cqt used in practise, or don\(cqt care if ccache produces objects where
2004 \fB__FILE__\fR
2005 is expanded to the wrong path, you can set
2006 \fBsloppiness\fR
2007 to
2008 \fBfile_macro\fR\&.
2009 .RE
2010 .RE
2011 .sp
2012 .RS 4
2013 .ie n \{\
2014 \h'-04'\(bu\h'+03'\c
2015 .\}
2016 .el \{\
2017 .sp -1
2018 .IP \(bu 2.3
2019 .\}
2020 If \(lqcache miss\(rq has been incremented even though the same code has been compiled and cached before, ccache has either detected that something has changed anyway or a cleanup has been performed (either explicitly or implicitly when a cache limit has been reached)\&. Some perhaps unobvious things that may result in a cache miss are usage of
2021 \fB__TIME__\fR
2022 or
2023 \fB__DATE__\fR
2024 macros, or use of automatically generated code that contains a timestamp, build counter or other volatile information\&.
2025 .RE
2026 .sp
2027 .RS 4
2028 .ie n \{\
2029 \h'-04'\(bu\h'+03'\c
2030 .\}
2031 .el \{\
2032 .sp -1
2033 .IP \(bu 2.3
2034 .\}
2035 If \(lqmultiple source files\(rq has been incremented, it\(cqs an indication that the compiler has been invoked on several source code files at once\&. ccache doesn\(cqt support that\&. Compile the source code files separately if possible\&.
2036 .RE
2037 .sp
2038 .RS 4
2039 .ie n \{\
2040 \h'-04'\(bu\h'+03'\c
2041 .\}
2042 .el \{\
2043 .sp -1
2044 .IP \(bu 2.3
2045 .\}
2046 If \(lqunsupported compiler option\(rq has been incremented, enable debug logging and check which option was rejected\&.
2047 .RE
2048 .sp
2049 .RS 4
2050 .ie n \{\
2051 \h'-04'\(bu\h'+03'\c
2052 .\}
2053 .el \{\
2054 .sp -1
2055 .IP \(bu 2.3
2056 .\}
2057 If \(lqpreprocessor error\(rq has been incremented, one possible reason is that precompiled headers are being used\&. See
2058 PRECOMPILED HEADERS
2059 for how to remedy this\&.
2060 .RE
2061 .sp
2062 .RS 4
2063 .ie n \{\
2064 \h'-04'\(bu\h'+03'\c
2065 .\}
2066 .el \{\
2067 .sp -1
2068 .IP \(bu 2.3
2069 .\}
2070 If \(lqcan\(cqt use precompiled header\(rq has been incremented, see
2071 PRECOMPILED HEADERS\&.
2072 .RE
2073 .SS "Corrupt object files"
2074 .sp
2075 It should be noted that ccache is susceptible to general storage problems\&. If a bad object file sneaks into the cache for some reason, it will of course stay bad\&. Some possible reasons for erroneous object files are bad hardware (disk drive, disk controller, memory, etc), buggy drivers or file systems, a bad \fBprefix_command\fR or compiler wrapper\&. If this happens, the easiest way of fixing it is this:
2076 .sp
2077 .RS 4
2078 .ie n \{\
2079 \h'-04' 1.\h'+01'\c
2080 .\}
2081 .el \{\
2082 .sp -1
2083 .IP "  1." 4.2
2084 .\}
2085 Build so that the bad object file ends up in the build tree\&.
2086 .RE
2087 .sp
2088 .RS 4
2089 .ie n \{\
2090 \h'-04' 2.\h'+01'\c
2091 .\}
2092 .el \{\
2093 .sp -1
2094 .IP "  2." 4.2
2095 .\}
2096 Remove the bad object file from the build tree\&.
2097 .RE
2098 .sp
2099 .RS 4
2100 .ie n \{\
2101 \h'-04' 3.\h'+01'\c
2102 .\}
2103 .el \{\
2104 .sp -1
2105 .IP "  3." 4.2
2106 .\}
2107 Rebuild with
2108 \fBCCACHE_RECACHE\fR
2109 set\&.
2110 .RE
2111 .sp
2112 An alternative is to clear the whole cache with \fBccache \-C\fR if you don\(cqt mind losing other cached results\&.
2113 .sp
2114 There are no reported issues about ccache producing broken object files reproducibly\&. That doesn\(cqt mean it can\(cqt happen, so if you find a repeatable case, please report it\&.
2115 .SH "MORE INFORMATION"
2116 .sp
2117 Credits, mailing list information, bug reporting instructions, source code, etc, can be found on ccache\(cqs web site: https://ccache\&.samba\&.org\&.
2118 .SH "AUTHOR"
2119 .sp
2120 ccache was originally written by Andrew Tridgell and is currently developed and maintained by Joel Rosdahl\&. See AUTHORS\&.txt or AUTHORS\&.html and https://ccache\&.samba\&.org/credits\&.html for a list of contributors\&.