Imported Upstream version 3.2.6
[platform/upstream/ccache.git] / ccache.1
1 '\" t
2 .\"     Title: ccache
3 .\"    Author: [see the "Author" section]
4 .\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
5 .\"      Date: 07/12/2016
6 .\"    Manual: ccache Manual
7 .\"    Source: ccache 3.2.6
8 .\"  Language: English
9 .\"
10 .TH "CCACHE" "1" "07/12/2016" "ccache 3\&.2\&.6" "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 BUGS\&. 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\&. \fBNote\fR: \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\&.
274 .sp
275 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\&.
276 .sp
277 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\&.
278 .SH "CONFIGURATION"
279 .sp
280 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):
281 .sp
282 .RS 4
283 .ie n \{\
284 \h'-04' 1.\h'+01'\c
285 .\}
286 .el \{\
287 .sp -1
288 .IP "  1." 4.2
289 .\}
290 Environment variables\&.
291 .RE
292 .sp
293 .RS 4
294 .ie n \{\
295 \h'-04' 2.\h'+01'\c
296 .\}
297 .el \{\
298 .sp -1
299 .IP "  2." 4.2
300 .\}
301 The cache\-specific configuration file
302 \fB<ccachedir>/ccache\&.conf\fR
303 (typically
304 \fB$HOME/\&.ccache/ccache\&.conf\fR)\&.
305 .RE
306 .sp
307 .RS 4
308 .ie n \{\
309 \h'-04' 3.\h'+01'\c
310 .\}
311 .el \{\
312 .sp -1
313 .IP "  3." 4.2
314 .\}
315 The system\-wide configuration file
316 \fB<sysconfdir>/ccache\&.conf\fR
317 (typically
318 \fB/etc/ccache\&.conf\fR
319 or
320 \fB/usr/local/etc/ccache\&.conf\fR)\&.
321 .RE
322 .sp
323 .RS 4
324 .ie n \{\
325 \h'-04' 4.\h'+01'\c
326 .\}
327 .el \{\
328 .sp -1
329 .IP "  4." 4.2
330 .\}
331 Compile\-time defaults\&.
332 .RE
333 .sp
334 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\&.
335 .SS "Configuration file syntax"
336 .sp
337 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:
338 .sp
339 .if n \{\
340 .RS 4
341 .\}
342 .nf
343 # Set maximum cache size to 10 GB:
344 max_size = 10G
345 .fi
346 .if n \{\
347 .RE
348 .\}
349 .SS "Boolean values"
350 .sp
351 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\&.
352 .SS "Configuration settings"
353 .sp
354 Below is a list of available configuration settings\&. The corresponding environment variable name is indicated in parentheses after each configuration setting key\&.
355 .PP
356 \fBbase_dir\fR (\fBCCACHE_BASEDIR\fR)
357 .RS 4
358 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
359 COMPILING IN DIFFERENT DIRECTORIES\&.
360 .RE
361 .PP
362 \fBcache_dir\fR (\fBCCACHE_DIR\fR)
363 .RS 4
364 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
365 \fB$HOME/\&.ccache\fR\&.
366 .RE
367 .PP
368 \fBcache_dir_levels\fR (\fBCCACHE_NLEVELS\fR)
369 .RS 4
370 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\&.
371 .RE
372 .PP
373 \fBcompiler\fR (\fBCCACHE_CC\fR)
374 .RS 4
375 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\&.
376 .RE
377 .PP
378 \fBcompiler_check\fR (\fBCCACHE_COMPILERCHECK\fR)
379 .RS 4
380 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:
381 .PP
382 \fBcontent\fR
383 .RS 4
384 Hash the content of the compiler binary\&. This makes ccache very slightly slower compared to the
385 \fBmtime\fR
386 setting, but makes it cope better with compiler upgrades during a build bootstrapping process\&.
387 .RE
388 .PP
389 \fBmtime\fR
390 .RS 4
391 Hash the compiler\(cqs mtime and size, which is fast\&. This is the default\&.
392 .RE
393 .PP
394 \fBnone\fR
395 .RS 4
396 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
397 \fBnone\fR
398 setting if you know what you are doing\&.
399 .RE
400 .PP
401 \fBstring:value\fR
402 .RS 4
403 Use
404 \fBvalue\fR
405 as the string to calculate hash from\&. This can be the compiler revision number you retrieved earlier and set here via environment variable\&.
406 .RE
407 .PP
408 \fIa command string\fR
409 .RS 4
410 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
411 \fB%compiler%\fR
412 will be replaced with the path to the compiler\&. Several commands can be specified with semicolon as separator\&. Examples:
413 .sp
414 .RS 4
415 .ie n \{\
416 \h'-04'\(bu\h'+03'\c
417 .\}
418 .el \{\
419 .sp -1
420 .IP \(bu 2.3
421 .\}
422 %compiler% \-v
423 .RE
424 .sp
425 .RS 4
426 .ie n \{\
427 \h'-04'\(bu\h'+03'\c
428 .\}
429 .el \{\
430 .sp -1
431 .IP \(bu 2.3
432 .\}
433 %compiler% \-dumpmachine; %compiler% \-dumpversion
434 .RE
435 .sp
436 You should make sure that the specified command is as fast as possible since it will be run once for each ccache invocation\&.
437 .sp
438 Identifying the compiler using a command is useful if you want to avoid cache misses when the compiler has been rebuilt but not changed\&.
439 .sp
440 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
441 \fBmtime\fR
442 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
443 \fBmtime\fR
444 method in combination with the
445 \fBprefix_command\fR
446 setting if possible\&. See
447 USING CCACHE WITH OTHER COMPILER WRAPPERS\&.
448 .RE
449 .RE
450 .PP
451 \fBcompression\fR (\fBCCACHE_COMPRESS\fR or \fBCCACHE_NOCOMPRESS\fR, see Boolean values above)
452 .RS 4
453 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\&.
454 .RE
455 .PP
456 \fBcompression_level\fR (\fBCCACHE_COMPRESSLEVEL\fR)
457 .RS 4
458 This setting determines the level at which ccache will compress object files\&. It only has effect if
459 \fBcompression\fR
460 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)\&.
461 .RE
462 .PP
463 \fBcpp_extension\fR (\fBCCACHE_EXTENSION\fR)
464 .RS 4
465 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
466 \fBi\fR\&.
467 .RE
468 .PP
469 \fBdirect_mode\fR (\fBCCACHE_DIRECT\fR or \fBCCACHE_NODIRECT\fR, see Boolean values above)
470 .RS 4
471 If true, the direct mode will be used\&. The default is true\&. See
472 THE DIRECT MODE\&.
473 .RE
474 .PP
475 \fBdisable\fR (\fBCCACHE_DISABLE\fR or \fBCCACHE_NODISABLE\fR, see Boolean values above)
476 .RS 4
477 When true, ccache will just call the real compiler, bypassing the cache completely\&. The default is false\&.
478 .RE
479 .PP
480 \fBextra_files_to_hash\fR (\fBCCACHE_EXTRAFILES\fR)
481 .RS 4
482 This setting is a list of paths to files that ccache will include in the the hash sum that idetifies the build\&. The list separator is semicolon on Windows systems and colon on other systems\&.
483 .RE
484 .PP
485 \fBhard_link\fR (\fBCCACHE_HARDLINK\fR or \fBCCACHE_NOHARDLINK\fR, see Boolean values above)
486 .RS 4
487 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\&.
488 .RE
489 .PP
490 \fBhash_dir\fR (\fBCCACHE_HASHDIR\fR or \fBCCACHE_NOHASHDIR\fR, see Boolean values above)
491 .RS 4
492 If true, ccache will include the current working directory in the hash that is used to distinguish two compilations\&. This prevents a problem with the storage of the current working directory in the debug info of an object file, which can lead ccache to give a cached object file that has the working directory in the debug info set incorrectly\&. This option is off by default as the incorrect setting of this debug info rarely causes problems\&. If you strike problems with GDB not using the correct directory then enable this option\&.
493 .RE
494 .PP
495 \fBlog_file\fR (\fBCCACHE_LOGFILE\fR)
496 .RS 4
497 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\&.
498 .RE
499 .PP
500 \fBmax_files\fR (\fBCCACHE_MAXFILES\fR)
501 .RS 4
502 This option specifies the maximum number of files to keep in the cache\&. Use 0 for no limit (which is the default)\&.
503 .RE
504 .PP
505 \fBmax_size\fR (\fBCCACHE_MAXSIZE\fR)
506 .RS 4
507 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"\&.
508 .RE
509 .PP
510 \fBpath\fR (\fBCCACHE_PATH\fR)
511 .RS 4
512 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
513 \fBPATH\fR
514 that isn\(cqt a symbolic link to ccache itself\&.
515 .RE
516 .PP
517 \fBprefix_command\fR (\fBCCACHE_PREFIX\fR)
518 .RS 4
519 This option adds a list of prefixes (separated by space) to the command line that ccache uses when invoking the compiler\&. See also
520 USING CCACHE WITH OTHER COMPILER WRAPPERS\&.
521 .RE
522 .PP
523 \fBread_only\fR (\fBCCACHE_READONLY\fR or \fBCCACHE_NOREADONLY\fR, see Boolean values above)
524 .RS 4
525 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
526 \fBtemporary_dir\fR
527 as otherwise ccache will fail to create temporary files\&.
528 .RE
529 .PP
530 \fBread_only_direct\fR (\fBCCACHE_READONLY_DIRECT\fR or \fBCCACHE_NOREADONLY_DIRECT\fR, see Boolean values above)
531 .RS 4
532 Just like
533 \fBread_only\fR
534 except that ccache will only try to retrieve results from the cache using the direct mode, not the preprocessor mode\&. See documentation for
535 \fBread_only\fR
536 regarding using a read\-only ccache directory\&.
537 .RE
538 .PP
539 \fBrecache\fR (\fBCCACHE_RECACHE\fR or \fBCCACHE_NORECACHE\fR, see Boolean values above)
540 .RS 4
541 If true, ccache will not use any previously stored result\&. New results will still be cached, possibly overwriting any pre\-existing results\&.
542 .RE
543 .PP
544 \fBrun_second_cpp\fR (\fBCCACHE_CPP2\fR or \fBCCACHE_NOCPP2\fR, see Boolean values above)
545 .RS 4
546 If true, ccache will not use the optimisation of avoiding the second call to the preprocessor by compiling the preprocessed output that was used for finding the hash in the case of a cache miss\&. This is primarily a debugging option, although it is possible that some unusual compilers will have problems with compiling the preprocessed output, in which case this option could allow ccache to be used anyway\&.
547 .RE
548 .PP
549 \fBsloppiness\fR (\fBCCACHE_SLOPPINESS\fR)
550 .RS 4
551 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:
552 .PP
553 \fBfile_macro\fR
554 .RS 4
555 Ignore
556 \fB__FILE__\fR
557 being present in the source\&.
558 .RE
559 .PP
560 \fBfile_stat_matches\fR
561 .RS 4
562 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\&.
563 .RE
564 .PP
565 \fBinclude_file_ctime\fR
566 .RS 4
567 By default, ccache also will not cache a file if it includes a header whose ctime is too new\&. This option disables that check\&.
568 .RE
569 .PP
570 \fBinclude_file_mtime\fR
571 .RS 4
572 By default, ccache will not cache a file if it includes a header whose mtime is too new\&. This option disables that check\&.
573 .RE
574 .PP
575 \fBpch_defines\fR
576 .RS 4
577 Be sloppy about #defines when precompiling a header file\&. See
578 PRECOMPILED HEADERS
579 for more information\&.
580 .RE
581 .PP
582 \fBtime_macros\fR
583 .RS 4
584 Ignore
585 \fB__DATE__\fR
586 and
587 \fB__TIME__\fR
588 being present in the source code\&.
589 .RE
590 .sp
591 See the discussion under
592 TROUBLESHOOTING
593 for more information\&.
594 .RE
595 .PP
596 \fBstats\fR (\fBCCACHE_STATS\fR or \fBCCACHE_NOSTATS\fR, see Boolean values above)
597 .RS 4
598 If true, ccache will update the statistics counters on each compilation\&. The default is true\&.
599 .RE
600 .PP
601 \fBtemporary_dir\fR (\fBCCACHE_TEMPDIR\fR)
602 .RS 4
603 This setting specifies where ccache will put temporary files\&. The default is
604 \fB<cache_dir>/tmp\fR\&.
605 .if n \{\
606 .sp
607 .\}
608 .RS 4
609 .it 1 an-trap
610 .nr an-no-space-flag 1
611 .nr an-break-flag 1
612 .br
613 .ps +1
614 \fBNote\fR
615 .ps -1
616 .br
617 In previous versions of ccache,
618 \fBCCACHE_TEMPDIR\fR
619 had to be on the same filesystem as the
620 \fBCCACHE_DIR\fR
621 path, but this requirement has been relaxed\&.)
622 .sp .5v
623 .RE
624 .RE
625 .PP
626 \fBumask\fR (\fBCCACHE_UMASK\fR)
627 .RS 4
628 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\&.
629 .RE
630 .PP
631 \fBunify\fR (\fBCCACHE_UNIFY\fR or \fBCCACHE_NOUNIFY\fR, see Boolean values above)
632 .RS 4
633 If true, ccache will use a C/C++ unifier when hashing the preprocessor output if the
634 \fB\-g\fR
635 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
636 \fB__LINE__\fR
637 macro\&. Also note that enabling the unifier implies turning off the direct mode\&.
638 .RE
639 .SH "CACHE SIZE MANAGEMENT"
640 .sp
641 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)\&.
642 .SH "CACHE COMPRESSION"
643 .sp
644 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\&.
645 .SH "HOW CCACHE WORKS"
646 .sp
647 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\&.
648 .sp
649 ccache has two ways of doing the detection:
650 .sp
651 .RS 4
652 .ie n \{\
653 \h'-04'\(bu\h'+03'\c
654 .\}
655 .el \{\
656 .sp -1
657 .IP \(bu 2.3
658 .\}
659 the
660 \fBdirect mode\fR, where ccache hashes the source code and include files directly
661 .RE
662 .sp
663 .RS 4
664 .ie n \{\
665 \h'-04'\(bu\h'+03'\c
666 .\}
667 .el \{\
668 .sp -1
669 .IP \(bu 2.3
670 .\}
671 the
672 \fBpreprocessor mode\fR, where ccache runs the preprocessor on the source code and hashes the result
673 .RE
674 .sp
675 The direct mode is generally faster since running the preprocessor has some overhead\&.
676 .SS "Common hashed information"
677 .sp
678 For both modes, the following information is included in the hash:
679 .sp
680 .RS 4
681 .ie n \{\
682 \h'-04'\(bu\h'+03'\c
683 .\}
684 .el \{\
685 .sp -1
686 .IP \(bu 2.3
687 .\}
688 the extension used by the compiler for a file with preprocessor output (normally
689 \fB\&.i\fR
690 for C code and
691 \fB\&.ii\fR
692 for C++ code)
693 .RE
694 .sp
695 .RS 4
696 .ie n \{\
697 \h'-04'\(bu\h'+03'\c
698 .\}
699 .el \{\
700 .sp -1
701 .IP \(bu 2.3
702 .\}
703 the compiler\(cqs size and modification time (or other compiler\-specific information specified by the
704 \fBcompiler_check\fR
705 setting)
706 .RE
707 .sp
708 .RS 4
709 .ie n \{\
710 \h'-04'\(bu\h'+03'\c
711 .\}
712 .el \{\
713 .sp -1
714 .IP \(bu 2.3
715 .\}
716 the name of the compiler
717 .RE
718 .sp
719 .RS 4
720 .ie n \{\
721 \h'-04'\(bu\h'+03'\c
722 .\}
723 .el \{\
724 .sp -1
725 .IP \(bu 2.3
726 .\}
727 the current directory (if the
728 \fBhash_dir\fR
729 setting is enabled)
730 .RE
731 .sp
732 .RS 4
733 .ie n \{\
734 \h'-04'\(bu\h'+03'\c
735 .\}
736 .el \{\
737 .sp -1
738 .IP \(bu 2.3
739 .\}
740 contents of files specified by the
741 \fBextra_files_to_hash\fR
742 setting (if any)
743 .RE
744 .SS "The direct mode"
745 .sp
746 In the direct mode, the hash is formed of the common information and:
747 .sp
748 .RS 4
749 .ie n \{\
750 \h'-04'\(bu\h'+03'\c
751 .\}
752 .el \{\
753 .sp -1
754 .IP \(bu 2.3
755 .\}
756 the input source file
757 .RE
758 .sp
759 .RS 4
760 .ie n \{\
761 \h'-04'\(bu\h'+03'\c
762 .\}
763 .el \{\
764 .sp -1
765 .IP \(bu 2.3
766 .\}
767 the command line options
768 .RE
769 .sp
770 Based on the hash, a data structure called \(lqmanifest\(rq is looked up in the cache\&. The manifest contains:
771 .sp
772 .RS 4
773 .ie n \{\
774 \h'-04'\(bu\h'+03'\c
775 .\}
776 .el \{\
777 .sp -1
778 .IP \(bu 2.3
779 .\}
780 references to cached compilation results (object file, dependency file, etc) that were produced by previous compilations that matched the hash
781 .RE
782 .sp
783 .RS 4
784 .ie n \{\
785 \h'-04'\(bu\h'+03'\c
786 .\}
787 .el \{\
788 .sp -1
789 .IP \(bu 2.3
790 .\}
791 paths to the include files that were read at the time the compilation results were stored in the cache
792 .RE
793 .sp
794 .RS 4
795 .ie n \{\
796 \h'-04'\(bu\h'+03'\c
797 .\}
798 .el \{\
799 .sp -1
800 .IP \(bu 2.3
801 .\}
802 hash sums of the include files at the time the compilation results were stored in the cache
803 .RE
804 .sp
805 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\&.
806 .sp
807 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\&.
808 .sp
809 The direct mode will be disabled if any of the following holds:
810 .sp
811 .RS 4
812 .ie n \{\
813 \h'-04'\(bu\h'+03'\c
814 .\}
815 .el \{\
816 .sp -1
817 .IP \(bu 2.3
818 .\}
819 the configuration setting
820 \fBdirect_mode\fR
821 is false
822 .RE
823 .sp
824 .RS 4
825 .ie n \{\
826 \h'-04'\(bu\h'+03'\c
827 .\}
828 .el \{\
829 .sp -1
830 .IP \(bu 2.3
831 .\}
832 a modification time of one of the include files is too new (needed to avoid a race condition)
833 .RE
834 .sp
835 .RS 4
836 .ie n \{\
837 \h'-04'\(bu\h'+03'\c
838 .\}
839 .el \{\
840 .sp -1
841 .IP \(bu 2.3
842 .\}
843 the unifier is enabled (the configuration setting
844 \fBunify\fR
845 is true)
846 .RE
847 .sp
848 .RS 4
849 .ie n \{\
850 \h'-04'\(bu\h'+03'\c
851 .\}
852 .el \{\
853 .sp -1
854 .IP \(bu 2.3
855 .\}
856 a compiler option not supported by the direct mode is used:
857 .sp
858 .RS 4
859 .ie n \{\
860 \h'-04'\(bu\h'+03'\c
861 .\}
862 .el \{\
863 .sp -1
864 .IP \(bu 2.3
865 .\}
866 a
867 \fB\-Wp,\fR\fB\fIX\fR\fR
868 compiler option other than
869 \fB\-Wp,\-MD,\fR\fB\fIpath\fR\fR
870 and
871 \fB\-Wp,\-MMD,\fR\fB\fIpath\fR\fR
872 .RE
873 .sp
874 .RS 4
875 .ie n \{\
876 \h'-04'\(bu\h'+03'\c
877 .\}
878 .el \{\
879 .sp -1
880 .IP \(bu 2.3
881 .\}
882 \fB\-Xpreprocessor\fR
883 .RE
884 .RE
885 .sp
886 .RS 4
887 .ie n \{\
888 \h'-04'\(bu\h'+03'\c
889 .\}
890 .el \{\
891 .sp -1
892 .IP \(bu 2.3
893 .\}
894 the string \(lq__TIME__\(rq is present in the source code
895 .RE
896 .SS "The preprocessor mode"
897 .sp
898 In the preprocessor mode, the hash is formed of the common information and:
899 .sp
900 .RS 4
901 .ie n \{\
902 \h'-04'\(bu\h'+03'\c
903 .\}
904 .el \{\
905 .sp -1
906 .IP \(bu 2.3
907 .\}
908 the preprocessor output from running the compiler with
909 \fB\-E\fR
910 .RE
911 .sp
912 .RS 4
913 .ie n \{\
914 \h'-04'\(bu\h'+03'\c
915 .\}
916 .el \{\
917 .sp -1
918 .IP \(bu 2.3
919 .\}
920 the command line options except options that affect include files (\fB\-I\fR,
921 \fB\-include\fR,
922 \fB\-D\fR, etc; the theory is that these options will change the preprocessor output if they have any effect at all)
923 .RE
924 .sp
925 .RS 4
926 .ie n \{\
927 \h'-04'\(bu\h'+03'\c
928 .\}
929 .el \{\
930 .sp -1
931 .IP \(bu 2.3
932 .\}
933 any standard error output generated by the preprocessor
934 .RE
935 .sp
936 Based on the hash, the cached compilation result can be looked up directly in the cache\&.
937 .SH "COMPILING IN DIFFERENT DIRECTORIES"
938 .sp
939 Some information included in the hash that identifies a unique compilation may contain absolute paths:
940 .sp
941 .RS 4
942 .ie n \{\
943 \h'-04'\(bu\h'+03'\c
944 .\}
945 .el \{\
946 .sp -1
947 .IP \(bu 2.3
948 .\}
949 The preprocessed source code may contain absolute paths to include files if the compiler option
950 \fB\-g\fR
951 is used or if absolute paths are given to
952 \fB\-I\fR
953 and similar compiler options\&.
954 .RE
955 .sp
956 .RS 4
957 .ie n \{\
958 \h'-04'\(bu\h'+03'\c
959 .\}
960 .el \{\
961 .sp -1
962 .IP \(bu 2.3
963 .\}
964 Paths specified by compiler options (such as
965 \fB\-I\fR,
966 \fB\-MF\fR, etc) may be absolute\&.
967 .RE
968 .sp
969 .RS 4
970 .ie n \{\
971 \h'-04'\(bu\h'+03'\c
972 .\}
973 .el \{\
974 .sp -1
975 .IP \(bu 2.3
976 .\}
977 The source code file path may be absolute, and that path may substituted for
978 \fB__FILE__\fR
979 macros in the source code or included in warnings emitted to standard error by the preprocessor\&.
980 .RE
981 .sp
982 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\&.)
983 .sp
984 The drawbacks of using a base directory are:
985 .sp
986 .RS 4
987 .ie n \{\
988 \h'-04'\(bu\h'+03'\c
989 .\}
990 .el \{\
991 .sp -1
992 .IP \(bu 2.3
993 .\}
994 If you specify an absolute path to the source code file,
995 \fB__FILE__\fR
996 macros will be expanded to a relative path instead\&.
997 .RE
998 .sp
999 .RS 4
1000 .ie n \{\
1001 \h'-04'\(bu\h'+03'\c
1002 .\}
1003 .el \{\
1004 .sp -1
1005 .IP \(bu 2.3
1006 .\}
1007 If you specify an absolute path to the source code file and compile with
1008 \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\&.
1009 .RE
1010 .SH "PRECOMPILED HEADERS"
1011 .sp
1012 ccache has support for GCC\(cqs precompiled headers\&. However, you have to do some things to make it work properly:
1013 .sp
1014 .RS 4
1015 .ie n \{\
1016 \h'-04'\(bu\h'+03'\c
1017 .\}
1018 .el \{\
1019 .sp -1
1020 .IP \(bu 2.3
1021 .\}
1022 You must set
1023 \fBsloppiness\fR
1024 to
1025 \fBpch_defines,time_macros\fR\&. The reason is that ccache can\(cqt tell whether
1026 \fB__TIME__\fR
1027 or
1028 \fB__DATE__\fR
1029 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\&.
1030 .RE
1031 .sp
1032 .RS 4
1033 .ie n \{\
1034 \h'-04'\(bu\h'+03'\c
1035 .\}
1036 .el \{\
1037 .sp -1
1038 .IP \(bu 2.3
1039 .\}
1040 You must either:
1041 .sp
1042 .RS 4
1043 .ie n \{\
1044 \h'-04'\(bu\h'+03'\c
1045 .\}
1046 .el \{\
1047 .sp -1
1048 .IP \(bu 2.3
1049 .\}
1050 use the
1051 \fB\-include\fR
1052 compiler option to include the precompiled header (i\&.e\&., don\(cqt use
1053 \fB#include\fR
1054 in the source code to include the header); or
1055 .RE
1056 .sp
1057 .RS 4
1058 .ie n \{\
1059 \h'-04'\(bu\h'+03'\c
1060 .\}
1061 .el \{\
1062 .sp -1
1063 .IP \(bu 2.3
1064 .\}
1065 (for the Clang compiler) use the
1066 \fB\-include\-pch\fR
1067 compiler option to include the PCH file generated from the precompiled header; or
1068 .RE
1069 .sp
1070 .RS 4
1071 .ie n \{\
1072 \h'-04'\(bu\h'+03'\c
1073 .\}
1074 .el \{\
1075 .sp -1
1076 .IP \(bu 2.3
1077 .\}
1078 add the
1079 \fB\-fpch\-preprocess\fR
1080 compiler option when compiling\&.
1081 .RE
1082 .sp
1083 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)\&.
1084 .RE
1085 .SH "SHARING A CACHE"
1086 .sp
1087 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:
1088 .sp
1089 .RS 4
1090 .ie n \{\
1091 \h'-04'\(bu\h'+03'\c
1092 .\}
1093 .el \{\
1094 .sp -1
1095 .IP \(bu 2.3
1096 .\}
1097 Use the same cache directory\&.
1098 .RE
1099 .sp
1100 .RS 4
1101 .ie n \{\
1102 \h'-04'\(bu\h'+03'\c
1103 .\}
1104 .el \{\
1105 .sp -1
1106 .IP \(bu 2.3
1107 .\}
1108 Make sure that the configuration setting
1109 \fBhard_link\fR
1110 is false (which is the default)\&.
1111 .RE
1112 .sp
1113 .RS 4
1114 .ie n \{\
1115 \h'-04'\(bu\h'+03'\c
1116 .\}
1117 .el \{\
1118 .sp -1
1119 .IP \(bu 2.3
1120 .\}
1121 Make sure that all users are in the same group\&.
1122 .RE
1123 .sp
1124 .RS 4
1125 .ie n \{\
1126 \h'-04'\(bu\h'+03'\c
1127 .\}
1128 .el \{\
1129 .sp -1
1130 .IP \(bu 2.3
1131 .\}
1132 Set the configuration setting
1133 \fBumask\fR
1134 to 002\&. This ensures that cached files are accessible to everyone in the group\&.
1135 .RE
1136 .sp
1137 .RS 4
1138 .ie n \{\
1139 \h'-04'\(bu\h'+03'\c
1140 .\}
1141 .el \{\
1142 .sp -1
1143 .IP \(bu 2.3
1144 .\}
1145 Make sure that all users have write permission in the entire cache directory (and that you trust all users of the shared cache)\&.
1146 .RE
1147 .sp
1148 .RS 4
1149 .ie n \{\
1150 \h'-04'\(bu\h'+03'\c
1151 .\}
1152 .el \{\
1153 .sp -1
1154 .IP \(bu 2.3
1155 .\}
1156 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 command \(lqfind $CCACHE_DIR \-type d | xargs chmod g+s\(rq might be useful for this\&.
1157 .RE
1158 .sp
1159 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\&.
1160 .sp
1161 You may also want to make sure that a base directory is set appropriately, as discussed in a previous section\&.
1162 .SH "SHARING A CACHE ON NFS"
1163 .sp
1164 It is possible to put the cache directory on an NFS filesystem (or similar filesystems), but keep in mind that:
1165 .sp
1166 .RS 4
1167 .ie n \{\
1168 \h'-04'\(bu\h'+03'\c
1169 .\}
1170 .el \{\
1171 .sp -1
1172 .IP \(bu 2.3
1173 .\}
1174 Having the cache on NFS may slow down compilation\&. Make sure to do some benchmarking to see if it\(cqs worth it\&.
1175 .RE
1176 .sp
1177 .RS 4
1178 .ie n \{\
1179 \h'-04'\(bu\h'+03'\c
1180 .\}
1181 .el \{\
1182 .sp -1
1183 .IP \(bu 2.3
1184 .\}
1185 ccache hasn\(cqt been tested very thoroughly on NFS\&.
1186 .RE
1187 .sp
1188 A tip is to set \fBtemporary_dir\fR to a directory on the local host to avoid NFS traffic for temporary files\&.
1189 .SH "USING CCACHE WITH OTHER COMPILER WRAPPERS"
1190 .sp
1191 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\&.
1192 .sp
1193 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:
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 Compiler upgrades will not be detected properly\&.
1204 .RE
1205 .sp
1206 .RS 4
1207 .ie n \{\
1208 \h'-04'\(bu\h'+03'\c
1209 .\}
1210 .el \{\
1211 .sp -1
1212 .IP \(bu 2.3
1213 .\}
1214 The cached results will not be shared between compilations with and without the other wrapper\&.
1215 .RE
1216 .sp
1217 Another minor thing is that if \fBprefix_command\fR is used, ccache will not invoke the other wrapper when running the preprocessor, which increase performance\&.
1218 .SH "BUGS"
1219 .sp
1220 .RS 4
1221 .ie n \{\
1222 \h'-04'\(bu\h'+03'\c
1223 .\}
1224 .el \{\
1225 .sp -1
1226 .IP \(bu 2.3
1227 .\}
1228 ccache doesn\(cqt handle the GNU Assembler\(cqs
1229 \fB\&.incbin\fR
1230 directive correctly\&. This directive can be embedded in the source code inside an
1231 \fB\fIasm\fR\fR
1232 statement in order to include a file verbatim in the object file\&. If the included file is modified, ccache doesn\(cqt pick up the change since the inclusion isn\(cqt done by the preprocessor\&. A workaround of this problem is to set
1233 \fBextra_files_to_hash\fR
1234 to the path of the included file\&.
1235 .RE
1236 .sp
1237 .RS 4
1238 .ie n \{\
1239 \h'-04'\(bu\h'+03'\c
1240 .\}
1241 .el \{\
1242 .sp -1
1243 .IP \(bu 2.3
1244 .\}
1245 The direct mode fails to pick up new header files in some rare scenarios\&. See
1246 THE DIRECT MODE
1247 above\&.
1248 .RE
1249 .SH "TROUBLESHOOTING"
1250 .SS "General"
1251 .sp
1252 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\&.
1253 .SS "Performance"
1254 .sp
1255 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\&.
1256 .sp
1257 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 preferrable\&.
1258 .sp
1259 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:
1260 .sp
1261 .RS 4
1262 .ie n \{\
1263 \h'-04'\(bu\h'+03'\c
1264 .\}
1265 .el \{\
1266 .sp -1
1267 .IP \(bu 2.3
1268 .\}
1269 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:
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 The source code has been modified in such a way that the preprocessor output is not affected\&.
1280 .RE
1281 .sp
1282 .RS 4
1283 .ie n \{\
1284 \h'-04'\(bu\h'+03'\c
1285 .\}
1286 .el \{\
1287 .sp -1
1288 .IP \(bu 2.3
1289 .\}
1290 Compiler arguments that are hashed in the direct mode but not in the preprocessor mode have changed (\fB\-I\fR,
1291 \fB\-include\fR,
1292 \fB\-D\fR, etc) and they didn\(cqt affect the preprocessor output\&.
1293 .RE
1294 .sp
1295 .RS 4
1296 .ie n \{\
1297 \h'-04'\(bu\h'+03'\c
1298 .\}
1299 .el \{\
1300 .sp -1
1301 .IP \(bu 2.3
1302 .\}
1303 The compiler option
1304 \fB\-Xpreprocessor\fR
1305 or
1306 \fB\-Wp,\fR\fB\fIX\fR\fR
1307 (except
1308 \fB\-Wp,\-MD,\fR\fB\fIpath\fR\fR
1309 and
1310 \fBWp,\-MMD,\fR\fB\fIpath\fR\fR) is used\&.
1311 .RE
1312 .sp
1313 .RS 4
1314 .ie n \{\
1315 \h'-04'\(bu\h'+03'\c
1316 .\}
1317 .el \{\
1318 .sp -1
1319 .IP \(bu 2.3
1320 .\}
1321 This was the first compilation with a new value of the base directory setting\&.
1322 .RE
1323 .sp
1324 .RS 4
1325 .ie n \{\
1326 \h'-04'\(bu\h'+03'\c
1327 .\}
1328 .el \{\
1329 .sp -1
1330 .IP \(bu 2.3
1331 .\}
1332 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
1333 \fBsloppiness\fR
1334 to
1335 \fBinclude_file_mtime\fR
1336 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\&.)
1337 .RE
1338 .sp
1339 .RS 4
1340 .ie n \{\
1341 \h'-04'\(bu\h'+03'\c
1342 .\}
1343 .el \{\
1344 .sp -1
1345 .IP \(bu 2.3
1346 .\}
1347 The
1348 \fB__TIME__\fR
1349 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
1350 \fB__TIME__\fR
1351 macro
1352 \fImay\fR
1353 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
1354 \fB__TIME__\fR
1355 isn\(cqt used in practise, or don\(cqt care if ccache produces objects where
1356 \fB__TIME__\fR
1357 is expanded to something in the past, you can set
1358 \fBsloppiness\fR
1359 to
1360 \fBtime_macros\fR\&.
1361 .RE
1362 .sp
1363 .RS 4
1364 .ie n \{\
1365 \h'-04'\(bu\h'+03'\c
1366 .\}
1367 .el \{\
1368 .sp -1
1369 .IP \(bu 2.3
1370 .\}
1371 The
1372 \fB__DATE__\fR
1373 preprocessor macro is (potentially) being used and the date has changed\&. This is similar to how
1374 \fB__TIME__\fR
1375 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
1376 \fB__DATE__\fR
1377 macro affects the output\&. If you know that
1378 \fB__DATE__\fR
1379 isn\(cqt used in practise, or don\(cqt care if ccache produces objects where
1380 \fB__DATE__\fR
1381 is expanded to something in the past, you can set
1382 \fBsloppiness\fR
1383 to
1384 \fBtime_macros\fR\&.
1385 .RE
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 The
1396 \fB__FILE__\fR
1397 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
1398 \fB__FILE__\fR
1399 macro affects the output\&. If you know that
1400 \fB__FILE__\fR
1401 isn\(cqt used in practise, or don\(cqt care if ccache produces objects where
1402 \fB__FILE__\fR
1403 is expanded to the wrong path, you can set
1404 \fBsloppiness\fR
1405 to
1406 \fBfile_macro\fR\&.
1407 .RE
1408 .RE
1409 .sp
1410 .RS 4
1411 .ie n \{\
1412 \h'-04'\(bu\h'+03'\c
1413 .\}
1414 .el \{\
1415 .sp -1
1416 .IP \(bu 2.3
1417 .\}
1418 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
1419 \fB__TIME__\fR
1420 or
1421 \fB__DATE__\fR
1422 macros, or use of automatically generated code that contains a timestamp, build counter or other volatile information\&.
1423 .RE
1424 .sp
1425 .RS 4
1426 .ie n \{\
1427 \h'-04'\(bu\h'+03'\c
1428 .\}
1429 .el \{\
1430 .sp -1
1431 .IP \(bu 2.3
1432 .\}
1433 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\&.
1434 .RE
1435 .sp
1436 .RS 4
1437 .ie n \{\
1438 \h'-04'\(bu\h'+03'\c
1439 .\}
1440 .el \{\
1441 .sp -1
1442 .IP \(bu 2.3
1443 .\}
1444 If \(lqunsupported compiler option\(rq has been incremented, enable debug logging and check which option was rejected\&.
1445 .RE
1446 .sp
1447 .RS 4
1448 .ie n \{\
1449 \h'-04'\(bu\h'+03'\c
1450 .\}
1451 .el \{\
1452 .sp -1
1453 .IP \(bu 2.3
1454 .\}
1455 If \(lqpreprocessor error\(rq has been incremented, one possible reason is that precompiled headers are being used\&. See
1456 PRECOMPILED HEADERS
1457 for how to remedy this\&.
1458 .RE
1459 .sp
1460 .RS 4
1461 .ie n \{\
1462 \h'-04'\(bu\h'+03'\c
1463 .\}
1464 .el \{\
1465 .sp -1
1466 .IP \(bu 2.3
1467 .\}
1468 If \(lqcan\(cqt use precompiled header\(rq has been incremented, see
1469 PRECOMPILED HEADERS\&.
1470 .RE
1471 .SS "Errors when compiling with ccache"
1472 .sp
1473 If compilation doesn\(cqt work with ccache, but it works without it, one possible reason is that the compiler can\(cqt compile preprocessed output correctly\&. A workaround that may work is to enable \fBrun_second_cpp\fR*\&. This will make cache misses slower, though, so it is better to find and fix the root cause\&.
1474 .SS "Corrupt object files"
1475 .sp
1476 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:
1477 .sp
1478 .RS 4
1479 .ie n \{\
1480 \h'-04' 1.\h'+01'\c
1481 .\}
1482 .el \{\
1483 .sp -1
1484 .IP "  1." 4.2
1485 .\}
1486 Build so that the bad object file ends up in the build tree\&.
1487 .RE
1488 .sp
1489 .RS 4
1490 .ie n \{\
1491 \h'-04' 2.\h'+01'\c
1492 .\}
1493 .el \{\
1494 .sp -1
1495 .IP "  2." 4.2
1496 .\}
1497 Remove the bad object file from the build tree\&.
1498 .RE
1499 .sp
1500 .RS 4
1501 .ie n \{\
1502 \h'-04' 3.\h'+01'\c
1503 .\}
1504 .el \{\
1505 .sp -1
1506 .IP "  3." 4.2
1507 .\}
1508 Rebuild with
1509 \fBCCACHE_RECACHE\fR
1510 set\&.
1511 .RE
1512 .sp
1513 An alternative is to clear the whole cache with \fBccache \-C\fR if you don\(cqt mind losing other cached results\&.
1514 .sp
1515 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\&.
1516 .SH "MORE INFORMATION"
1517 .sp
1518 Credits, mailing list information, bug reporting instructions, source code, etc, can be found on ccache\(cqs web site: http://ccache\&.samba\&.org\&.
1519 .SH "AUTHOR"
1520 .sp
1521 ccache was originally written by Andrew Tridgell and is currently developed and maintained by Joel Rosdahl\&. See AUTHORS\&.txt or AUTHORS\&.html and http://ccache\&.samba\&.org/credits\&.html for a list of contributors\&.