Imported Upstream version 3.3.4
[platform/upstream/ccache.git] / 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: 02/17/2017
6 .\"    Manual: ccache Manual
7 .\"    Source: ccache 3.3.4
8 .\"  Language: English
9 .\"
10 .TH "CCACHE" "1" "02/17/2017" "ccache 3\&.3\&.4" "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 uses hard links where possible to avoid copies\&.
110 .RE
111 .sp
112 .RS 4
113 .ie n \{\
114 \h'-04'\(bu\h'+03'\c
115 .\}
116 .el \{\
117 .sp -1
118 .IP \(bu 2.3
119 .\}
120 Optionally compresses files in the cache to reduce disk space\&.
121 .RE
122 .SS "Limitations"
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 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\&.
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 Only works with GCC and compilers that behave similar enough\&.
144 .RE
145 .sp
146 .RS 4
147 .ie n \{\
148 \h'-04'\(bu\h'+03'\c
149 .\}
150 .el \{\
151 .sp -1
152 .IP \(bu 2.3
153 .\}
154 Some compiler flags are not supported\&. If such a flag is detected, ccache will silently fall back to running the real compiler\&.
155 .RE
156 .SH "RUN MODES"
157 .sp
158 There are two ways to use ccache\&. You can either prefix your compilation commands with \fBccache\fR or you can let ccache masquerade as the compiler by creating a symbolic link (named as the compiler) to ccache\&. The first method is most convenient if you just want to try out ccache or wish to use it for some specific projects\&. The second method is most useful for when you wish to use ccache for all your compilations\&.
159 .sp
160 To use the first method, just make sure that \fBccache\fR is in your \fBPATH\fR\&.
161 .sp
162 To use the symlinks method, do something like this:
163 .sp
164 .if n \{\
165 .RS 4
166 .\}
167 .nf
168 cp ccache /usr/local/bin/
169 ln \-s ccache /usr/local/bin/gcc
170 ln \-s ccache /usr/local/bin/g++
171 ln \-s ccache /usr/local/bin/cc
172 ln \-s ccache /usr/local/bin/c++
173 .fi
174 .if n \{\
175 .RE
176 .\}
177 .sp
178 And so forth\&. This will work as long as the directory with symlinks comes before the path to the compiler (which is usually in /usr/bin)\&. After installing you may wish to run \(lqwhich gcc\(rq to make sure that the correct link is being used\&.
179 .if n \{\
180 .sp
181 .\}
182 .RS 4
183 .it 1 an-trap
184 .nr an-no-space-flag 1
185 .nr an-break-flag 1
186 .br
187 .ps +1
188 \fBWarning\fR
189 .ps -1
190 .br
191 .sp
192 The technique of letting ccache masquerade as the compiler works well, but currently doesn\(cqt interact well with other tools that do the same thing\&. See USING CCACHE WITH OTHER COMPILER WRAPPERS\&.
193 .sp .5v
194 .RE
195 .if n \{\
196 .sp
197 .\}
198 .RS 4
199 .it 1 an-trap
200 .nr an-no-space-flag 1
201 .nr an-break-flag 1
202 .br
203 .ps +1
204 \fBWarning\fR
205 .ps -1
206 .br
207 .sp
208 Do not use a hard link, use a symbolic link\&. A hard link will cause \(lqinteresting\(rq problems\&.
209 .sp .5v
210 .RE
211 .SH "OPTIONS"
212 .sp
213 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\&.
214 .PP
215 \fB\-c, \-\-cleanup\fR
216 .RS 4
217 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\&.
218 .RE
219 .PP
220 \fB\-C, \-\-clear\fR
221 .RS 4
222 Clear the entire cache, removing all cached files, but keeping the configuration file\&.
223 .RE
224 .PP
225 \fB\-F, \-\-max\-files\fR=\fIN\fR
226 .RS 4
227 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\&.
228 .RE
229 .PP
230 \fB\-h, \-\-help\fR
231 .RS 4
232 Print an options summary page\&.
233 .RE
234 .PP
235 \fB\-M, \-\-max\-size\fR=\fISIZE\fR
236 .RS 4
237 Set the maximum size of the files stored in the cache\&.
238 \fISIZE\fR
239 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\&.
240 .RE
241 .PP
242 \fB\-o, \-\-set\-config\fR=\fIKEY=VALUE\fR
243 .RS 4
244 Set configuration
245 \fIKEY\fR
246 to
247 \fIVALUE\fR\&. See
248 CONFIGURATION
249 for more information\&.
250 .RE
251 .PP
252 \fB\-p, \-\-print\-config\fR
253 .RS 4
254 Print current configuration options and from where they originate (environment variable, configuration file or compile\-time default)\&.
255 .RE
256 .PP
257 \fB\-s, \-\-show\-stats\fR
258 .RS 4
259 Print the current statistics summary for the cache\&.
260 .RE
261 .PP
262 \fB\-V, \-\-version\fR
263 .RS 4
264 Print version and copyright information\&.
265 .RE
266 .PP
267 \fB\-z, \-\-zero\-stats\fR
268 .RS 4
269 Zero the cache statistics (but not the configuration options)\&.
270 .RE
271 .SH "EXTRA OPTIONS"
272 .sp
273 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\&.
274 .if n \{\
275 .sp
276 .\}
277 .RS 4
278 .it 1 an-trap
279 .nr an-no-space-flag 1
280 .nr an-break-flag 1
281 .br
282 .ps +1
283 \fBNote\fR
284 .ps -1
285 .br
286 .sp
287 \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\&.
288 .sp .5v
289 .RE
290 .sp
291 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\&.
292 .sp
293 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\&.
294 .SH "CONFIGURATION"
295 .sp
296 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):
297 .sp
298 .RS 4
299 .ie n \{\
300 \h'-04' 1.\h'+01'\c
301 .\}
302 .el \{\
303 .sp -1
304 .IP "  1." 4.2
305 .\}
306 Environment variables\&.
307 .RE
308 .sp
309 .RS 4
310 .ie n \{\
311 \h'-04' 2.\h'+01'\c
312 .\}
313 .el \{\
314 .sp -1
315 .IP "  2." 4.2
316 .\}
317 The cache\-specific configuration file
318 \fB<ccachedir>/ccache\&.conf\fR
319 (typically
320 \fB$HOME/\&.ccache/ccache\&.conf\fR)\&.
321 .RE
322 .sp
323 .RS 4
324 .ie n \{\
325 \h'-04' 3.\h'+01'\c
326 .\}
327 .el \{\
328 .sp -1
329 .IP "  3." 4.2
330 .\}
331 The system\-wide configuration file
332 \fB<sysconfdir>/ccache\&.conf\fR
333 (typically
334 \fB/etc/ccache\&.conf\fR
335 or
336 \fB/usr/local/etc/ccache\&.conf\fR)\&.
337 .RE
338 .sp
339 .RS 4
340 .ie n \{\
341 \h'-04' 4.\h'+01'\c
342 .\}
343 .el \{\
344 .sp -1
345 .IP "  4." 4.2
346 .\}
347 Compile\-time defaults\&.
348 .RE
349 .sp
350 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\&.
351 .SS "Configuration file syntax"
352 .sp
353 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:
354 .sp
355 .if n \{\
356 .RS 4
357 .\}
358 .nf
359 # Set maximum cache size to 10 GB:
360 max_size = 10G
361 .fi
362 .if n \{\
363 .RE
364 .\}
365 .SS "Boolean values"
366 .sp
367 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 regardless of the value (even if set to the empty string), 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\&.
368 .SS "Configuration settings"
369 .sp
370 Below is a list of available configuration settings\&. The corresponding environment variable name is indicated in parentheses after each configuration setting key\&.
371 .PP
372 \fBbase_dir\fR (\fBCCACHE_BASEDIR\fR)
373 .RS 4
374 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\&. See also the discussion under
375 COMPILING IN DIFFERENT DIRECTORIES\&. If using GCC or newer versions of Clang, you might want to look into the
376 \fB\-fdebug\-prefix\-map=old=new\fR
377 option for relocating debug info to a common prefix (mapping prefix with old=new)\&.
378 .RE
379 .PP
380 \fBcache_dir\fR (\fBCCACHE_DIR\fR)
381 .RS 4
382 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
383 \fB$HOME/\&.ccache\fR\&.
384 .RE
385 .PP
386 \fBcache_dir_levels\fR (\fBCCACHE_NLEVELS\fR)
387 .RS 4
388 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\&.
389 .RE
390 .PP
391 \fBcompiler\fR (\fBCCACHE_CC\fR)
392 .RS 4
393 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\&.
394 .RE
395 .PP
396 \fBcompiler_check\fR (\fBCCACHE_COMPILERCHECK\fR)
397 .RS 4
398 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:
399 .PP
400 \fBcontent\fR
401 .RS 4
402 Hash the content of the compiler binary\&. This makes ccache very slightly slower compared to the
403 \fBmtime\fR
404 setting, but makes it cope better with compiler upgrades during a build bootstrapping process\&.
405 .RE
406 .PP
407 \fBmtime\fR
408 .RS 4
409 Hash the compiler\(cqs mtime and size, which is fast\&. This is the default\&.
410 .RE
411 .PP
412 \fBnone\fR
413 .RS 4
414 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
415 \fBnone\fR
416 setting if you know what you are doing\&.
417 .RE
418 .PP
419 \fBstring:value\fR
420 .RS 4
421 Use
422 \fBvalue\fR
423 as the string to calculate hash from\&. This can be the compiler revision number you retrieved earlier and set here via environment variable\&.
424 .RE
425 .PP
426 \fIa command string\fR
427 .RS 4
428 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
429 \fB%compiler%\fR
430 will be replaced with the path to the compiler\&. Several commands can be specified with semicolon as separator\&. Examples:
431 .sp
432 .if n \{\
433 .RS 4
434 .\}
435 .nf
436 %compiler% \-v
437 .fi
438 .if n \{\
439 .RE
440 .\}
441 .sp
442 .if n \{\
443 .RS 4
444 .\}
445 .nf
446 %compiler% \-dumpmachine; %compiler% \-dumpversion
447 .fi
448 .if n \{\
449 .RE
450 .\}
451 .sp
452 You should make sure that the specified command is as fast as possible since it will be run once for each ccache invocation\&.
453 .sp
454 Identifying the compiler using a command is useful if you want to avoid cache misses when the compiler has been rebuilt but not changed\&.
455 .sp
456 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
457 \fBmtime\fR
458 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
459 \fBmtime\fR
460 method in combination with the
461 \fBprefix_command\fR
462 setting if possible\&. See
463 USING CCACHE WITH OTHER COMPILER WRAPPERS\&.
464 .RE
465 .RE
466 .PP
467 \fBcompression\fR (\fBCCACHE_COMPRESS\fR or \fBCCACHE_NOCOMPRESS\fR, see Boolean values above)
468 .RS 4
469 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\&.
470 .RE
471 .PP
472 \fBcompression_level\fR (\fBCCACHE_COMPRESSLEVEL\fR)
473 .RS 4
474 This setting determines the level at which ccache will compress object files\&. It only has effect if
475 \fBcompression\fR
476 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)\&.
477 .RE
478 .PP
479 \fBcpp_extension\fR (\fBCCACHE_EXTENSION\fR)
480 .RS 4
481 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
482 \fBi\fR\&.
483 .RE
484 .PP
485 \fBdirect_mode\fR (\fBCCACHE_DIRECT\fR or \fBCCACHE_NODIRECT\fR, see Boolean values above)
486 .RS 4
487 If true, the direct mode will be used\&. The default is true\&. See
488 THE DIRECT MODE\&.
489 .RE
490 .PP
491 \fBdisable\fR (\fBCCACHE_DISABLE\fR or \fBCCACHE_NODISABLE\fR, see Boolean values above)
492 .RS 4
493 When true, ccache will just call the real compiler, bypassing the cache completely\&. The default is false\&.
494 .RE
495 .PP
496 \fBextra_files_to_hash\fR (\fBCCACHE_EXTRAFILES\fR)
497 .RS 4
498 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\&.
499 .RE
500 .PP
501 \fBhard_link\fR (\fBCCACHE_HARDLINK\fR or \fBCCACHE_NOHARDLINK\fR, see Boolean values above)
502 .RS 4
503 If true, ccache will attempt to use hard links from the cache directory when creating the compiler output rather than using a file copy\&. Using hard links may be slightly faster in some situations, but can confuse programs like \(lqmake\(rq that rely on modification times\&. Another thing to keep in mind is that if the resulting object file is modified in any way, this corrupts the cached object file as well\&. 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\&.
504 .RE
505 .PP
506 \fBhash_dir\fR (\fBCCACHE_HASHDIR\fR or \fBCCACHE_NOHASHDIR\fR, see Boolean values above)
507 .RS 4
508 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
509 \fB\-g\fR
510 with variations)\&. Exception: The CWD will not be included in the hash if
511 \fBbase_dir\fR
512 is set (and matches the CWD) and the compiler option
513 \fB\-fdebug\-prefix\-map\fR
514 is used\&.
515 .sp
516 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\&.
517 .sp
518 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\&.
519 .RE
520 .PP
521 \fBignore_headers_in_manifest\fR (\fBCCACHE_IGNOREHEADERS\fR)
522 .RS 4
523 This setting is a list of paths to files (or directories with headers) that ccache will
524 \fBnot\fR
525 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\&.
526 .RE
527 .PP
528 \fBkeep_comments_cpp\fR (\fBCCACHE_COMMENTS\fR or \fBCCACHE_NOCOMMENTS\fR, see Boolean values above)
529 .RS 4
530 If true, ccache will not discard the comments before hashing preprocessor output\&. This can be used to check documentation with
531 \fB\-Wdocumentation\fR\&.
532 .RE
533 .PP
534 \fBlimit_multiple\fR (\fBCCACHE_LIMIT_MULTIPLE\fR)
535 .RS 4
536 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%)\&.
537 .RE
538 .PP
539 \fBlog_file\fR (\fBCCACHE_LOGFILE\fR)
540 .RS 4
541 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\&.
542 .RE
543 .PP
544 \fBmax_files\fR (\fBCCACHE_MAXFILES\fR)
545 .RS 4
546 This option specifies the maximum number of files to keep in the cache\&. Use 0 for no limit (which is the default)\&.
547 .RE
548 .PP
549 \fBmax_size\fR (\fBCCACHE_MAXSIZE\fR)
550 .RS 4
551 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"\&.
552 .RE
553 .PP
554 \fBpath\fR (\fBCCACHE_PATH\fR)
555 .RS 4
556 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
557 \fBPATH\fR
558 that isn\(cqt a symbolic link to ccache itself\&.
559 .RE
560 .PP
561 \fBprefix_command\fR (\fBCCACHE_PREFIX\fR)
562 .RS 4
563 This option adds a list of prefixes (separated by space) to the command line that ccache uses when invoking the compiler\&. See also
564 USING CCACHE WITH OTHER COMPILER WRAPPERS\&.
565 .RE
566 .PP
567 \fBprefix_command_cpp\fR (\fBCCACHE_PREFIX_CPP\fR)
568 .RS 4
569 This option adds a list of prefixes (separated by space) to the command line that ccache uses when invoking the preprocessor\&.
570 .RE
571 .PP
572 \fBread_only\fR (\fBCCACHE_READONLY\fR or \fBCCACHE_NOREADONLY\fR, see Boolean values above)
573 .RS 4
574 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
575 \fBtemporary_dir\fR
576 as otherwise ccache will fail to create temporary files\&.
577 .RE
578 .PP
579 \fBread_only_direct\fR (\fBCCACHE_READONLY_DIRECT\fR or \fBCCACHE_NOREADONLY_DIRECT\fR, see Boolean values above)
580 .RS 4
581 Just like
582 \fBread_only\fR
583 except that ccache will only try to retrieve results from the cache using the direct mode, not the preprocessor mode\&. See documentation for
584 \fBread_only\fR
585 regarding using a read\-only ccache directory\&.
586 .RE
587 .PP
588 \fBrecache\fR (\fBCCACHE_RECACHE\fR or \fBCCACHE_NORECACHE\fR, see Boolean values above)
589 .RS 4
590 If true, ccache will not use any previously stored result\&. New results will still be cached, possibly overwriting any pre\-existing results\&.
591 .RE
592 .PP
593 \fBrun_second_cpp\fR (\fBCCACHE_CPP2\fR or \fBCCACHE_NOCPP2\fR, see Boolean values above)
594 .RS 4
595 If true, ccache will first run the preprocessor to preprocess the source code (see
596 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\&.
597 .sp
598 If false, ccache will first run preprocessor to preprocess the source code and then on a cache miss run the compiler on the
599 \fIpreprocessed source code\fR
600 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\&.
601 .RE
602 .PP
603 \fBsloppiness\fR (\fBCCACHE_SLOPPINESS\fR)
604 .RS 4
605 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:
606 .PP
607 \fBfile_macro\fR
608 .RS 4
609 Ignore
610 \fB__FILE__\fR
611 being present in the source\&.
612 .RE
613 .PP
614 \fBfile_stat_matches\fR
615 .RS 4
616 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 sizes, mtimes and ctimes match\&.
617 .RE
618 .PP
619 \fBinclude_file_ctime\fR
620 .RS 4
621 By default, ccache also will not cache a file if it includes a header whose ctime is too new\&. This option disables that check\&.
622 .RE
623 .PP
624 \fBinclude_file_mtime\fR
625 .RS 4
626 By default, ccache will not cache a file if it includes a header whose mtime is too new\&. This option disables that check\&.
627 .RE
628 .PP
629 \fBno_system_headers\fR
630 .RS 4
631 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\&.
632 .RE
633 .PP
634 \fBpch_defines\fR
635 .RS 4
636 Be sloppy about #defines when precompiling a header file\&. See
637 PRECOMPILED HEADERS
638 for more information\&.
639 .RE
640 .PP
641 \fBtime_macros\fR
642 .RS 4
643 Ignore
644 \fB__DATE__\fR
645 and
646 \fB__TIME__\fR
647 being present in the source code\&.
648 .RE
649 .sp
650 See the discussion under
651 TROUBLESHOOTING
652 for more information\&.
653 .RE
654 .PP
655 \fBstats\fR (\fBCCACHE_STATS\fR or \fBCCACHE_NOSTATS\fR, see Boolean values above)
656 .RS 4
657 If true, ccache will update the statistics counters on each compilation\&. The default is true\&.
658 .RE
659 .PP
660 \fBtemporary_dir\fR (\fBCCACHE_TEMPDIR\fR)
661 .RS 4
662 This setting specifies where ccache will put temporary files\&. The default is
663 \fB<cache_dir>/tmp\fR\&.
664 .if n \{\
665 .sp
666 .\}
667 .RS 4
668 .it 1 an-trap
669 .nr an-no-space-flag 1
670 .nr an-break-flag 1
671 .br
672 .ps +1
673 \fBNote\fR
674 .ps -1
675 .br
676 In previous versions of ccache,
677 \fBCCACHE_TEMPDIR\fR
678 had to be on the same filesystem as the
679 \fBCCACHE_DIR\fR
680 path, but this requirement has been relaxed\&.)
681 .sp .5v
682 .RE
683 .RE
684 .PP
685 \fBumask\fR (\fBCCACHE_UMASK\fR)
686 .RS 4
687 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\&.
688 .RE
689 .PP
690 \fBunify\fR (\fBCCACHE_UNIFY\fR or \fBCCACHE_NOUNIFY\fR, see Boolean values above)
691 .RS 4
692 If true, ccache will use a C/C++ unifier when hashing the preprocessor output if the
693 \fB\-g\fR
694 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
695 \fB__LINE__\fR
696 macro\&. Also note that enabling the unifier implies turning off the direct mode\&.
697 .RE
698 .SH "CACHE SIZE MANAGEMENT"
699 .sp
700 By default, ccache has a five gigabyte limit on the total size of files in the cache and no maximum 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)\&.
701 .SH "CACHE COMPRESSION"
702 .sp
703 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\&.
704 .SH "CACHE STATISTICS"
705 .sp
706 \fBccache \-s/\-\-show\-stats\fR can show the following statistics:
707 .TS
708 allbox tab(:);
709 ltB ltB.
710 T{
711 Name
712 T}:T{
713 Description
714 T}
715 .T&
716 lt lt
717 lt lt
718 lt lt
719 lt lt
720 lt lt
721 lt lt
722 lt lt
723 lt lt
724 lt lt
725 lt lt
726 lt lt
727 lt lt
728 lt lt
729 lt lt
730 lt lt
731 lt lt
732 lt lt
733 lt lt
734 lt lt
735 lt lt
736 lt lt
737 lt lt
738 lt lt
739 lt lt
740 lt lt
741 lt lt
742 lt lt
743 lt lt.
744 T{
745 .sp
746 autoconf compile/link
747 T}:T{
748 .sp
749 Uncachable compilation or linking by an autoconf test\&.
750 T}
751 T{
752 .sp
753 bad compiler arguments
754 T}:T{
755 .sp
756 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\&.
757 T}
758 T{
759 .sp
760 cache file missing
761 T}:T{
762 .sp
763 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\&.
764 T}
765 T{
766 .sp
767 cache hit (direct)
768 T}:T{
769 .sp
770 A result was successfully found using the direct mode\&.
771 T}
772 T{
773 .sp
774 cache hit (preprocessed)
775 T}:T{
776 .sp
777 A result was successfully found using the preprocessor mode\&.
778 T}
779 T{
780 .sp
781 cache miss
782 T}:T{
783 .sp
784 No result was found\&.
785 T}
786 T{
787 .sp
788 cache size
789 T}:T{
790 .sp
791 Current size of the cache\&.
792 T}
793 T{
794 .sp
795 called for link
796 T}:T{
797 .sp
798 The compiler was called for linking, not compiling\&.
799 T}
800 T{
801 .sp
802 called for preprocessing
803 T}:T{
804 .sp
805 The compiler was called for preprocessing, not compiling\&.
806 T}
807 T{
808 .sp
809 can\(cqt use precompiled header
810 T}:T{
811 .sp
812 Preconditions for using precompiled headers were not fulfilled\&.
813 T}
814 T{
815 .sp
816 ccache internal error
817 T}:T{
818 .sp
819 Unexpected failure, e\&.g\&. due to problems reading/writing the cache\&.
820 T}
821 T{
822 .sp
823 cleanups performed
824 T}:T{
825 .sp
826 Number of cleanups performed, either implicitly due to the cache size limit being reached or due to explicit \fBccache \-c/\-\-cleanup\fR calls\&.
827 T}
828 T{
829 .sp
830 compile failed
831 T}:T{
832 .sp
833 The compilation failed\&. No result stored in the cache\&.
834 T}
835 T{
836 .sp
837 compiler check failed
838 T}:T{
839 .sp
840 A compiler check program specified by \fBcompiler_check\fR (\fBCCACHE_COMPILERCHECK\fR) failed\&.
841 T}
842 T{
843 .sp
844 compiler produced empty output
845 T}:T{
846 .sp
847 The compiler\(cqs output file (typically an object file) was empty after compilation\&.
848 T}
849 T{
850 .sp
851 compiler produced no output
852 T}:T{
853 .sp
854 The compiler\(cqs output file (typically an object file) was missing after compilation\&.
855 T}
856 T{
857 .sp
858 compiler produced stdout
859 T}:T{
860 .sp
861 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\&.
862 T}
863 T{
864 .sp
865 couldn\(cqt find the compiler
866 T}:T{
867 .sp
868 The compiler to execute could not be found\&.
869 T}
870 T{
871 .sp
872 error hashing extra file
873 T}:T{
874 .sp
875 Failure reading a file specified by \fBextra_files_to_hash\fR (\fBCCACHE_EXTRAFILES\fR)\&.
876 T}
877 T{
878 .sp
879 files in cache
880 T}:T{
881 .sp
882 Current number of files in the cache\&.
883 T}
884 T{
885 .sp
886 multiple source files
887 T}:T{
888 .sp
889 The compiler was called to compile multiple source files in one go\&. This is not supported by ccache\&.
890 T}
891 T{
892 .sp
893 no input file
894 T}:T{
895 .sp
896 No input file was specified to the compiler\&.
897 T}
898 T{
899 .sp
900 output to a non\-regular file
901 T}:T{
902 .sp
903 The output path specified with \fB\-o\fR is not a file (e\&.g\&. a directory or a device node)\&.
904 T}
905 T{
906 .sp
907 output to stdout
908 T}:T{
909 .sp
910 The compiler was instructed to write its output to standard output using \fB\-o \-\fR\&. This is not supported by ccache\&.
911 T}
912 T{
913 .sp
914 preprocessor error
915 T}:T{
916 .sp
917 Preprocessing the source code using the compiler\(cqs \fB\-E\fR option failed\&.
918 T}
919 T{
920 .sp
921 unsupported code directive
922 T}:T{
923 .sp
924 Code like the assembler \(lq\&.incbin\(rq directive was found\&. This is not supported by ccache\&.
925 T}
926 T{
927 .sp
928 unsupported compiler option
929 T}:T{
930 .sp
931 A compiler option not supported by ccache was found\&.
932 T}
933 T{
934 .sp
935 unsupported source language
936 T}:T{
937 .sp
938 A source language e\&.g\&. specified with \fB\-x\fR was unsupported by ccache\&.
939 T}
940 .TE
941 .sp 1
942 .SH "HOW CCACHE WORKS"
943 .sp
944 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\&.
945 .sp
946 ccache has two ways of doing the detection:
947 .sp
948 .RS 4
949 .ie n \{\
950 \h'-04'\(bu\h'+03'\c
951 .\}
952 .el \{\
953 .sp -1
954 .IP \(bu 2.3
955 .\}
956 the
957 \fBdirect mode\fR, where ccache hashes the source code and include files directly
958 .RE
959 .sp
960 .RS 4
961 .ie n \{\
962 \h'-04'\(bu\h'+03'\c
963 .\}
964 .el \{\
965 .sp -1
966 .IP \(bu 2.3
967 .\}
968 the
969 \fBpreprocessor mode\fR, where ccache runs the preprocessor on the source code and hashes the result
970 .RE
971 .sp
972 The direct mode is generally faster since running the preprocessor has some overhead\&.
973 .SS "Common hashed information"
974 .sp
975 For both modes, the following information is included in the hash:
976 .sp
977 .RS 4
978 .ie n \{\
979 \h'-04'\(bu\h'+03'\c
980 .\}
981 .el \{\
982 .sp -1
983 .IP \(bu 2.3
984 .\}
985 the extension used by the compiler for a file with preprocessor output (normally
986 \fB\&.i\fR
987 for C code and
988 \fB\&.ii\fR
989 for C++ code)
990 .RE
991 .sp
992 .RS 4
993 .ie n \{\
994 \h'-04'\(bu\h'+03'\c
995 .\}
996 .el \{\
997 .sp -1
998 .IP \(bu 2.3
999 .\}
1000 the compiler\(cqs size and modification time (or other compiler\-specific information specified by the
1001 \fBcompiler_check\fR
1002 setting)
1003 .RE
1004 .sp
1005 .RS 4
1006 .ie n \{\
1007 \h'-04'\(bu\h'+03'\c
1008 .\}
1009 .el \{\
1010 .sp -1
1011 .IP \(bu 2.3
1012 .\}
1013 the name of the compiler
1014 .RE
1015 .sp
1016 .RS 4
1017 .ie n \{\
1018 \h'-04'\(bu\h'+03'\c
1019 .\}
1020 .el \{\
1021 .sp -1
1022 .IP \(bu 2.3
1023 .\}
1024 the current directory (if the
1025 \fBhash_dir\fR
1026 setting is enabled)
1027 .RE
1028 .sp
1029 .RS 4
1030 .ie n \{\
1031 \h'-04'\(bu\h'+03'\c
1032 .\}
1033 .el \{\
1034 .sp -1
1035 .IP \(bu 2.3
1036 .\}
1037 contents of files specified by the
1038 \fBextra_files_to_hash\fR
1039 setting (if any)
1040 .RE
1041 .SS "The direct mode"
1042 .sp
1043 In the direct mode, the hash is formed of the common information and:
1044 .sp
1045 .RS 4
1046 .ie n \{\
1047 \h'-04'\(bu\h'+03'\c
1048 .\}
1049 .el \{\
1050 .sp -1
1051 .IP \(bu 2.3
1052 .\}
1053 the input source file
1054 .RE
1055 .sp
1056 .RS 4
1057 .ie n \{\
1058 \h'-04'\(bu\h'+03'\c
1059 .\}
1060 .el \{\
1061 .sp -1
1062 .IP \(bu 2.3
1063 .\}
1064 the command line options
1065 .RE
1066 .sp
1067 Based on the hash, a data structure called \(lqmanifest\(rq is looked up in the cache\&. The manifest contains:
1068 .sp
1069 .RS 4
1070 .ie n \{\
1071 \h'-04'\(bu\h'+03'\c
1072 .\}
1073 .el \{\
1074 .sp -1
1075 .IP \(bu 2.3
1076 .\}
1077 references to cached compilation results (object file, dependency file, etc) that were produced by previous compilations that matched the hash
1078 .RE
1079 .sp
1080 .RS 4
1081 .ie n \{\
1082 \h'-04'\(bu\h'+03'\c
1083 .\}
1084 .el \{\
1085 .sp -1
1086 .IP \(bu 2.3
1087 .\}
1088 paths to the include files that were read at the time the compilation results were stored in the cache
1089 .RE
1090 .sp
1091 .RS 4
1092 .ie n \{\
1093 \h'-04'\(bu\h'+03'\c
1094 .\}
1095 .el \{\
1096 .sp -1
1097 .IP \(bu 2.3
1098 .\}
1099 hash sums of the include files at the time the compilation results were stored in the cache
1100 .RE
1101 .sp
1102 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\&.
1103 .sp
1104 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\&.
1105 .sp
1106 The direct mode will be disabled if any of the following holds:
1107 .sp
1108 .RS 4
1109 .ie n \{\
1110 \h'-04'\(bu\h'+03'\c
1111 .\}
1112 .el \{\
1113 .sp -1
1114 .IP \(bu 2.3
1115 .\}
1116 the configuration setting
1117 \fBdirect_mode\fR
1118 is false
1119 .RE
1120 .sp
1121 .RS 4
1122 .ie n \{\
1123 \h'-04'\(bu\h'+03'\c
1124 .\}
1125 .el \{\
1126 .sp -1
1127 .IP \(bu 2.3
1128 .\}
1129 a modification time of one of the include files is too new (needed to avoid a race condition)
1130 .RE
1131 .sp
1132 .RS 4
1133 .ie n \{\
1134 \h'-04'\(bu\h'+03'\c
1135 .\}
1136 .el \{\
1137 .sp -1
1138 .IP \(bu 2.3
1139 .\}
1140 the unifier is enabled (the configuration setting
1141 \fBunify\fR
1142 is true)
1143 .RE
1144 .sp
1145 .RS 4
1146 .ie n \{\
1147 \h'-04'\(bu\h'+03'\c
1148 .\}
1149 .el \{\
1150 .sp -1
1151 .IP \(bu 2.3
1152 .\}
1153 a compiler option not supported by the direct mode is used:
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 a
1164 \fB\-Wp,\fR\fB\fIX\fR\fR
1165 compiler option other than
1166 \fB\-Wp,\-MD,\fR\fB\fIpath\fR\fR,
1167 \fB\-Wp,\-MMD,\fR\fB\fIpath\fR\fR
1168 and
1169 \fB\-Wp,\-D_define_\fR
1170 .RE
1171 .sp
1172 .RS 4
1173 .ie n \{\
1174 \h'-04'\(bu\h'+03'\c
1175 .\}
1176 .el \{\
1177 .sp -1
1178 .IP \(bu 2.3
1179 .\}
1180 \fB\-Xpreprocessor\fR
1181 .RE
1182 .RE
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 string \(lq__TIME__\(rq is present in the source code
1193 .RE
1194 .SS "The preprocessor mode"
1195 .sp
1196 In the preprocessor mode, the hash is formed of the common information and:
1197 .sp
1198 .RS 4
1199 .ie n \{\
1200 \h'-04'\(bu\h'+03'\c
1201 .\}
1202 .el \{\
1203 .sp -1
1204 .IP \(bu 2.3
1205 .\}
1206 the preprocessor output from running the compiler with
1207 \fB\-E\fR
1208 .RE
1209 .sp
1210 .RS 4
1211 .ie n \{\
1212 \h'-04'\(bu\h'+03'\c
1213 .\}
1214 .el \{\
1215 .sp -1
1216 .IP \(bu 2.3
1217 .\}
1218 the command line options except options that affect include files (\fB\-I\fR,
1219 \fB\-include\fR,
1220 \fB\-D\fR, etc; the theory is that these options will change the preprocessor output if they have any effect at all)
1221 .RE
1222 .sp
1223 .RS 4
1224 .ie n \{\
1225 \h'-04'\(bu\h'+03'\c
1226 .\}
1227 .el \{\
1228 .sp -1
1229 .IP \(bu 2.3
1230 .\}
1231 any standard error output generated by the preprocessor
1232 .RE
1233 .sp
1234 Based on the hash, the cached compilation result can be looked up directly in the cache\&.
1235 .SH "COMPILING IN DIFFERENT DIRECTORIES"
1236 .sp
1237 Some information included in the hash that identifies a unique compilation may contain absolute paths:
1238 .sp
1239 .RS 4
1240 .ie n \{\
1241 \h'-04'\(bu\h'+03'\c
1242 .\}
1243 .el \{\
1244 .sp -1
1245 .IP \(bu 2.3
1246 .\}
1247 The preprocessed source code may contain absolute paths to include files if the compiler option
1248 \fB\-g\fR
1249 is used or if absolute paths are given to
1250 \fB\-I\fR
1251 and similar compiler options\&.
1252 .RE
1253 .sp
1254 .RS 4
1255 .ie n \{\
1256 \h'-04'\(bu\h'+03'\c
1257 .\}
1258 .el \{\
1259 .sp -1
1260 .IP \(bu 2.3
1261 .\}
1262 Paths specified by compiler options (such as
1263 \fB\-I\fR,
1264 \fB\-MF\fR, etc) may be absolute\&.
1265 .RE
1266 .sp
1267 .RS 4
1268 .ie n \{\
1269 \h'-04'\(bu\h'+03'\c
1270 .\}
1271 .el \{\
1272 .sp -1
1273 .IP \(bu 2.3
1274 .\}
1275 The source code file path may be absolute, and that path may substituted for
1276 \fB__FILE__\fR
1277 macros in the source code or included in warnings emitted to standard error by the preprocessor\&.
1278 .RE
1279 .sp
1280 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\&. To mitigate this problem, you can specify a \(lqbase directory\(rq in the configuration setting \fBbase_dir\fR to an absolute path to the directory\&. ccache will then rewrite absolute paths that are under the base directory (i\&.e\&., paths that have the base directory as a prefix) to relative paths when constructing the hash\&. 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 / as the base directory since that will make ccache also rewrite paths to system header files, which doesn\(cqt gain anything\&.)
1281 .sp
1282 The drawbacks of using a base directory are:
1283 .sp
1284 .RS 4
1285 .ie n \{\
1286 \h'-04'\(bu\h'+03'\c
1287 .\}
1288 .el \{\
1289 .sp -1
1290 .IP \(bu 2.3
1291 .\}
1292 If you specify an absolute path to the source code file,
1293 \fB__FILE__\fR
1294 macros will be expanded to a relative path instead\&.
1295 .RE
1296 .sp
1297 .RS 4
1298 .ie n \{\
1299 \h'-04'\(bu\h'+03'\c
1300 .\}
1301 .el \{\
1302 .sp -1
1303 .IP \(bu 2.3
1304 .\}
1305 If you specify an absolute path to the source code file and compile with
1306 \fB\-g\fR, the source code path stored in the object file may point to the wrong directory, which may prevent debuggers like GDB from finding the source code\&. Sometimes, a work\-around is to change the directory explicitly with the \(lqcd\(rq command in GDB\&.
1307 .RE
1308 .SH "PRECOMPILED HEADERS"
1309 .sp
1310 ccache has support for GCC\(cqs precompiled headers\&. However, you have to do some things to make it work properly:
1311 .sp
1312 .RS 4
1313 .ie n \{\
1314 \h'-04'\(bu\h'+03'\c
1315 .\}
1316 .el \{\
1317 .sp -1
1318 .IP \(bu 2.3
1319 .\}
1320 You must set
1321 \fBsloppiness\fR
1322 to
1323 \fBpch_defines,time_macros\fR\&. The reason is that ccache can\(cqt tell whether
1324 \fB__TIME__\fR
1325 or
1326 \fB__DATE__\fR
1327 is used when using a precompiled header\&. Further, it can\(cqt detect changes in #defines in the source code because of how preprocessing works in combination with precompiled headers\&.
1328 .RE
1329 .sp
1330 .RS 4
1331 .ie n \{\
1332 \h'-04'\(bu\h'+03'\c
1333 .\}
1334 .el \{\
1335 .sp -1
1336 .IP \(bu 2.3
1337 .\}
1338 You must either:
1339 .sp
1340 .RS 4
1341 .ie n \{\
1342 \h'-04'\(bu\h'+03'\c
1343 .\}
1344 .el \{\
1345 .sp -1
1346 .IP \(bu 2.3
1347 .\}
1348 use the
1349 \fB\-include\fR
1350 compiler option to include the precompiled header (i\&.e\&., don\(cqt use
1351 \fB#include\fR
1352 in the source code to include the header); or
1353 .RE
1354 .sp
1355 .RS 4
1356 .ie n \{\
1357 \h'-04'\(bu\h'+03'\c
1358 .\}
1359 .el \{\
1360 .sp -1
1361 .IP \(bu 2.3
1362 .\}
1363 (for the Clang compiler) use the
1364 \fB\-include\-pch\fR
1365 compiler option to include the PCH file generated from the precompiled header; or
1366 .RE
1367 .sp
1368 .RS 4
1369 .ie n \{\
1370 \h'-04'\(bu\h'+03'\c
1371 .\}
1372 .el \{\
1373 .sp -1
1374 .IP \(bu 2.3
1375 .\}
1376 add the
1377 \fB\-fpch\-preprocess\fR
1378 compiler option when compiling\&.
1379 .RE
1380 .sp
1381 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)\&.
1382 .RE
1383 .SH "SHARING A CACHE"
1384 .sp
1385 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:
1386 .sp
1387 .RS 4
1388 .ie n \{\
1389 \h'-04'\(bu\h'+03'\c
1390 .\}
1391 .el \{\
1392 .sp -1
1393 .IP \(bu 2.3
1394 .\}
1395 Use the same cache directory\&.
1396 .RE
1397 .sp
1398 .RS 4
1399 .ie n \{\
1400 \h'-04'\(bu\h'+03'\c
1401 .\}
1402 .el \{\
1403 .sp -1
1404 .IP \(bu 2.3
1405 .\}
1406 Make sure that the configuration setting
1407 \fBhard_link\fR
1408 is false (which is the default)\&.
1409 .RE
1410 .sp
1411 .RS 4
1412 .ie n \{\
1413 \h'-04'\(bu\h'+03'\c
1414 .\}
1415 .el \{\
1416 .sp -1
1417 .IP \(bu 2.3
1418 .\}
1419 Make sure that all users are in the same group\&.
1420 .RE
1421 .sp
1422 .RS 4
1423 .ie n \{\
1424 \h'-04'\(bu\h'+03'\c
1425 .\}
1426 .el \{\
1427 .sp -1
1428 .IP \(bu 2.3
1429 .\}
1430 Set the configuration setting
1431 \fBumask\fR
1432 to 002\&. This ensures that cached files are accessible to everyone in the group\&.
1433 .RE
1434 .sp
1435 .RS 4
1436 .ie n \{\
1437 \h'-04'\(bu\h'+03'\c
1438 .\}
1439 .el \{\
1440 .sp -1
1441 .IP \(bu 2.3
1442 .\}
1443 Make sure that all users have write permission in the entire cache directory (and that you trust all users of the shared cache)\&.
1444 .RE
1445 .sp
1446 .RS 4
1447 .ie n \{\
1448 \h'-04'\(bu\h'+03'\c
1449 .\}
1450 .el \{\
1451 .sp -1
1452 .IP \(bu 2.3
1453 .\}
1454 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:
1455 .sp
1456 .if n \{\
1457 .RS 4
1458 .\}
1459 .nf
1460 find $CCACHE_DIR \-type d | xargs chmod g+s
1461 .fi
1462 .if n \{\
1463 .RE
1464 .\}
1465 .RE
1466 .sp
1467 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\&.
1468 .sp
1469 You may also want to make sure that a base directory is set appropriately, as discussed in a previous section\&.
1470 .SH "SHARING A CACHE ON NFS"
1471 .sp
1472 It is possible to put the cache directory on an NFS filesystem (or similar filesystems), but keep in mind that:
1473 .sp
1474 .RS 4
1475 .ie n \{\
1476 \h'-04'\(bu\h'+03'\c
1477 .\}
1478 .el \{\
1479 .sp -1
1480 .IP \(bu 2.3
1481 .\}
1482 Having the cache on NFS may slow down compilation\&. Make sure to do some benchmarking to see if it\(cqs worth it\&.
1483 .RE
1484 .sp
1485 .RS 4
1486 .ie n \{\
1487 \h'-04'\(bu\h'+03'\c
1488 .\}
1489 .el \{\
1490 .sp -1
1491 .IP \(bu 2.3
1492 .\}
1493 ccache hasn\(cqt been tested very thoroughly on NFS\&.
1494 .RE
1495 .sp
1496 A tip is to set \fBtemporary_dir\fR to a directory on the local host to avoid NFS traffic for temporary files\&.
1497 .SH "USING CCACHE WITH OTHER COMPILER WRAPPERS"
1498 .sp
1499 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\&.
1500 .sp
1501 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:
1502 .sp
1503 .RS 4
1504 .ie n \{\
1505 \h'-04'\(bu\h'+03'\c
1506 .\}
1507 .el \{\
1508 .sp -1
1509 .IP \(bu 2.3
1510 .\}
1511 Compiler upgrades will not be detected properly\&.
1512 .RE
1513 .sp
1514 .RS 4
1515 .ie n \{\
1516 \h'-04'\(bu\h'+03'\c
1517 .\}
1518 .el \{\
1519 .sp -1
1520 .IP \(bu 2.3
1521 .\}
1522 The cached results will not be shared between compilations with and without the other wrapper\&.
1523 .RE
1524 .sp
1525 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)\&.
1526 .SH "CAVEATS"
1527 .sp
1528 .RS 4
1529 .ie n \{\
1530 \h'-04'\(bu\h'+03'\c
1531 .\}
1532 .el \{\
1533 .sp -1
1534 .IP \(bu 2.3
1535 .\}
1536 The direct mode fails to pick up new header files in some rare scenarios\&. See
1537 THE DIRECT MODE
1538 above\&.
1539 .RE
1540 .SH "TROUBLESHOOTING"
1541 .SS "General"
1542 .sp
1543 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\&.
1544 .SS "Performance"
1545 .sp
1546 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\&.
1547 .sp
1548 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\&.
1549 .sp
1550 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:
1551 .sp
1552 .RS 4
1553 .ie n \{\
1554 \h'-04'\(bu\h'+03'\c
1555 .\}
1556 .el \{\
1557 .sp -1
1558 .IP \(bu 2.3
1559 .\}
1560 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:
1561 .sp
1562 .RS 4
1563 .ie n \{\
1564 \h'-04'\(bu\h'+03'\c
1565 .\}
1566 .el \{\
1567 .sp -1
1568 .IP \(bu 2.3
1569 .\}
1570 The source code has been modified in such a way that the preprocessor output is not affected\&.
1571 .RE
1572 .sp
1573 .RS 4
1574 .ie n \{\
1575 \h'-04'\(bu\h'+03'\c
1576 .\}
1577 .el \{\
1578 .sp -1
1579 .IP \(bu 2.3
1580 .\}
1581 Compiler arguments that are hashed in the direct mode but not in the preprocessor mode have changed (\fB\-I\fR,
1582 \fB\-include\fR,
1583 \fB\-D\fR, etc) and they didn\(cqt affect the preprocessor output\&.
1584 .RE
1585 .sp
1586 .RS 4
1587 .ie n \{\
1588 \h'-04'\(bu\h'+03'\c
1589 .\}
1590 .el \{\
1591 .sp -1
1592 .IP \(bu 2.3
1593 .\}
1594 The compiler option
1595 \fB\-Xpreprocessor\fR
1596 or
1597 \fB\-Wp,\fR\fB\fIX\fR\fR
1598 (except
1599 \fB\-Wp,\-MD,\fR\fB\fIpath\fR\fR,
1600 \fB\-Wp,\-MMD,\fR\fB\fIpath\fR\fR, and
1601 \fB\-Wp,\-D_define_\fR) is used\&.
1602 .RE
1603 .sp
1604 .RS 4
1605 .ie n \{\
1606 \h'-04'\(bu\h'+03'\c
1607 .\}
1608 .el \{\
1609 .sp -1
1610 .IP \(bu 2.3
1611 .\}
1612 This was the first compilation with a new value of the base directory setting\&.
1613 .RE
1614 .sp
1615 .RS 4
1616 .ie n \{\
1617 \h'-04'\(bu\h'+03'\c
1618 .\}
1619 .el \{\
1620 .sp -1
1621 .IP \(bu 2.3
1622 .\}
1623 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
1624 \fBsloppiness\fR
1625 to
1626 \fBinclude_file_mtime\fR
1627 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\&.)
1628 .RE
1629 .sp
1630 .RS 4
1631 .ie n \{\
1632 \h'-04'\(bu\h'+03'\c
1633 .\}
1634 .el \{\
1635 .sp -1
1636 .IP \(bu 2.3
1637 .\}
1638 The
1639 \fB__TIME__\fR
1640 preprocessor macro is (potentially) being used\&. ccache turns off direct mode if \(lq__TIME__\(rq is present in the source code\&. This is done as a safety measure since the string indicates that a
1641 \fB__TIME__\fR
1642 macro
1643 \fImay\fR
1644 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
1645 \fB__TIME__\fR
1646 isn\(cqt used in practise, or don\(cqt care if ccache produces objects where
1647 \fB__TIME__\fR
1648 is expanded to something in the past, you can set
1649 \fBsloppiness\fR
1650 to
1651 \fBtime_macros\fR\&.
1652 .RE
1653 .sp
1654 .RS 4
1655 .ie n \{\
1656 \h'-04'\(bu\h'+03'\c
1657 .\}
1658 .el \{\
1659 .sp -1
1660 .IP \(bu 2.3
1661 .\}
1662 The
1663 \fB__DATE__\fR
1664 preprocessor macro is (potentially) being used and the date has changed\&. This is similar to how
1665 \fB__TIME__\fR
1666 is handled\&. If \(lq__DATE__\(rq is present in the source code, ccache hashes the current date in order to be able to produce the correct object file if the
1667 \fB__DATE__\fR
1668 macro affects the output\&. If you know that
1669 \fB__DATE__\fR
1670 isn\(cqt used in practise, or don\(cqt care if ccache produces objects where
1671 \fB__DATE__\fR
1672 is expanded to something in the past, you can set
1673 \fBsloppiness\fR
1674 to
1675 \fBtime_macros\fR\&.
1676 .RE
1677 .sp
1678 .RS 4
1679 .ie n \{\
1680 \h'-04'\(bu\h'+03'\c
1681 .\}
1682 .el \{\
1683 .sp -1
1684 .IP \(bu 2.3
1685 .\}
1686 The
1687 \fB__FILE__\fR
1688 preprocessor macro is (potentially) being used and the file path has changed\&. If \(lq__FILE__\(rq 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
1689 \fB__FILE__\fR
1690 macro affects the output\&. If you know that
1691 \fB__FILE__\fR
1692 isn\(cqt used in practise, or don\(cqt care if ccache produces objects where
1693 \fB__FILE__\fR
1694 is expanded to the wrong path, you can set
1695 \fBsloppiness\fR
1696 to
1697 \fBfile_macro\fR\&.
1698 .RE
1699 .RE
1700 .sp
1701 .RS 4
1702 .ie n \{\
1703 \h'-04'\(bu\h'+03'\c
1704 .\}
1705 .el \{\
1706 .sp -1
1707 .IP \(bu 2.3
1708 .\}
1709 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
1710 \fB__TIME__\fR
1711 or
1712 \fB__DATE__\fR
1713 macros, or use of automatically generated code that contains a timestamp, build counter or other volatile information\&.
1714 .RE
1715 .sp
1716 .RS 4
1717 .ie n \{\
1718 \h'-04'\(bu\h'+03'\c
1719 .\}
1720 .el \{\
1721 .sp -1
1722 .IP \(bu 2.3
1723 .\}
1724 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\&.
1725 .RE
1726 .sp
1727 .RS 4
1728 .ie n \{\
1729 \h'-04'\(bu\h'+03'\c
1730 .\}
1731 .el \{\
1732 .sp -1
1733 .IP \(bu 2.3
1734 .\}
1735 If \(lqunsupported compiler option\(rq has been incremented, enable debug logging and check which option was rejected\&.
1736 .RE
1737 .sp
1738 .RS 4
1739 .ie n \{\
1740 \h'-04'\(bu\h'+03'\c
1741 .\}
1742 .el \{\
1743 .sp -1
1744 .IP \(bu 2.3
1745 .\}
1746 If \(lqpreprocessor error\(rq has been incremented, one possible reason is that precompiled headers are being used\&. See
1747 PRECOMPILED HEADERS
1748 for how to remedy this\&.
1749 .RE
1750 .sp
1751 .RS 4
1752 .ie n \{\
1753 \h'-04'\(bu\h'+03'\c
1754 .\}
1755 .el \{\
1756 .sp -1
1757 .IP \(bu 2.3
1758 .\}
1759 If \(lqcan\(cqt use precompiled header\(rq has been incremented, see
1760 PRECOMPILED HEADERS\&.
1761 .RE
1762 .SS "Corrupt object files"
1763 .sp
1764 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:
1765 .sp
1766 .RS 4
1767 .ie n \{\
1768 \h'-04' 1.\h'+01'\c
1769 .\}
1770 .el \{\
1771 .sp -1
1772 .IP "  1." 4.2
1773 .\}
1774 Build so that the bad object file ends up in the build tree\&.
1775 .RE
1776 .sp
1777 .RS 4
1778 .ie n \{\
1779 \h'-04' 2.\h'+01'\c
1780 .\}
1781 .el \{\
1782 .sp -1
1783 .IP "  2." 4.2
1784 .\}
1785 Remove the bad object file from the build tree\&.
1786 .RE
1787 .sp
1788 .RS 4
1789 .ie n \{\
1790 \h'-04' 3.\h'+01'\c
1791 .\}
1792 .el \{\
1793 .sp -1
1794 .IP "  3." 4.2
1795 .\}
1796 Rebuild with
1797 \fBCCACHE_RECACHE\fR
1798 set\&.
1799 .RE
1800 .sp
1801 An alternative is to clear the whole cache with \fBccache \-C\fR if you don\(cqt mind losing other cached results\&.
1802 .sp
1803 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\&.
1804 .SH "MORE INFORMATION"
1805 .sp
1806 Credits, mailing list information, bug reporting instructions, source code, etc, can be found on ccache\(cqs web site: https://ccache\&.samba\&.org\&.
1807 .SH "AUTHOR"
1808 .sp
1809 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\&.