Imported Upstream version 3.2.1
[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: 12/10/2014
6 .\"    Manual: ccache Manual
7 .\"    Source: ccache 3.2.1
8 .\"  Language: English
9 .\"
10 .TH "CCACHE" "1" "12/10/2014" "ccache 3\&.2\&.1" "ccache Manual"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18 .ie \n(.g .ds Aq \(aq
19 .el       .ds Aq '
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
24 .nh
25 .\" disable justification (adjust text to left margin only)
26 .ad l
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
30 .SH "NAME"
31 ccache \- a fast C/C++ compiler cache
32 .SH "SYNOPSIS"
33 .sp
34 .nf
35 \fBccache\fR [\fIoptions\fR]
36 \fBccache\fR \fIcompiler\fR [\fIcompiler options\fR]
37 \fIcompiler\fR [\fIcompiler options\fR]                   (via symbolic link)
38 .fi
39 .SH "DESCRIPTION"
40 .sp
41 ccache is a compiler cache\&. It speeds up recompilation by caching the result of previous compilations and detecting when the same compilation is being done again\&. Supported languages are C, C++, Objective\-C and Objective\-C++\&.
42 .sp
43 ccache has been carefully written to always produce exactly the same compiler output that you would get without the cache\&. The only way you should be able to tell that you are using ccache is the speed\&. Currently known exceptions to this goal are listed under 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\&. Boolean options are indicated with \(lq[boolean]\(rq
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 \fIa command string\fR
402 .RS 4
403 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
404 \fB%compiler%\fR
405 will be replaced with the path to the compiler\&. Several commands can be specified with semicolon as separator\&. Examples:
406 .sp
407 .RS 4
408 .ie n \{\
409 \h'-04'\(bu\h'+03'\c
410 .\}
411 .el \{\
412 .sp -1
413 .IP \(bu 2.3
414 .\}
415 %compiler% \-v
416 .RE
417 .sp
418 .RS 4
419 .ie n \{\
420 \h'-04'\(bu\h'+03'\c
421 .\}
422 .el \{\
423 .sp -1
424 .IP \(bu 2.3
425 .\}
426 %compiler% \-dumpmachine; %compiler% \-dumpversion
427 .RE
428 .sp
429 You should make sure that the specified command is as fast as possible since it will be run once for each ccache invocation\&.
430 .sp
431 Identifying the compiler using a command is useful if you want to avoid cache misses when the compiler has been rebuilt but not changed\&.
432 .sp
433 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
434 \fBmtime\fR
435 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
436 \fBmtime\fR
437 method in combination with the
438 \fBprefix_command\fR
439 setting if possible\&. See
440 USING CCACHE WITH OTHER COMPILER WRAPPERS\&.
441 .RE
442 .RE
443 .PP
444 \fBcompression\fR (\fBCCACHE_COMPRESS\fR) [boolean]
445 .RS 4
446 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\&.
447 .RE
448 .PP
449 \fBcompression_level\fR (\fBCCACHE_COMPRESSLEVEL\fR)
450 .RS 4
451 This setting determines the level at which ccache will compress object files\&. It only has effect if
452 \fBcompression\fR
453 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)\&.
454 .RE
455 .PP
456 \fBcpp_extension\fR (\fBCCACHE_EXTENSION\fR)
457 .RS 4
458 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
459 \fBi\fR\&.
460 .RE
461 .PP
462 \fBdirect_mode\fR (\fBCCACHE_DIRECT\fR) [boolean]
463 .RS 4
464 If true, the direct mode will be used\&. The default is true\&. See
465 THE DIRECT MODE\&.
466 .RE
467 .PP
468 \fBdisable\fR (\fBCCACHE_DISABLE\fR) [boolean]
469 .RS 4
470 When true, ccache will just call the real compiler, bypassing the cache completely\&. The default is false\&.
471 .RE
472 .PP
473 \fBextra_files_to_hash\fR (\fBCCACHE_EXTRAFILES\fR)
474 .RS 4
475 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\&.
476 .RE
477 .PP
478 \fBhard_link\fR (\fBCCACHE_HARDLINK\fR) [boolean]
479 .RS 4
480 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\&.
481 .RE
482 .PP
483 \fBhash_dir\fR (\fBCCACHE_HASHDIR\fR) [boolean]
484 .RS 4
485 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 a 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\&.
486 .RE
487 .PP
488 \fBlog_file\fR (\fBCCACHE_LOGFILE\fR)
489 .RS 4
490 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\&.
491 .RE
492 .PP
493 \fBmax_files\fR (\fBCCACHE_MAXFILES\fR)
494 .RS 4
495 This option specifies the maximum number of files to keep in the cache\&. Use 0 for no limit (which is the default)\&.
496 .RE
497 .PP
498 \fBmax_size\fR (\fBCCACHE_MAXSIZE\fR)
499 .RS 4
500 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"\&.
501 .RE
502 .PP
503 \fBpath\fR (\fBCCACHE_PATH\fR)
504 .RS 4
505 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
506 \fBPATH\fR
507 that isn\(cqt a symbolic link to ccache itself\&.
508 .RE
509 .PP
510 \fBprefix_command\fR (\fBCCACHE_PREFIX\fR)
511 .RS 4
512 This option adds a list of prefixes (separated by space) to the command line that ccache uses when invoking the compiler\&. See also
513 USING CCACHE WITH OTHER COMPILER WRAPPERS\&.
514 .RE
515 .PP
516 \fBread_only\fR (\fBCCACHE_READONLY\fR) [boolean]
517 .RS 4
518 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
519 \fBtemporary_dir\fR
520 as otherwise ccache will fail to create temporary files\&.
521 .RE
522 .PP
523 \fBread_only_direct\fR (\fBCCACHE_READONLY_DIRECT\fR) [boolean]
524 .RS 4
525 Just like
526 \fBread_only\fR
527 except that ccache will only try to retrieve results from the cache using the direct mode, not the preprocessor mode\&. See documentation for
528 \fBread_only\fR
529 regarding using a read\-only ccache directory\&.
530 .RE
531 .PP
532 \fBrecache\fR (\fBCCACHE_RECACHE\fR) [boolean]
533 .RS 4
534 If true, ccache will not use any previously stored result\&. New results will still be cached, possibly overwriting any pre\-existing results\&.
535 .RE
536 .PP
537 \fBrun_second_cpp\fR (\fBCCACHE_CPP2\fR) [boolean]
538 .RS 4
539 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\&.
540 .RE
541 .PP
542 \fBsloppiness\fR (\fBCCACHE_SLOPPINESS\fR)
543 .RS 4
544 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:
545 .PP
546 \fBfile_macro\fR
547 .RS 4
548 Ignore
549 \fB__FILE__\fR
550 being present in the source\&.
551 .RE
552 .PP
553 \fBfile_stat_matches\fR
554 .RS 4
555 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\&.
556 .RE
557 .PP
558 \fBinclude_file_ctime\fR
559 .RS 4
560 By default, ccache also will not cache a file if it includes a header whose ctime is too new\&. This option disables that check\&.
561 .RE
562 .PP
563 \fBinclude_file_mtime\fR
564 .RS 4
565 By default, ccache will not cache a file if it includes a header whose mtime is too new\&. This option disables that check\&.
566 .RE
567 .PP
568 \fBpch_defines\fR
569 .RS 4
570 Be sloppy about #defines when precompiling a header file\&. See
571 PRECOMPILED HEADERS
572 for more information\&.
573 .RE
574 .PP
575 \fBtime_macros\fR
576 .RS 4
577 Ignore
578 \fB__DATE__\fR
579 and
580 \fB__TIME__\fR
581 being present in the source code\&.
582 .RE
583 .sp
584 See the discussion under
585 TROUBLESHOOTING
586 for more information\&.
587 .RE
588 .PP
589 \fBstats\fR (\fBCCACHE_STATS\fR) [boolean]
590 .RS 4
591 If true, ccache will update the statistics counters on each compilation\&. The default is true\&.
592 .RE
593 .PP
594 \fBtemporary_dir\fR (\fBCCACHE_TEMPDIR\fR)
595 .RS 4
596 This setting specifies where ccache will put temporary files\&. The default is
597 \fB<cache_dir>/tmp\fR\&.
598 .if n \{\
599 .sp
600 .\}
601 .RS 4
602 .it 1 an-trap
603 .nr an-no-space-flag 1
604 .nr an-break-flag 1
605 .br
606 .ps +1
607 \fBNote\fR
608 .ps -1
609 .br
610 In previous versions of ccache,
611 \fBCCACHE_TEMPDIR\fR
612 had to be on the same filesystem as the
613 \fBCCACHE_DIR\fR
614 path, but this requirement has been relaxed\&.)
615 .sp .5v
616 .RE
617 .RE
618 .PP
619 \fBumask\fR (\fBCCACHE_UMASK\fR)
620 .RS 4
621 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\&.
622 .RE
623 .PP
624 \fBunify\fR (\fBCCACHE_UNIFY\fR) [boolean]
625 .RS 4
626 If true, ccache will use a C/C++ unifier when hashing the preprocessor output if the
627 \fB\-g\fR
628 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
629 \fB__LINE__\fR
630 macro\&. Also note that enabling the unifier implies turning off the direct mode\&.
631 .RE
632 .SH "CACHE SIZE MANAGEMENT"
633 .sp
634 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)\&.
635 .SH "CACHE COMPRESSION"
636 .sp
637 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\&.
638 .SH "HOW CCACHE WORKS"
639 .sp
640 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\&.
641 .sp
642 ccache has two ways of doing the detection:
643 .sp
644 .RS 4
645 .ie n \{\
646 \h'-04'\(bu\h'+03'\c
647 .\}
648 .el \{\
649 .sp -1
650 .IP \(bu 2.3
651 .\}
652 the
653 \fBdirect mode\fR, where ccache hashes the source code and include files directly
654 .RE
655 .sp
656 .RS 4
657 .ie n \{\
658 \h'-04'\(bu\h'+03'\c
659 .\}
660 .el \{\
661 .sp -1
662 .IP \(bu 2.3
663 .\}
664 the
665 \fBpreprocessor mode\fR, where ccache runs the preprocessor on the source code and hashes the result
666 .RE
667 .sp
668 The direct mode is generally faster since running the preprocessor has some overhead\&.
669 .SS "Common hashed information"
670 .sp
671 For both modes, the following information is included in the hash:
672 .sp
673 .RS 4
674 .ie n \{\
675 \h'-04'\(bu\h'+03'\c
676 .\}
677 .el \{\
678 .sp -1
679 .IP \(bu 2.3
680 .\}
681 the extension used by the compiler for a file with preprocessor output (normally
682 \fB\&.i\fR
683 for C code and
684 \fB\&.ii\fR
685 for C++ code)
686 .RE
687 .sp
688 .RS 4
689 .ie n \{\
690 \h'-04'\(bu\h'+03'\c
691 .\}
692 .el \{\
693 .sp -1
694 .IP \(bu 2.3
695 .\}
696 the compiler\(cqs size and modification time (or other compiler\-specific information specified by the
697 \fBcompiler_check\fR
698 setting)
699 .RE
700 .sp
701 .RS 4
702 .ie n \{\
703 \h'-04'\(bu\h'+03'\c
704 .\}
705 .el \{\
706 .sp -1
707 .IP \(bu 2.3
708 .\}
709 the name of the compiler
710 .RE
711 .sp
712 .RS 4
713 .ie n \{\
714 \h'-04'\(bu\h'+03'\c
715 .\}
716 .el \{\
717 .sp -1
718 .IP \(bu 2.3
719 .\}
720 the current directory (if the
721 \fBhash_dir\fR
722 setting is enabled)
723 .RE
724 .sp
725 .RS 4
726 .ie n \{\
727 \h'-04'\(bu\h'+03'\c
728 .\}
729 .el \{\
730 .sp -1
731 .IP \(bu 2.3
732 .\}
733 contents of files specified by the
734 \fBextra_files_to_hash\fR
735 setting (if any)
736 .RE
737 .SS "The direct mode"
738 .sp
739 In the direct mode, the hash is formed of the common information and:
740 .sp
741 .RS 4
742 .ie n \{\
743 \h'-04'\(bu\h'+03'\c
744 .\}
745 .el \{\
746 .sp -1
747 .IP \(bu 2.3
748 .\}
749 the input source file
750 .RE
751 .sp
752 .RS 4
753 .ie n \{\
754 \h'-04'\(bu\h'+03'\c
755 .\}
756 .el \{\
757 .sp -1
758 .IP \(bu 2.3
759 .\}
760 the command line options
761 .RE
762 .sp
763 Based on the hash, a data structure called \(lqmanifest\(rq is looked up in the cache\&. The manifest contains:
764 .sp
765 .RS 4
766 .ie n \{\
767 \h'-04'\(bu\h'+03'\c
768 .\}
769 .el \{\
770 .sp -1
771 .IP \(bu 2.3
772 .\}
773 references to cached compilation results (object file, dependency file, etc) that were produced by previous compilations that matched the hash
774 .RE
775 .sp
776 .RS 4
777 .ie n \{\
778 \h'-04'\(bu\h'+03'\c
779 .\}
780 .el \{\
781 .sp -1
782 .IP \(bu 2.3
783 .\}
784 paths to the include files that were read at the time the compilation results were stored in the cache
785 .RE
786 .sp
787 .RS 4
788 .ie n \{\
789 \h'-04'\(bu\h'+03'\c
790 .\}
791 .el \{\
792 .sp -1
793 .IP \(bu 2.3
794 .\}
795 hash sums of the include files at the time the compilation results were stored in the cache
796 .RE
797 .sp
798 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\&.
799 .sp
800 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\&.
801 .sp
802 The direct mode will be disabled if any of the following holds:
803 .sp
804 .RS 4
805 .ie n \{\
806 \h'-04'\(bu\h'+03'\c
807 .\}
808 .el \{\
809 .sp -1
810 .IP \(bu 2.3
811 .\}
812 the configuration setting
813 \fBdirect_mode\fR
814 is false
815 .RE
816 .sp
817 .RS 4
818 .ie n \{\
819 \h'-04'\(bu\h'+03'\c
820 .\}
821 .el \{\
822 .sp -1
823 .IP \(bu 2.3
824 .\}
825 a modification time of one of the include files is too new (needed to avoid a race condition)
826 .RE
827 .sp
828 .RS 4
829 .ie n \{\
830 \h'-04'\(bu\h'+03'\c
831 .\}
832 .el \{\
833 .sp -1
834 .IP \(bu 2.3
835 .\}
836 the unifier is enabled (the configuration setting
837 \fBunify\fR
838 is true)
839 .RE
840 .sp
841 .RS 4
842 .ie n \{\
843 \h'-04'\(bu\h'+03'\c
844 .\}
845 .el \{\
846 .sp -1
847 .IP \(bu 2.3
848 .\}
849 a compiler option not supported by the direct mode is used:
850 .sp
851 .RS 4
852 .ie n \{\
853 \h'-04'\(bu\h'+03'\c
854 .\}
855 .el \{\
856 .sp -1
857 .IP \(bu 2.3
858 .\}
859 a
860 \fB\-Wp,\fR\fB\fIX\fR\fR
861 compiler option other than
862 \fB\-Wp,\-MD,\fR\fB\fIpath\fR\fR
863 and
864 \fB\-Wp,\-MMD,\fR\fB\fIpath\fR\fR
865 .RE
866 .sp
867 .RS 4
868 .ie n \{\
869 \h'-04'\(bu\h'+03'\c
870 .\}
871 .el \{\
872 .sp -1
873 .IP \(bu 2.3
874 .\}
875 \fB\-Xpreprocessor\fR
876 .RE
877 .RE
878 .sp
879 .RS 4
880 .ie n \{\
881 \h'-04'\(bu\h'+03'\c
882 .\}
883 .el \{\
884 .sp -1
885 .IP \(bu 2.3
886 .\}
887 the string \(lq__TIME__\(rq is present in the source code
888 .RE
889 .SS "The preprocessor mode"
890 .sp
891 In the preprocessor mode, the hash is formed of the common information and:
892 .sp
893 .RS 4
894 .ie n \{\
895 \h'-04'\(bu\h'+03'\c
896 .\}
897 .el \{\
898 .sp -1
899 .IP \(bu 2.3
900 .\}
901 the preprocessor output from running the compiler with
902 \fB\-E\fR
903 .RE
904 .sp
905 .RS 4
906 .ie n \{\
907 \h'-04'\(bu\h'+03'\c
908 .\}
909 .el \{\
910 .sp -1
911 .IP \(bu 2.3
912 .\}
913 the command line options except options that affect include files (\fB\-I\fR,
914 \fB\-include\fR,
915 \fB\-D\fR, etc; the theory is that these options will change the preprocessor output if they have any effect at all)
916 .RE
917 .sp
918 .RS 4
919 .ie n \{\
920 \h'-04'\(bu\h'+03'\c
921 .\}
922 .el \{\
923 .sp -1
924 .IP \(bu 2.3
925 .\}
926 any standard error output generated by the preprocessor
927 .RE
928 .sp
929 Based on the hash, the cached compilation result can be looked up directly in the cache\&.
930 .SH "COMPILING IN DIFFERENT DIRECTORIES"
931 .sp
932 Some information included in the hash that identifies a unique compilation may contain absolute paths:
933 .sp
934 .RS 4
935 .ie n \{\
936 \h'-04'\(bu\h'+03'\c
937 .\}
938 .el \{\
939 .sp -1
940 .IP \(bu 2.3
941 .\}
942 The preprocessed source code may contain absolute paths to include files if the compiler option
943 \fB\-g\fR
944 is used or if absolute paths are given to
945 \fB\-I\fR
946 and similar compiler options\&.
947 .RE
948 .sp
949 .RS 4
950 .ie n \{\
951 \h'-04'\(bu\h'+03'\c
952 .\}
953 .el \{\
954 .sp -1
955 .IP \(bu 2.3
956 .\}
957 Paths specified by compiler options (such as
958 \fB\-I\fR,
959 \fB\-MF\fR, etc) may be absolute\&.
960 .RE
961 .sp
962 .RS 4
963 .ie n \{\
964 \h'-04'\(bu\h'+03'\c
965 .\}
966 .el \{\
967 .sp -1
968 .IP \(bu 2.3
969 .\}
970 The source code file path may be absolute, and that path may substituted for
971 \fB__FILE__\fR
972 macros in the source code or included in warnings emitted to standard error by the preprocessor\&.
973 .RE
974 .sp
975 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\&.)
976 .sp
977 The drawbacks of using a base directory are:
978 .sp
979 .RS 4
980 .ie n \{\
981 \h'-04'\(bu\h'+03'\c
982 .\}
983 .el \{\
984 .sp -1
985 .IP \(bu 2.3
986 .\}
987 If you specify an absolute path to the source code file,
988 \fB__FILE__\fR
989 macros will be expanded to a relative path instead\&.
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 If you specify an absolute path to the source code file and compile with
1001 \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\&.
1002 .RE
1003 .SH "PRECOMPILED HEADERS"
1004 .sp
1005 ccache has support for GCC\(cqs precompiled headers\&. However, you have to do some things to make it work properly:
1006 .sp
1007 .RS 4
1008 .ie n \{\
1009 \h'-04'\(bu\h'+03'\c
1010 .\}
1011 .el \{\
1012 .sp -1
1013 .IP \(bu 2.3
1014 .\}
1015 You must set
1016 \fBsloppiness\fR
1017 to
1018 \fBpch_defines,time_macros\fR\&. The reason is that ccache can\(cqt tell whether
1019 \fB__TIME__\fR
1020 or
1021 \fB__DATE__\fR
1022 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\&.
1023 .RE
1024 .sp
1025 .RS 4
1026 .ie n \{\
1027 \h'-04'\(bu\h'+03'\c
1028 .\}
1029 .el \{\
1030 .sp -1
1031 .IP \(bu 2.3
1032 .\}
1033 You must either:
1034 .sp
1035 .RS 4
1036 .ie n \{\
1037 \h'-04'\(bu\h'+03'\c
1038 .\}
1039 .el \{\
1040 .sp -1
1041 .IP \(bu 2.3
1042 .\}
1043 use the
1044 \fB\-include\fR
1045 compiler option to include the precompiled header (i\&.e\&., don\(cqt use
1046 \fB#include\fR
1047 in the source code to include the header); or
1048 .RE
1049 .sp
1050 .RS 4
1051 .ie n \{\
1052 \h'-04'\(bu\h'+03'\c
1053 .\}
1054 .el \{\
1055 .sp -1
1056 .IP \(bu 2.3
1057 .\}
1058 (for the Clang compiler) use the
1059 \fB\-include\-pch\fR
1060 compiler option to include the PCH file generated from the precompiled header; or
1061 .RE
1062 .sp
1063 .RS 4
1064 .ie n \{\
1065 \h'-04'\(bu\h'+03'\c
1066 .\}
1067 .el \{\
1068 .sp -1
1069 .IP \(bu 2.3
1070 .\}
1071 add the
1072 \fB\-fpch\-preprocess\fR
1073 compiler option when compiling\&.
1074 .RE
1075 .sp
1076 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)\&.
1077 .RE
1078 .SH "SHARING A CACHE"
1079 .sp
1080 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:
1081 .sp
1082 .RS 4
1083 .ie n \{\
1084 \h'-04'\(bu\h'+03'\c
1085 .\}
1086 .el \{\
1087 .sp -1
1088 .IP \(bu 2.3
1089 .\}
1090 Use the same cache directory\&.
1091 .RE
1092 .sp
1093 .RS 4
1094 .ie n \{\
1095 \h'-04'\(bu\h'+03'\c
1096 .\}
1097 .el \{\
1098 .sp -1
1099 .IP \(bu 2.3
1100 .\}
1101 Make sure that the configuration setting
1102 \fBhard_link\fR
1103 is false (which is the default)\&.
1104 .RE
1105 .sp
1106 .RS 4
1107 .ie n \{\
1108 \h'-04'\(bu\h'+03'\c
1109 .\}
1110 .el \{\
1111 .sp -1
1112 .IP \(bu 2.3
1113 .\}
1114 Make sure that all users are in the same group\&.
1115 .RE
1116 .sp
1117 .RS 4
1118 .ie n \{\
1119 \h'-04'\(bu\h'+03'\c
1120 .\}
1121 .el \{\
1122 .sp -1
1123 .IP \(bu 2.3
1124 .\}
1125 Set the configuration setting
1126 \fBumask\fR
1127 to 002\&. This ensures that cached files are accessible to everyone in the group\&.
1128 .RE
1129 .sp
1130 .RS 4
1131 .ie n \{\
1132 \h'-04'\(bu\h'+03'\c
1133 .\}
1134 .el \{\
1135 .sp -1
1136 .IP \(bu 2.3
1137 .\}
1138 Make sure that all users have write permission in the entire cache directory (and that you trust all users of the shared cache)\&.
1139 .RE
1140 .sp
1141 .RS 4
1142 .ie n \{\
1143 \h'-04'\(bu\h'+03'\c
1144 .\}
1145 .el \{\
1146 .sp -1
1147 .IP \(bu 2.3
1148 .\}
1149 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\&.
1150 .RE
1151 .sp
1152 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\&.
1153 .sp
1154 You may also want to make sure that a base directory is set appropriately, as discussed in a previous section\&.
1155 .SH "SHARING A CACHE ON NFS"
1156 .sp
1157 It is possible to put the cache directory on an NFS filesystem (or similar filesystems), but keep in mind that:
1158 .sp
1159 .RS 4
1160 .ie n \{\
1161 \h'-04'\(bu\h'+03'\c
1162 .\}
1163 .el \{\
1164 .sp -1
1165 .IP \(bu 2.3
1166 .\}
1167 Having the cache on NFS may slow down compilation\&. Make sure to do some benchmarking to see if it\(cqs worth it\&.
1168 .RE
1169 .sp
1170 .RS 4
1171 .ie n \{\
1172 \h'-04'\(bu\h'+03'\c
1173 .\}
1174 .el \{\
1175 .sp -1
1176 .IP \(bu 2.3
1177 .\}
1178 ccache hasn\(cqt been tested very thoroughly on NFS\&.
1179 .RE
1180 .sp
1181 A tip is to set \fBtemporary_dir\fR to a directory on the local host to avoid NFS traffic for temporary files\&.
1182 .SH "USING CCACHE WITH OTHER COMPILER WRAPPERS"
1183 .sp
1184 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\&.
1185 .sp
1186 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:
1187 .sp
1188 .RS 4
1189 .ie n \{\
1190 \h'-04'\(bu\h'+03'\c
1191 .\}
1192 .el \{\
1193 .sp -1
1194 .IP \(bu 2.3
1195 .\}
1196 Compiler upgrades will not be detected properly\&.
1197 .RE
1198 .sp
1199 .RS 4
1200 .ie n \{\
1201 \h'-04'\(bu\h'+03'\c
1202 .\}
1203 .el \{\
1204 .sp -1
1205 .IP \(bu 2.3
1206 .\}
1207 The cached results will not be shared between compilations with and without the other wrapper\&.
1208 .RE
1209 .sp
1210 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\&.
1211 .SH "BUGS"
1212 .sp
1213 .RS 4
1214 .ie n \{\
1215 \h'-04'\(bu\h'+03'\c
1216 .\}
1217 .el \{\
1218 .sp -1
1219 .IP \(bu 2.3
1220 .\}
1221 ccache doesn\(cqt handle the GNU Assembler\(cqs
1222 \fB\&.incbin\fR
1223 directive correctly\&. This directive can be embedded in the source code inside an
1224 \fB\fIasm\fR\fR
1225 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
1226 \fBextra_files_to_hash\fR
1227 to the path of the included file\&.
1228 .RE
1229 .sp
1230 .RS 4
1231 .ie n \{\
1232 \h'-04'\(bu\h'+03'\c
1233 .\}
1234 .el \{\
1235 .sp -1
1236 .IP \(bu 2.3
1237 .\}
1238 The direct mode fails to pick up new header files in some rare scenarios\&. See
1239 THE DIRECT MODE
1240 above\&.
1241 .RE
1242 .SH "TROUBLESHOOTING"
1243 .SS "General"
1244 .sp
1245 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\&.
1246 .SS "Performance"
1247 .sp
1248 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\&.
1249 .sp
1250 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\&.
1251 .sp
1252 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:
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 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:
1263 .sp
1264 .RS 4
1265 .ie n \{\
1266 \h'-04'\(bu\h'+03'\c
1267 .\}
1268 .el \{\
1269 .sp -1
1270 .IP \(bu 2.3
1271 .\}
1272 The source code has been modified in such a way that the preprocessor output is not affected\&.
1273 .RE
1274 .sp
1275 .RS 4
1276 .ie n \{\
1277 \h'-04'\(bu\h'+03'\c
1278 .\}
1279 .el \{\
1280 .sp -1
1281 .IP \(bu 2.3
1282 .\}
1283 Compiler arguments that are hashed in the direct mode but not in the preprocessor mode have changed (\fB\-I\fR,
1284 \fB\-include\fR,
1285 \fB\-D\fR, etc) and they didn\(cqt affect the preprocessor output\&.
1286 .RE
1287 .sp
1288 .RS 4
1289 .ie n \{\
1290 \h'-04'\(bu\h'+03'\c
1291 .\}
1292 .el \{\
1293 .sp -1
1294 .IP \(bu 2.3
1295 .\}
1296 The compiler option
1297 \fB\-Xpreprocessor\fR
1298 or
1299 \fB\-Wp,\fR\fB\fIX\fR\fR
1300 (except
1301 \fB\-Wp,\-MD,\fR\fB\fIpath\fR\fR
1302 and
1303 \fBWp,\-MMD,\fR\fB\fIpath\fR\fR) is used\&.
1304 .RE
1305 .sp
1306 .RS 4
1307 .ie n \{\
1308 \h'-04'\(bu\h'+03'\c
1309 .\}
1310 .el \{\
1311 .sp -1
1312 .IP \(bu 2.3
1313 .\}
1314 This was the first compilation with a new value of the base directory setting\&.
1315 .RE
1316 .sp
1317 .RS 4
1318 .ie n \{\
1319 \h'-04'\(bu\h'+03'\c
1320 .\}
1321 .el \{\
1322 .sp -1
1323 .IP \(bu 2.3
1324 .\}
1325 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
1326 \fBsloppiness\fR
1327 to
1328 \fBinclude_file_mtime\fR
1329 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\&.)
1330 .RE
1331 .sp
1332 .RS 4
1333 .ie n \{\
1334 \h'-04'\(bu\h'+03'\c
1335 .\}
1336 .el \{\
1337 .sp -1
1338 .IP \(bu 2.3
1339 .\}
1340 The
1341 \fB__TIME__\fR
1342 preprocessor macro is (potentially) being used\&. ccache turns off direct mode if \(lq__TIME__\(rq is present in the source code outside comments and string literals\&. This is done as a safety measure since the string indicates that a
1343 \fB__TIME__\fR
1344 macro
1345 \fImay\fR
1346 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
1347 \fB__TIME__\fR
1348 isn\(cqt used in practise, or don\(cqt care if ccache produces objects where
1349 \fB__TIME__\fR
1350 is expanded to something in the past, you can set
1351 \fBsloppiness\fR
1352 to
1353 \fBtime_macros\fR\&.
1354 .RE
1355 .sp
1356 .RS 4
1357 .ie n \{\
1358 \h'-04'\(bu\h'+03'\c
1359 .\}
1360 .el \{\
1361 .sp -1
1362 .IP \(bu 2.3
1363 .\}
1364 The
1365 \fB__DATE__\fR
1366 preprocessor macro is (potentially) being used and the date has changed\&. This is similar to how
1367 \fB__TIME__\fR
1368 is handled\&. If \(lq__DATE__\(rq is present in the source code outside comments and string literals, ccache hashes the current date in order to be able to produce the correct object file if the
1369 \fB__DATE__\fR
1370 macro affects the output\&. If you know that
1371 \fB__DATE__\fR
1372 isn\(cqt used in practise, or don\(cqt care if ccache produces objects where
1373 \fB__DATE__\fR
1374 is expanded to something in the past, you can set
1375 \fBsloppiness\fR
1376 to
1377 \fBtime_macros\fR\&.
1378 .RE
1379 .sp
1380 .RS 4
1381 .ie n \{\
1382 \h'-04'\(bu\h'+03'\c
1383 .\}
1384 .el \{\
1385 .sp -1
1386 .IP \(bu 2.3
1387 .\}
1388 The
1389 \fB__FILE__\fR
1390 preprocessor macro is (potentially) being used and the file path has changed\&. If \(lq__FILE__\(rq is present in the source code outside comments and string literals, ccache hashes the current input file path in order to be able to produce the correct object file if the
1391 \fB__FILE__\fR
1392 macro affects the output\&. If you know that
1393 \fB__FILE__\fR
1394 isn\(cqt used in practise, or don\(cqt care if ccache produces objects where
1395 \fB__FILE__\fR
1396 is expanded to the wrong path, you can set
1397 \fBsloppiness\fR
1398 to
1399 \fBfile_macro\fR\&.
1400 .RE
1401 .RE
1402 .sp
1403 .RS 4
1404 .ie n \{\
1405 \h'-04'\(bu\h'+03'\c
1406 .\}
1407 .el \{\
1408 .sp -1
1409 .IP \(bu 2.3
1410 .\}
1411 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
1412 \fB__TIME__\fR
1413 or
1414 \fB__DATE__\fR
1415 macros, or use of automatically generated code that contains a timestamp, build counter or other volatile information\&.
1416 .RE
1417 .sp
1418 .RS 4
1419 .ie n \{\
1420 \h'-04'\(bu\h'+03'\c
1421 .\}
1422 .el \{\
1423 .sp -1
1424 .IP \(bu 2.3
1425 .\}
1426 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\&.
1427 .RE
1428 .sp
1429 .RS 4
1430 .ie n \{\
1431 \h'-04'\(bu\h'+03'\c
1432 .\}
1433 .el \{\
1434 .sp -1
1435 .IP \(bu 2.3
1436 .\}
1437 If \(lqunsupported compiler option\(rq has been incremented, enable debug logging and check which option was rejected\&.
1438 .RE
1439 .sp
1440 .RS 4
1441 .ie n \{\
1442 \h'-04'\(bu\h'+03'\c
1443 .\}
1444 .el \{\
1445 .sp -1
1446 .IP \(bu 2.3
1447 .\}
1448 If \(lqpreprocessor error\(rq has been incremented, one possible reason is that precompiled headers are being used\&. See
1449 PRECOMPILED HEADERS
1450 for how to remedy this\&.
1451 .RE
1452 .sp
1453 .RS 4
1454 .ie n \{\
1455 \h'-04'\(bu\h'+03'\c
1456 .\}
1457 .el \{\
1458 .sp -1
1459 .IP \(bu 2.3
1460 .\}
1461 If \(lqcan\(cqt use precompiled header\(rq has been incremented, see
1462 PRECOMPILED HEADERS\&.
1463 .RE
1464 .SS "Errors when compiling with ccache"
1465 .sp
1466 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\&.
1467 .SS "Corrupt object files"
1468 .sp
1469 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:
1470 .sp
1471 .RS 4
1472 .ie n \{\
1473 \h'-04' 1.\h'+01'\c
1474 .\}
1475 .el \{\
1476 .sp -1
1477 .IP "  1." 4.2
1478 .\}
1479 Build so that the bad object file ends up in the build tree\&.
1480 .RE
1481 .sp
1482 .RS 4
1483 .ie n \{\
1484 \h'-04' 2.\h'+01'\c
1485 .\}
1486 .el \{\
1487 .sp -1
1488 .IP "  2." 4.2
1489 .\}
1490 Remove the bad object file from the build tree\&.
1491 .RE
1492 .sp
1493 .RS 4
1494 .ie n \{\
1495 \h'-04' 3.\h'+01'\c
1496 .\}
1497 .el \{\
1498 .sp -1
1499 .IP "  3." 4.2
1500 .\}
1501 Rebuild with
1502 \fBCCACHE_RECACHE\fR
1503 set\&.
1504 .RE
1505 .sp
1506 An alternative is to clear the whole cache with \fBccache \-C\fR if you don\(cqt mind losing other cached results\&.
1507 .sp
1508 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\&.
1509 .SH "MORE INFORMATION"
1510 .sp
1511 Credits, mailing list information, bug reporting instructions, source code, etc, can be found on ccache\(cqs web site: http://ccache\&.samba\&.org\&.
1512 .SH "AUTHOR"
1513 .sp
1514 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\&.