summaryrefslogtreecommitdiff
path: root/ccache/ccache.1
blob: f30cc6fdae5338fd4830818627c0e21577ae3226 (plain)
    1 '\" t
    2 .\"     Title: ccache
    3 .\"    Author: [see the "AUTHOR(S)" section]
    4 .\" Generator: Asciidoctor 2.0.17
    5 .\"      Date: 2022-08-27
    6 .\"    Manual: \ \&
    7 .\"    Source: Ccache 4.6.3
    8 .\"  Language: English
    9 .\"
   10 .TH "CCACHE" "1" "2022-08-27" "Ccache 4.6.3" "\ \&"
   11 .ie \n(.g .ds Aq \(aq
   12 .el       .ds Aq '
   13 .ss \n[.ss] 0
   14 .nh
   15 .ad l
   16 .de URL
   17 \fI\\$2\fP <\\$1>\\$3
   18 ..
   19 .als MTO URL
   20 .if \n[.g] \{\
   21 .  mso www.tmac
   22 .  am URL
   23 .    ad l
   24 .  .
   25 .  am MTO
   26 .    ad l
   27 .  .
   28 .  LINKSTYLE blue R < >
   29 .\}
   30 .SH "NAME"
   31 ccache \- a fast C/C++ compiler cache
   32 .SH "SYNOPSIS"
   33 .sp
   34 .nf
   35 \fBccache\fP [\fIoptions\fP]
   36 \fBccache\fP \fIcompiler\fP [\fIcompiler options\fP]
   37 \fIcompiler\fP [\fIcompiler options\fP]                   (via symbolic link)
   38 .fi
   39 .br
   40 .SH "DESCRIPTION"
   41 .sp
   42 Ccache is a compiler cache. It speeds up recompilation by caching the result of
   43 previous compilations and detecting when the same compilation is being done
   44 again.
   45 .sp
   46 Ccache has been carefully written to always produce exactly the same compiler
   47 output that you would get without the cache. The only way you should be able to
   48 tell that you are using ccache is the speed. Currently known exceptions to this
   49 goal are listed under \fICAVEATS\fP. If you discover an undocumented case where
   50 ccache changes the output of your compiler, please let us know.
   51 .SH "RUN MODES"
   52 .sp
   53 There are two ways to use ccache. You can either prefix your compilation
   54 commands with \fBccache\fP or you can let ccache masquerade as the compiler by
   55 creating a symbolic link (named as the compiler) to ccache. The first method is
   56 most convenient if you just want to try out ccache or wish to use it for some
   57 specific projects. The second method is most useful for when you wish to use
   58 ccache for all your compilations.
   59 .sp
   60 To use the first method, just make sure that \fBccache\fP is in your \fBPATH\fP.
   61 .sp
   62 To use the symlinks method, do something like this:
   63 .sp
   64 .if n .RS 4
   65 .nf
   66 .fam C
   67 cp ccache /usr/local/bin/
   68 ln \-s ccache /usr/local/bin/gcc
   69 ln \-s ccache /usr/local/bin/g++
   70 ln \-s ccache /usr/local/bin/cc
   71 ln \-s ccache /usr/local/bin/c++
   72 .fam
   73 .fi
   74 .if n .RE
   75 .sp
   76 And so forth. This will work as long as the directory with symlinks comes
   77 before the path to the compiler (which is usually in \fB/usr/bin\fP). After
   78 installing you may wish to run \(lqwhich gcc\(rq to make sure that the correct link
   79 is being used.
   80 .if n .sp
   81 .RS 4
   82 .it 1 an-trap
   83 .nr an-no-space-flag 1
   84 .nr an-break-flag 1
   85 .br
   86 .ps +1
   87 .B Warning
   88 .ps -1
   89 .br
   90 .sp
   91 The technique of letting ccache masquerade as the compiler works well,
   92 but currently doesn\(cqt interact well with other tools that do the same thing. See
   93 \fIUSING CCACHE WITH OTHER COMPILER WRAPPERS\fP.
   94 .sp .5v
   95 .RE
   96 .if n .sp
   97 .RS 4
   98 .it 1 an-trap
   99 .nr an-no-space-flag 1
  100 .nr an-break-flag 1
  101 .br
  102 .ps +1
  103 .B Warning
  104 .ps -1
  105 .br
  106 .sp
  107 Use a symbolic links for masquerading, not hard links.
  108 .sp .5v
  109 .RE
  110 .SH "COMMAND LINE OPTIONS"
  111 .sp
  112 These command line options only apply when you invoke ccache as \(lqccache\(rq.
  113 When invoked as a compiler (via a symlink as described in the previous
  114 section), the normal compiler options apply and you should refer to the
  115 compiler\(cqs documentation.
  116 .SS "Common options"
  117 .sp
  118 \fB\-c\fP, \fB\-\-cleanup\fP
  119 .RS 4
  120 Clean up the cache by removing old cached files until the specified file
  121 number and cache size limits are not exceeded. This also recalculates the
  122 cache file count and size totals. Normally, there is no need to initiate
  123 cleanup manually as ccache keeps the cache below the specified limits at
  124 runtime and keeps statistics up to date on each compilation. Forcing a
  125 cleanup is mostly useful if you manually modify the cache contents or
  126 believe that the cache size statistics may be inaccurate.
  127 .RE
  128 .sp
  129 \fB\-C\fP, \fB\-\-clear\fP
  130 .RS 4
  131 Clear the entire cache, removing all cached files, but keeping the
  132 configuration file.
  133 .RE
  134 .sp
  135 \fB\-\-config\-path\fP \fIPATH\fP
  136 .RS 4
  137 Let the command line options operate on configuration file \fIPATH\fP instead of
  138 the default. Using this option has the same effect as setting (overriding)
  139 the environment variable \fBCCACHE_CONFIGPATH\fP temporarily.
  140 .RE
  141 .sp
  142 \fB\-d\fP, \fB\-\-dir\fP \fIPATH\fP
  143 .RS 4
  144 Let the command line options operate on cache directory \fIPATH\fP instead of
  145 the default. For example, to show statistics for a cache directory at
  146 \fB/shared/ccache\fP you can run \fBccache \-d /shared/ccache \-s\fP. Using this option
  147 has the same effect as setting the environment variable \fBCCACHE_DIR\fP
  148 temporarily.
  149 .RE
  150 .sp
  151 \fB\-\-evict\-namespace\fP \fINAMESPACE\fP
  152 .RS 4
  153 Remove files created in the given \fBnamespace\fP from the
  154 cache.
  155 .RE
  156 .sp
  157 \fB\-\-evict\-older\-than\fP \fIAGE\fP
  158 .RS 4
  159 Remove files older than \fIAGE\fP from the cache. \fIAGE\fP should be an unsigned
  160 integer with a \fBd\fP (days) or \fBs\fP (seconds) suffix. If combined with
  161 \fB\-\-evict\-namespace\fP, only remove old files within that namespace.
  162 .RE
  163 .sp
  164 \fB\-h\fP, \fB\-\-help\fP
  165 .RS 4
  166 Print a summary of command line options.
  167 .RE
  168 .sp
  169 \fB\-F\fP \fINUM\fP, \fB\-\-max\-files\fP \fINUM\fP
  170 .RS 4
  171 Set the maximum number of files allowed in the cache to \fINUM\fP. Use 0 for no
  172 limit. The value is stored in a configuration file in the cache directory
  173 and applies to all future compilations.
  174 .RE
  175 .sp
  176 \fB\-M\fP \fISIZE\fP, \fB\-\-max\-size\fP \fISIZE\fP
  177 .RS 4
  178 Set the maximum size of the files stored in the cache. \fISIZE\fP should be a
  179 number followed by an optional suffix: k, M, G, T (decimal), Ki, Mi, Gi or
  180 Ti (binary). The default suffix is G. Use 0 for no limit. The value is
  181 stored in a configuration file in the cache directory and applies to all
  182 future compilations.
  183 .RE
  184 .sp
  185 \fB\-X\fP \fILEVEL\fP, \fB\-\-recompress\fP \fILEVEL\fP
  186 .RS 4
  187 Recompress the cache to level \fILEVEL\fP using the Zstandard algorithm. The
  188 level can be an integer, with the same semantics as the
  189 \fBcompression_level\fP configuration option), or
  190 the special value \fBuncompressed\fP for no compression. See
  191 \fICACHE COMPRESSION\fP for more information. This can potentionally take a
  192 long time since all files in the cache need to be visited. Only files that
  193 are currently compressed with a different level than \fILEVEL\fP will be
  194 recompressed.
  195 .RE
  196 .sp
  197 \fB\-o\fP \fIKEY=VALUE\fP, \fB\-\-set\-config\fP \fIKEY\fP=\fIVALUE\fP
  198 .RS 4
  199 Set configuration option \fIKEY\fP to \fIVALUE\fP. See \fICONFIGURATION\fP for more
  200 information.
  201 .RE
  202 .sp
  203 \fB\-x\fP, \fB\-\-show\-compression\fP
  204 .RS 4
  205 Print cache compression statistics. See \fICACHE COMPRESSION\fP for more
  206 information. This can potentionally take a long time since all files in the
  207 cache need to be visited.
  208 .RE
  209 .sp
  210 \fB\-p\fP, \fB\-\-show\-config\fP
  211 .RS 4
  212 Print current configuration options and from where they originate
  213 (environment variable, configuration file or compile\-time default) in
  214 human\-readable format.
  215 .RE
  216 .sp
  217 \fB\-\-show\-log\-stats\fP
  218 .RS 4
  219 Print statistics counters from the stats log in human\-readable format. See
  220 \fBstats_log\fP. Use \fB\-v\fP/\fB\-\-verbose\fP once or twice for
  221 more details.
  222 .RE
  223 .sp
  224 \fB\-s\fP, \fB\-\-show\-stats\fP
  225 .RS 4
  226 Print a summary of configuration and statistics counters in human\-readable
  227 format. Use \fB\-v\fP/\fB\-\-verbose\fP once or twice for more details.
  228 .RE
  229 .sp
  230 \fB\-v\fP, \fB\-\-verbose\fP
  231 .RS 4
  232 Increase verbosity. The option can be given multiple times.
  233 .RE
  234 .sp
  235 \fB\-V\fP, \fB\-\-version\fP
  236 .RS 4
  237 Print version and copyright information.
  238 .RE
  239 .sp
  240 \fB\-z\fP, \fB\-\-zero\-stats\fP
  241 .RS 4
  242 Zero the cache statistics (but not the configuration options).
  243 .RE
  244 .SS "Options for secondary storage"
  245 .sp
  246 \fB\-\-trim\-dir\fP \fIPATH\fP
  247 .RS 4
  248 Remove old files from directory \fIPATH\fP until it is at most the size specified
  249 by \fB\-\-trim\-max\-size\fP.
  250 .if n .sp
  251 .RS 4
  252 .it 1 an-trap
  253 .nr an-no-space-flag 1
  254 .nr an-break-flag 1
  255 .br
  256 .ps +1
  257 .B Warning
  258 .ps -1
  259 .br
  260 .sp
  261 Don\(cqt use this option to trim the primary cache. To trim the primary
  262 cache directory to a certain size, use \fBCCACHE_MAXSIZE=\fISIZE\fP ccache \-c\fP.
  263 .sp .5v
  264 .RE
  265 .RE
  266 .sp
  267 \fB\-\-trim\-max\-size\fP \fISIZE\fP
  268 .RS 4
  269 Specify the maximum size for \fB\-\-trim\-dir\fP. \fISIZE\fP should be a number followed
  270 by an optional suffix: k, M, G, T (decimal), Ki, Mi, Gi or Ti (binary). The
  271 default suffix is G.
  272 .RE
  273 .sp
  274 \fB\-\-trim\-method\fP \fIMETHOD\fP
  275 .RS 4
  276 Specify the method to trim a directory with \fB\-\-trim\-dir\fP. Possible values
  277 are:
  278 .sp
  279 \fBatime\fP
  280 .RS 4
  281 LRU (least recently used) using the file access timestamp. This is the
  282 default.
  283 .RE
  284 .sp
  285 \fBmtime\fP
  286 .RS 4
  287 LRU (least recently used) using the file modification timestamp.
  288 .RE
  289 .RE
  290 .SS "Options for scripting or debugging"
  291 .sp
  292 \fB\-\-checksum\-file\fP \fIPATH\fP
  293 .RS 4
  294 Print the checksum (128 bit XXH3) of the file at \fIPATH\fP (\fB\-\fP for standard
  295 input).
  296 .RE
  297 .sp
  298 \fB\-\-extract\-result\fP \fIPATH\fP
  299 .RS 4
  300 Extract data stored in the result file at \fIPATH\fP (\fB\-\fP for standard input).
  301 The data will be written to \fBccache\-result.*\fP files in to the current
  302 working directory. This option is only useful when debugging ccache and its
  303 behavior.
  304 .RE
  305 .sp
  306 \fB\-k\fP \fIKEY\fP, \fB\-\-get\-config\fP \fIKEY\fP
  307 .RS 4
  308 Print the value of configuration option \fIKEY\fP. See \fICONFIGURATION\fP for
  309 more information.
  310 .RE
  311 .sp
  312 \fB\-\-hash\-file\fP \fIPATH\fP
  313 .RS 4
  314 Print the hash (160 bit BLAKE3) of the file at \fIPATH\fP (\fB\-\fP for standard
  315 input). This is only useful when debugging ccache and its behavior.
  316 .RE
  317 .sp
  318 \fB\-\-inspect\fP \fIPATH\fP
  319 .RS 4
  320 Print the content of a result or manifest file at \fIPATH\fP (\fB\-\fP for standard
  321 input) to standard output in human\-readable format. File content embedded in
  322 a result file will however not be printed; use \fB\-\-extract\-result\fP to extract
  323 the file content. This option is only useful when debugging ccache and its
  324 behavior.
  325 .RE
  326 .sp
  327 \fB\-\-print\-stats\fP
  328 .RS 4
  329 Print statistics counter IDs and corresponding values in machine\-parsable
  330 (tab\-separated) format.
  331 .RE
  332 .SS "Extra options"
  333 .sp
  334 When run as a compiler, ccache usually just takes the same command line options
  335 as the compiler you are using. The only exception to this is the option
  336 \fB\-\-ccache\-skip\fP. That option can be used to tell ccache to avoid interpreting
  337 the next option in any way and to pass it along to the compiler as\-is.
  338 .if n .sp
  339 .RS 4
  340 .it 1 an-trap
  341 .nr an-no-space-flag 1
  342 .nr an-break-flag 1
  343 .br
  344 .ps +1
  345 .B Note
  346 .ps -1
  347 .br
  348 .sp
  349 \fB\-\-ccache\-skip\fP currently only tells ccache not to interpret the next
  350 option as a special compiler option \(em the option will still be included in the
  351 direct mode hash.
  352 .sp .5v
  353 .RE
  354 .sp
  355 The reason this can be important is that ccache does need to parse the command
  356 line and determine what is an input filename and what is a compiler option, as
  357 it needs the input filename to determine the name of the resulting object file
  358 (among other things). The heuristic ccache uses when parsing the command line
  359 is that any argument that exists as a file is treated as an input file name. By
  360 using \fB\-\-ccache\-skip\fP you can force an option to not be treated as an input
  361 file name and instead be passed along to the compiler as a command line option.
  362 .sp
  363 Another case where \fB\-\-ccache\-skip\fP can be useful is if ccache interprets an
  364 option specially but shouldn\(cqt, since the option has another meaning for your
  365 compiler than what ccache thinks.
  366 .SH "CONFIGURATION"
  367 .sp
  368 Ccache\(cqs default behavior can be overridden by options in configuration files,
  369 which in turn can be overridden by environment variables with names starting
  370 with \fBCCACHE_\fP. Ccache normally reads configuration from two files: first a
  371 system\-level configuration file and secondly a cache\-specific configuration
  372 file. The priorities of configuration options are as follows (where 1 is
  373 highest):
  374 .sp
  375 .RS 4
  376 .ie n \{\
  377 \h'-04' 1.\h'+01'\c
  378 .\}
  379 .el \{\
  380 .  sp -1
  381 .  IP " 1." 4.2
  382 .\}
  383 Environment variables.
  384 .RE
  385 .sp
  386 .RS 4
  387 .ie n \{\
  388 \h'-04' 2.\h'+01'\c
  389 .\}
  390 .el \{\
  391 .  sp -1
  392 .  IP " 2." 4.2
  393 .\}
  394 The primary (cache\-specific) configuration file (see below).
  395 .RE
  396 .sp
  397 .RS 4
  398 .ie n \{\
  399 \h'-04' 3.\h'+01'\c
  400 .\}
  401 .el \{\
  402 .  sp -1
  403 .  IP " 3." 4.2
  404 .\}
  405 The secondary (system\-wide read\-only) configuration file
  406 \fB<sysconfdir>/ccache.conf\fP (typically \fB/etc/ccache.conf\fP or
  407 \fB/usr/local/etc/ccache.conf\fP).
  408 .RE
  409 .sp
  410 .RS 4
  411 .ie n \{\
  412 \h'-04' 4.\h'+01'\c
  413 .\}
  414 .el \{\
  415 .  sp -1
  416 .  IP " 4." 4.2
  417 .\}
  418 Compile\-time defaults.
  419 .RE
  420 .sp
  421 As a special case, if the the environment variable \fBCCACHE_CONFIGPATH\fP is set
  422 it specifies the primary configuration file and the secondary (system\-wide)
  423 configuration file won\(cqt be read.
  424 .SS "Location of the primary configuration file"
  425 .sp
  426 The location of the primary (cache\-specific) configuration is determined like
  427 this:
  428 .sp
  429 .RS 4
  430 .ie n \{\
  431 \h'-04' 1.\h'+01'\c
  432 .\}
  433 .el \{\
  434 .  sp -1
  435 .  IP " 1." 4.2
  436 .\}
  437 If \fBCCACHE_CONFIGPATH\fP is set, use that path.
  438 .RE
  439 .sp
  440 .RS 4
  441 .ie n \{\
  442 \h'-04' 2.\h'+01'\c
  443 .\}
  444 .el \{\
  445 .  sp -1
  446 .  IP " 2." 4.2
  447 .\}
  448 Otherwise, if the environment variable \fBCCACHE_DIR\fP is set then use
  449 \fB$CCACHE_DIR/ccache.conf\fP.
  450 .RE
  451 .sp
  452 .RS 4
  453 .ie n \{\
  454 \h'-04' 3.\h'+01'\c
  455 .\}
  456 .el \{\
  457 .  sp -1
  458 .  IP " 3." 4.2
  459 .\}
  460 Otherwise, if \fBcache_dir\fP is set in the secondary
  461 (system\-wide) configuration file then use \fB<cache_dir>/ccache.conf\fP.
  462 .RE
  463 .sp
  464 .RS 4
  465 .ie n \{\
  466 \h'-04' 4.\h'+01'\c
  467 .\}
  468 .el \{\
  469 .  sp -1
  470 .  IP " 4." 4.2
  471 .\}
  472 Otherwise, if there is a legacy \fB$HOME/.ccache\fP directory then use
  473 \fB$HOME/.ccache/ccache.conf\fP.
  474 .RE
  475 .sp
  476 .RS 4
  477 .ie n \{\
  478 \h'-04' 5.\h'+01'\c
  479 .\}
  480 .el \{\
  481 .  sp -1
  482 .  IP " 5." 4.2
  483 .\}
  484 Otherwise, if \fBXDG_CONFIG_HOME\fP is set then use
  485 \fB$XDG_CONFIG_HOME/ccache/ccache.conf\fP.
  486 .RE
  487 .sp
  488 .RS 4
  489 .ie n \{\
  490 \h'-04' 6.\h'+01'\c
  491 .\}
  492 .el \{\
  493 .  sp -1
  494 .  IP " 6." 4.2
  495 .\}
  496 Otherwise, use \fB%APPDATA%/ccache/ccache.conf\fP (Windows),
  497 \fB$HOME/Library/Preferences/ccache/ccache.conf\fP (macOS) or
  498 \fB$HOME/.config/ccache/ccache.conf\fP (other systems).
  499 .RE
  500 .SS "Configuration file syntax"
  501 .sp
  502 Configuration files are in a simple \(lqkey = value\(rq format, one option per
  503 line. Lines starting with a hash sign are comments. Blank lines are ignored, as
  504 is whitespace surrounding keys and values. Example:
  505 .sp
  506 .if n .RS 4
  507 .nf
  508 .fam C
  509 # Set maximum cache size to 10 GB:
  510 max_size = 10G
  511 .fam
  512 .fi
  513 .if n .RE
  514 .SS "Boolean values"
  515 .sp
  516 Some configuration options are boolean values (i.e. truth values). In a
  517 configuration file, such values must be set to the string \fBtrue\fP or \fBfalse\fP.
  518 For the corresponding environment variables, the semantics are a bit different:
  519 .sp
  520 .RS 4
  521 .ie n \{\
  522 \h'-04'\(bu\h'+03'\c
  523 .\}
  524 .el \{\
  525 .  sp -1
  526 .  IP \(bu 2.3
  527 .\}
  528 A set environment variable means \(lqtrue\(rq (even if set to the empty string).
  529 .RE
  530 .sp
  531 .RS 4
  532 .ie n \{\
  533 \h'-04'\(bu\h'+03'\c
  534 .\}
  535 .el \{\
  536 .  sp -1
  537 .  IP \(bu 2.3
  538 .\}
  539 The following case\-insensitive negative values are considered an error
  540 (instead of surprising the user): \fB0\fP, \fBfalse\fP, \fBdisable\fP and \fBno\fP.
  541 .RE
  542 .sp
  543 .RS 4
  544 .ie n \{\
  545 \h'-04'\(bu\h'+03'\c
  546 .\}
  547 .el \{\
  548 .  sp -1
  549 .  IP \(bu 2.3
  550 .\}
  551 An unset environment variable means \(lqfalse\(rq.
  552 .RE
  553 .sp
  554 Each boolean environment variable also has a negated form starting with
  555 \fBCCACHE_NO\fP. For example, \fBCCACHE_COMPRESS\fP can be set to force compression and
  556 \fBCCACHE_NOCOMPRESS\fP can be set to force no compression.
  557 .SS "Configuration options"
  558 .sp
  559 Below is a list of available configuration options. The corresponding
  560 environment variable name is indicated in parentheses after each configuration
  561 option key.
  562 .sp
  563 \fBabsolute_paths_in_stderr\fP (\fBCCACHE_ABSSTDERR\fP)
  564 .RS 4
  565 This option specifies whether ccache should rewrite relative paths in the
  566 compiler\(cqs standard error output to absolute paths. This can be useful if
  567 you use \fBbase_dir\fP with a build system (e.g. CMake with
  568 the "Unix Makefiles" generator) that executes the compiler in a different
  569 working directory, which makes relative paths in compiler errors or
  570 warnings incorrect. The default is false.
  571 .RE
  572 .sp
  573 \fBbase_dir\fP (\fBCCACHE_BASEDIR\fP)
  574 .RS 4
  575 This option should be an absolute path to a directory. If set, ccache will
  576 rewrite absolute paths into paths relative to the current working directory,
  577 but only absolute paths that begin with \fBbase_dir\fP. Cache results can then
  578 be shared for compilations in different directories even if the project uses
  579 absolute paths in the compiler command line. See also the discussion under
  580 \fICOMPILING IN DIFFERENT DIRECTORIES\fP. If set to the empty string (which
  581 is the default), no rewriting is done.
  582 .sp
  583 A typical path to use as \fBbase_dir\fP is your home directory or another directory
  584 that is a parent of your project directories. Don\(cqt use \fB/\fP as the base
  585 directory since that will make ccache also rewrite paths to system header
  586 files, which typically is contraproductive.
  587 .sp
  588 For example, say that Alice\(cqs current working directory is
  589 \fB/home/alice/project1/build\fP and that she compiles like this:
  590 .sp
  591 .if n .RS 4
  592 .nf
  593 .fam C
  594 ccache gcc \-I/usr/include/example \-I/home/alice/project2/include \-c /home/alice/project1/src/example.c
  595 .fam
  596 .fi
  597 .if n .RE
  598 .sp
  599 Here is what ccache will actually execute for different \fBbase_dir\fP values:
  600 .sp
  601 .if n .RS 4
  602 .nf
  603 .fam C
  604 # Current working directory: /home/alice/project1/build
  605 
  606 # With base_dir = /:
  607 gcc \-I../../../../usr/include/example \-I../../project2/include \-c ../src/example.c
  608 
  609 # With base_dir = /home or /home/alice:
  610 gcc \-I/usr/include/example \-I../../project2/include \-c ../src/example.c
  611 
  612 # With base_dir = /home/alice/project1 or /home/alice/project1/src:
  613 gcc \-I/usr/include/example \-I/home/alice/project2/include \-c ../src/example.c
  614 .fam
  615 .fi
  616 .if n .RE
  617 .sp
  618 If Bob has put \fBproject1\fP and \fBproject2\fP in \fB/home/bob/stuff\fP and both users
  619 have set \fBbase_dir\fP to \fB/home\fP or \fB/home/$USER\fP, then Bob will get a cache hit
  620 (if they share ccache directory) since the actual command line will be
  621 identical to that of Alice:
  622 .sp
  623 .if n .RS 4
  624 .nf
  625 .fam C
  626 # Current working directory: /home/bob/stuff/project1/build
  627 
  628 # With base_dir = /home or /home/bob:
  629 gcc \-I/usr/include/example \-I../../project2/include \-c ../src/example.c
  630 .fam
  631 .fi
  632 .if n .RE
  633 .sp
  634 Without \fBbase_dir\fP there will be a cache miss since the absolute paths will
  635 differ. With \fBbase_dir\fP set to \fB/\fP there will be a cache miss since the
  636 relative path to \fB/usr/include/example\fP will be different. With \fBbase_dir\fP set
  637 to \fB/home/bob/stuff/project1\fP there will a cache miss since the path to
  638 project2 will be a different absolute path.
  639 .if n .sp
  640 .RS 4
  641 .it 1 an-trap
  642 .nr an-no-space-flag 1
  643 .nr an-break-flag 1
  644 .br
  645 .ps +1
  646 .B Warning
  647 .ps -1
  648 .br
  649 .sp
  650 Rewriting absolute paths to relative is kind of a brittle hack. It
  651 works OK in many cases, but there might be cases where things break. One known
  652 issue is that absolute paths are not reproduced in dependency files, which can
  653 mess up dependency detection in tools like Make and Ninja. If possible, use
  654 relative paths in the first place instead instead of using \fBbase_dir\fP.
  655 .sp .5v
  656 .RE
  657 .RE
  658 .sp
  659 \fBcache_dir\fP (\fBCCACHE_DIR\fP)
  660 .RS 4
  661 This option specifies where ccache will keep its cached compiler outputs.
  662 The default is \fB$XDG_CACHE_HOME/ccache\fP if \fBXDG_CACHE_HOME\fP is set,
  663 otherwise \fB%APPDATA%/ccache\fP (Windows), \fB$HOME/Library/Caches/ccache\fP
  664 (macOS) or \fB$HOME/.config/ccache\fP (other systems). Exception: If the legacy
  665 directory \fB$HOME/.ccache\fP exists then that directory is the default.
  666 .sp
  667 See also \fILocation of the primary configuration file\fP.
  668 .sp
  669 If you want to use another \fBCCACHE_DIR\fP value temporarily for one ccache
  670 invocation you can use the \fB\-d\fP/\fB\-\-dir\fP command line option instead.
  671 .RE
  672 .sp
  673 \fBcompiler\fP (\fBCCACHE_COMPILER\fP or (deprecated) \fBCCACHE_CC\fP)
  674 .RS 4
  675 This option can be used to force the name of the compiler to use. If set to
  676 the empty string (which is the default), ccache works it out from the
  677 command line.
  678 .RE
  679 .sp
  680 \fBcompiler_check\fP (\fBCCACHE_COMPILERCHECK\fP)
  681 .RS 4
  682 By default, ccache includes the modification time (\(lqmtime\(rq) and size of
  683 the compiler in the hash to ensure that results retrieved from the cache
  684 are accurate. If compiler plugins are used, these plugins will also be
  685 added to the hash. This option can be used to select another strategy.
  686 Possible values are:
  687 .sp
  688 \fBcontent\fP
  689 .RS 4
  690 Hash the content of the compiler binary. This makes ccache very slightly
  691 slower compared to \fBmtime\fP, but makes it cope better with compiler upgrades
  692 during a build bootstrapping process.
  693 .RE
  694 .sp
  695 \fBmtime\fP
  696 .RS 4
  697 Hash the compiler\(cqs mtime and size, which is fast. This is the default.
  698 .RE
  699 .sp
  700 \fBnone\fP
  701 .RS 4
  702 Don\(cqt hash anything. This may be good for situations where you can safely
  703 use the cached results even though the compiler\(cqs mtime or size has changed
  704 (e.g. if the compiler is built as part of your build system and the
  705 compiler\(cqs source has not changed, or if the compiler only has changes that
  706 don\(cqt affect code generation). You should only use \fBnone\fP if you know what
  707 you are doing.
  708 .RE
  709 .sp
  710 \fBstring:value\fP
  711 .RS 4
  712 Hash \fBvalue\fP. This can for instance be a compiler revision number or
  713 another string that the build system generates to identify the compiler.
  714 .RE
  715 .sp
  716 \fIa command string\fP
  717 .RS 4
  718 Hash the standard output and standard error output of the specified
  719 command. The string will be split on whitespace to find out the command and
  720 arguments to run. No other interpretation of the command string will be
  721 done, except that the special word \fB%compiler%\fP will be replaced with the
  722 path to the compiler. Several commands can be specified with semicolon as
  723 separator. Examples:
  724 .sp
  725 .if n .RS 4
  726 .nf
  727 .fam C
  728 %compiler% \-v
  729 .fam
  730 .fi
  731 .if n .RE
  732 .sp
  733 .if n .RS 4
  734 .nf
  735 .fam C
  736 %compiler% \-dumpmachine; %compiler% \-dumpversion
  737 .fam
  738 .fi
  739 .if n .RE
  740 .sp
  741 You should make sure that the specified command is as fast as possible since it
  742 will be run once for each ccache invocation.
  743 .sp
  744 Identifying the compiler using a command is useful if you want to avoid cache
  745 misses when the compiler has been rebuilt but not changed.
  746 .sp
  747 Another case is when the compiler (as seen by ccache) actually isn\(cqt the real
  748 compiler but another compiler wrapper \(em in that case, the default \fBmtime\fP
  749 method will hash the mtime and size of the other compiler wrapper, which means
  750 that ccache won\(cqt be able to detect a compiler upgrade. Using a suitable command
  751 to identify the compiler is thus safer, but it\(cqs also slower, so you should
  752 consider continue using the \fBmtime\fP method in combination with the
  753 \fBprefix_command\fP option if possible. See
  754 \fIUSING CCACHE WITH OTHER COMPILER WRAPPERS\fP.
  755 .RE
  756 .RE
  757 .sp
  758 \fBcompiler_type\fP (\fBCCACHE_COMPILERTYPE\fP)
  759 .RS 4
  760 Ccache normally guesses the compiler type based on the compiler name. The
  761 \fBcompiler_type\fP option lets you force a compiler type. This can be useful
  762 if the compiler has a non\-standard name but is actually one of the known
  763 compiler types. Possible values are:
  764 .sp
  765 \fBauto\fP
  766 .RS 4
  767 Guess one of the types below based on the compiler name (following
  768 symlinks). This is the default.
  769 .RE
  770 .sp
  771 \fBclang\fP
  772 .RS 4
  773 Clang\-based compiler.
  774 .RE
  775 .sp
  776 \fBclang\-cl\fP
  777 .RS 4
  778 clang\-cl.
  779 .RE
  780 .sp
  781 \fBgcc\fP
  782 .RS 4
  783 GCC\-based compiler.
  784 .RE
  785 .sp
  786 \fBmsvc\fP
  787 .RS 4
  788 Microsoft Visual C++ (MSVC).
  789 .RE
  790 .sp
  791 \fBnvcc\fP
  792 .RS 4
  793 NVCC (CUDA) compiler.
  794 .RE
  795 .sp
  796 \fBother\fP
  797 .RS 4
  798 Any compiler other than the known types.
  799 .RE
  800 .sp
  801 \fBpump\fP
  802 .RS 4
  803 distcc\(cqs \(lqpump\(rq script.
  804 .RE
  805 .RE
  806 .sp
  807 \fBcompression\fP (\fBCCACHE_COMPRESS\fP or \fBCCACHE_NOCOMPRESS\fP, see \fIBoolean values\fP above)
  808 .RS 4
  809 If true, ccache will compress data it puts in the cache. However, this
  810 option has no effect on how files are retrieved from the cache; compressed
  811 and uncompressed results will still be usable regardless of this option.
  812 The default is true.
  813 .sp
  814 Compression is done using the Zstandard algorithm. The algorithm is fast enough
  815 that there should be little reason to turn off compression to gain performance.
  816 One exception is if the cache is located on a compressed file system, in which
  817 case the compression performed by ccache of course is redundant.
  818 .sp
  819 Compression will be disabled if file cloning (the
  820 \fBfile_clone\fP option) or hard linking (the
  821 \fBhard_link\fP option) is enabled.
  822 .RE
  823 .sp
  824 \fBcompression_level\fP (\fBCCACHE_COMPRESSLEVEL\fP)
  825 .RS 4
  826 This option determines the level at which ccache will compress object files
  827 using the real\-time compression algorithm Zstandard. It only has effect if
  828 \fBcompression\fP is enabled (which it is by default).
  829 Zstandard is extremely fast for decompression and very fast for compression
  830 for lower compression levels. The default is 0.
  831 .sp
  832 Semantics of \fBcompression_level\fP:
  833 .sp
  834 \fB> 0\fP
  835 .RS 4
  836 A positive value corresponds to normal Zstandard compression levels. Lower
  837 levels (e.g. \fB1\fP) mean faster compression but worse compression ratio.
  838 Higher levels (e.g. \fB19\fP) mean slower compression but better compression
  839 ratio. The maximum possible value depends on the libzstd version, but at
  840 least up to 19 is available for all versions. Decompression speed is
  841 essentially the same for all levels. As a rule of thumb, use level 5 or
  842 lower since higher levels may slow down compilations noticeably. Higher
  843 levels are however useful when recompressing the cache with command line
  844 option \fB\-X\fP/\fB\-\-recompress\fP.
  845 .RE
  846 .sp
  847 \fB< 0\fP
  848 .RS 4
  849 A negative value corresponds to Zstandard\(cqs \(lqultra\-fast\(rq compression
  850 levels, which are even faster than level 1 but with less good compression
  851 ratios. For instance, level \fB\-3\fP corresponds to \fB\-\-fast=3\fP for the \fBzstd\fP
  852 command line tool. In practice, there is little use for levels lower than
  853 \fB\-5\fP or so.
  854 .RE
  855 .sp
  856 \fB0\fP (default)
  857 .RS 4
  858 The value \fB0\fP means that ccache will choose a suitable level, currently
  859 \fB1\fP.
  860 .RE
  861 .sp
  862 See the \c
  863 .URL "http://zstd.net" "Zstandard documentation" ""
  864 for more information.
  865 .RE
  866 .sp
  867 \fBcpp_extension\fP (\fBCCACHE_EXTENSION\fP)
  868 .RS 4
  869 This option can be used to force a certain extension for the intermediate
  870 preprocessed file. The default is to automatically determine the extension
  871 to use for intermediate preprocessor files based on the type of file being
  872 compiled, but that sometimes doesn\(cqt work. For example, when using the
  873 \(lqaCC\(rq compiler on HP\-UX, set the cpp extension to \fBi\fP.
  874 .RE
  875 .sp
  876 \fBdebug\fP (\fBCCACHE_DEBUG\fP or \fBCCACHE_NODEBUG\fP, see \fIBoolean values\fP above)
  877 .RS 4
  878 If true, enable the debug mode. The debug mode creates per\-object debug
  879 files that are helpful when debugging unexpected cache misses. Note however
  880 that ccache performance will be reduced slightly. See \fICACHE DEBUGGING\fP
  881 for more information. The default is false.
  882 .RE
  883 .sp
  884 \fBdebug_dir\fP (\fBCCACHE_DEBUGDIR\fP)
  885 .RS 4
  886 Specifies where to write per\-object debug files if the debug
  887 mode is enabled. If set to the empty string, the files will be written
  888 next to the object file. If set to a directory, the debug files will be
  889 written with full absolute paths in that directory, creating it if needed.
  890 The default is the empty string.
  891 .sp
  892 For example, if \fBdebug_dir\fP is set to \fB/example\fP, the current working directory
  893 is \fB/home/user\fP and the object file is \fBbuild/output.o\fP then the debug log will
  894 be written to \fB/example/home/user/build/output.o.ccache\-log\fP. See also
  895 \fICACHE DEBUGGING\fP.
  896 .RE
  897 .sp
  898 \fBdepend_mode\fP (\fBCCACHE_DEPEND\fP or \fBCCACHE_NODEPEND\fP, see \fIBoolean values\fP above)
  899 .RS 4
  900 If true, the depend mode will be used. The default is false. See
  901 \fIThe depend mode\fP.
  902 .RE
  903 .sp
  904 \fBdirect_mode\fP (\fBCCACHE_DIRECT\fP or \fBCCACHE_NODIRECT\fP, see \fIBoolean values\fP above)
  905 .RS 4
  906 If true, the direct mode will be used. The default is true. See
  907 \fIThe direct mode\fP.
  908 .RE
  909 .sp
  910 \fBdisable\fP (\fBCCACHE_DISABLE\fP or \fBCCACHE_NODISABLE\fP, see \fIBoolean values\fP above)
  911 .RS 4
  912 When true, ccache will just call the real compiler, bypassing the cache
  913 completely. The default is false.
  914 .RE
  915 .sp
  916 \fBextra_files_to_hash\fP (\fBCCACHE_EXTRAFILES\fP)
  917 .RS 4
  918 This option is a list of paths to files that ccache will include in the the
  919 hash sum that identifies the build. The list separator is semicolon on
  920 Windows systems and colon on other systems.
  921 .RE
  922 .sp
  923 \fBfile_clone\fP (\fBCCACHE_FILECLONE\fP or \fBCCACHE_NOFILECLONE\fP, see \fIBoolean values\fP above)
  924 .RS 4
  925 If true, ccache will attempt to use file cloning (also known as \(lqcopy on
  926 write\(rq, \(lqCoW\(rq or \(lqreflinks\(rq) to store and fetch cached compiler
  927 results. \fBfile_clone\fP has priority over \fBhard_link\fP.
  928 The default is false.
  929 .sp
  930 Files stored by cloning cannot be compressed, so the cache size will likely be
  931 significantly larger if this option is enabled. However, performance may be
  932 improved depending on the use case.
  933 .sp
  934 Unlike the \fBhard_link\fP option, \fBfile_clone\fP is completely
  935 safe to use, but not all file systems support the feature. For such file
  936 systems, ccache will fall back to use plain copying (or hard links if
  937 \fBhard_link\fP is enabled).
  938 .RE
  939 .sp
  940 \fBhard_link\fP (\fBCCACHE_HARDLINK\fP or \fBCCACHE_NOHARDLINK\fP, see \fIBoolean values\fP above)
  941 .RS 4
  942 If true, ccache will attempt to use hard links to store and fetch cached
  943 object files. The default is false.
  944 .sp
  945 Files stored via hard links cannot be compressed, so the cache size will likely
  946 be significantly larger if this option is enabled. However, performance may be
  947 improved depending on the use case.
  948 .if n .sp
  949 .RS 4
  950 .it 1 an-trap
  951 .nr an-no-space-flag 1
  952 .nr an-break-flag 1
  953 .br
  954 .ps +1
  955 .B Warning
  956 .ps -1
  957 .br
  958 .sp
  959 Do not enable this option unless you are aware of these caveats:
  960 .sp .5v
  961 .RE
  962 .sp
  963 .RS 4
  964 .ie n \{\
  965 \h'-04'\(bu\h'+03'\c
  966 .\}
  967 .el \{\
  968 .  sp -1
  969 .  IP \(bu 2.3
  970 .\}
  971 If the resulting file is modified, the file in the cache will also be
  972 modified since they share content, which corrupts the cache entry. As of
  973 version 4.0, ccache makes stored and fetched object files read\-only as a
  974 safety measure. Furthermore, a simple integrity check is made for cached
  975 object files by verifying that their sizes are correct. This means that
  976 mistakes like \fBstrip file.o\fP or \fBecho >file.o\fP will be detected even if the
  977 object file is made writeable, but a modification that doesn\(cqt change the file
  978 size will not.
  979 .RE
  980 .sp
  981 .RS 4
  982 .ie n \{\
  983 \h'-04'\(bu\h'+03'\c
  984 .\}
  985 .el \{\
  986 .  sp -1
  987 .  IP \(bu 2.3
  988 .\}
  989 Programs that don\(cqt expect that files from two different identical
  990 compilations are hard links to each other can fail.
  991 .RE
  992 .sp
  993 .RS 4
  994 .ie n \{\
  995 \h'-04'\(bu\h'+03'\c
  996 .\}
  997 .el \{\
  998 .  sp -1
  999 .  IP \(bu 2.3
 1000 .\}
 1001 Programs that rely on modification times (like \fBmake\fP) can be confused if
 1002 several users (or one user with several build trees) use the same cache
 1003 directory. The reason for this is that the object files share i\-nodes and
 1004 therefore modification times. If \fBfile.o\fP is in build tree \fBA\fP (hard\-linked
 1005 from the cache) and \fBfile.o\fP then is produced by ccache in build tree \fBB\fP by
 1006 hard\-linking from the cache, the modification timestamp will be updated for
 1007 \fBfile.o\fP in build tree \fBA\fP as well. This can retrigger relinking in build tree
 1008 \fBA\fP even though nothing really has changed.
 1009 .RE
 1010 .RE
 1011 .sp
 1012 \fBhash_dir\fP (\fBCCACHE_HASHDIR\fP or \fBCCACHE_NOHASHDIR\fP, see \fIBoolean values\fP above)
 1013 .RS 4
 1014 If true (which is the default), ccache will include the current working
 1015 directory (CWD) in the hash that is used to distinguish two compilations
 1016 when generating debug info (compiler option \fB\-g\fP with variations).
 1017 Exception: The CWD will not be included in the hash if
 1018 \fBbase_dir\fP is set (and matches the CWD) and the
 1019 compiler option \fB\-fdebug\-prefix\-map\fP is used. See also the discussion under
 1020 \fICOMPILING IN DIFFERENT DIRECTORIES\fP.
 1021 .sp
 1022 The reason for including the CWD in the hash by default is to prevent a problem
 1023 with the storage of the current working directory in the debug info of an
 1024 object file, which can lead ccache to return a cached object file that has the
 1025 working directory in the debug info set incorrectly.
 1026 .sp
 1027 You can disable this option to get cache hits when compiling the same source
 1028 code in different directories if you don\(cqt mind that CWD in the debug info
 1029 might be incorrect.
 1030 .RE
 1031 .sp
 1032 \fBignore_headers_in_manifest\fP (\fBCCACHE_IGNOREHEADERS\fP)
 1033 .RS 4
 1034 This option is a list of paths to files (or directories with headers) that
 1035 ccache will \fBnot\fP include in the manifest list that makes up the direct
 1036 mode. Note that this can cause stale cache hits if those headers do indeed
 1037 change. The list separator is semicolon on Windows systems and colon on
 1038 other systems.
 1039 .RE
 1040 .sp
 1041 \fBignore_options\fP (\fBCCACHE_IGNOREOPTIONS\fP)
 1042 .RS 4
 1043 This option is a space\-delimited list of compiler options that ccache will
 1044 exclude from the hash. Excluding a compiler option from the hash can be
 1045 useful when you know it doesn\(cqt affect the result (but ccache doesn\(cqt know
 1046 that), or when it does and you don\(cqt care. If a compiler option in the list
 1047 is suffixed with an asterisk (\fB*\fP) it will be matched as a prefix. For
 1048 example, \fB\-fmessage\-length=*\fP will match both \fB\-fmessage\-length=20\fP and
 1049 \fB\-fmessage\-length=70\fP.
 1050 .RE
 1051 .sp
 1052 \fBinode_cache\fP (\fBCCACHE_INODECACHE\fP or \fBCCACHE_NOINODECACHE\fP, see \fIBoolean values\fP above)
 1053 .RS 4
 1054 If true, enables caching of source file hashes based on device, inode and
 1055 timestamps. This will reduce the time spent on hashing included files as
 1056 the result can be resused between compilations.
 1057 .sp
 1058 The feature is still experimental and thus off by default. It is currently not
 1059 available on Windows.
 1060 .sp
 1061 The feature requires \fBtemporary_dir\fP to be located on a local filesystem.
 1062 .RE
 1063 .sp
 1064 \fBkeep_comments_cpp\fP (\fBCCACHE_COMMENTS\fP or \fBCCACHE_NOCOMMENTS\fP, see \fIBoolean values\fP above)
 1065 .RS 4
 1066 If true, ccache will not discard the comments before hashing preprocessor
 1067 output. This can be used to check documentation with \fB\-Wdocumentation\fP.
 1068 .RE
 1069 .sp
 1070 \fBlimit_multiple\fP (\fBCCACHE_LIMIT_MULTIPLE\fP)
 1071 .RS 4
 1072 Sets the limit when cleaning up. Files are deleted (in LRU order) until the
 1073 levels are below the limit. The default is 0.8 (= 80%). See
 1074 \fIAutomatic cleanup\fP for more information.
 1075 .RE
 1076 .sp
 1077 \fBlog_file\fP (\fBCCACHE_LOGFILE\fP)
 1078 .RS 4
 1079 If set to a file path, ccache will write information on what it is doing to
 1080 the specified file. This is useful for tracking down problems.
 1081 .sp
 1082 If set to \fBsyslog\fP, ccache will log using \fBsyslog()\fP instead of to a file. If
 1083 you use rsyslogd, you can add something like this to \fB/etc/rsyslog.conf\fP or a
 1084 file in \fB/etc/rsyslog.d\fP:
 1085 .sp
 1086 .if n .RS 4
 1087 .nf
 1088 .fam C
 1089 # log ccache to file
 1090 :programname, isequal, "ccache"         /var/log/ccache
 1091 # remove from syslog
 1092 & ~
 1093 .fam
 1094 .fi
 1095 .if n .RE
 1096 .RE
 1097 .sp
 1098 \fBmax_files\fP (\fBCCACHE_MAXFILES\fP)
 1099 .RS 4
 1100 This option specifies the maximum number of files to keep in the cache. Use
 1101 0 for no limit (which is the default). See also \fICACHE SIZE MANAGEMENT\fP.
 1102 .RE
 1103 .sp
 1104 \fBmax_size\fP (\fBCCACHE_MAXSIZE\fP)
 1105 .RS 4
 1106 This option specifies the maximum size of the cache. Use 0 for no limit. The
 1107 default value is 5G. Available suffixes: k, M, G, T (decimal) and Ki, Mi,
 1108 Gi, Ti (binary). The default suffix is G. See also
 1109 \fICACHE SIZE MANAGEMENT\fP.
 1110 .RE
 1111 .sp
 1112 \fBnamespace\fP (\fBCCACHE_NAMESPACE\fP)
 1113 .RS 4
 1114 If set, the namespace string will be added to the hashed data for each
 1115 compilation. This will make the associated cache entries logically separate
 1116 from cache entries with other namespaces, but they will still share the same
 1117 storage space. Cache entries can also be selectively removed from the
 1118 primary cache with the command line option \fB\-\-evict\-namespace\fP, potentially
 1119 in combination with \fB\-\-evict\-older\-than\fP.
 1120 .sp
 1121 For instance, if you use the same primary cache for several disparate projects,
 1122 you can use a unique namespace string for each one. This allows you to remove
 1123 cache entries that belong to a certain project if you stop working with that
 1124 project.
 1125 .RE
 1126 .sp
 1127 \fBpath\fP (\fBCCACHE_PATH\fP)
 1128 .RS 4
 1129 If set, ccache will search directories in this list when looking for the
 1130 real compiler. The list separator is semicolon on Windows systems and colon
 1131 on other systems. If not set, ccache will look for the first executable
 1132 matching the compiler name in the normal \fBPATH\fP that isn\(cqt a symbolic link
 1133 to ccache itself.
 1134 .RE
 1135 .sp
 1136 \fBpch_external_checksum\fP (\fBCCACHE_PCH_EXTSUM\fP or \fBCCACHE_NOPCH_EXTSUM\fP, see \fIBoolean values\fP above)
 1137 .RS 4
 1138 When this option is set, and ccache finds a precompiled header file,
 1139 ccache will look for a file with the extension \(lq.sum\(rq added
 1140 (e.g. \(lqpre.h.gch.sum\(rq), and if found, it will hash this file instead
 1141 of the precompiled header itself to work around the performance
 1142 penalty of hashing very large files.
 1143 .RE
 1144 .sp
 1145 \fBprefix_command\fP (\fBCCACHE_PREFIX\fP)
 1146 .RS 4
 1147 This option adds a list of prefixes (separated by space) to the command line
 1148 that ccache uses when invoking the compiler. See also
 1149 \fIUSING CCACHE WITH OTHER COMPILER WRAPPERS\fP.
 1150 .RE
 1151 .sp
 1152 \fBprefix_command_cpp\fP (\fBCCACHE_PREFIX_CPP\fP)
 1153 .RS 4
 1154 This option adds a list of prefixes (separated by space) to the command
 1155 line that ccache uses when invoking the preprocessor.
 1156 .RE
 1157 .sp
 1158 \fBread_only\fP (\fBCCACHE_READONLY\fP or \fBCCACHE_NOREADONLY\fP, see \fIBoolean values\fP above)
 1159 .RS 4
 1160 If true, ccache will attempt to use existing cached results, but it will not
 1161 add new results to any cache backend. Statistics counters will still be
 1162 updated, though, unless the \fBstats\fP option is set to
 1163 \fBfalse\fP.
 1164 .sp
 1165 If you are using this because your ccache directory is read\-only, you need to
 1166 set \fBtemporary_dir\fP since ccache will fail to create
 1167 temporary files otherwise. You may also want to set \fBstats\fP to
 1168 \fBfalse\fP make ccache not even try to update stats files.
 1169 .RE
 1170 .sp
 1171 \fBread_only_direct\fP (\fBCCACHE_READONLY_DIRECT\fP or \fBCCACHE_NOREADONLY_DIRECT\fP, see \fIBoolean values\fP above)
 1172 .RS 4
 1173 Just like \fBread_only\fP except that ccache will only try
 1174 to retrieve results from the cache using the direct mode, not the
 1175 preprocessor mode. See documentation for \fBread_only\fP
 1176 regarding using a read\-only ccache directory.
 1177 .RE
 1178 .sp
 1179 \fBrecache\fP (\fBCCACHE_RECACHE\fP or \fBCCACHE_NORECACHE\fP, see \fIBoolean values\fP above)
 1180 .RS 4
 1181 If true, ccache will not use any previously stored result. New results will
 1182 still be cached, possibly overwriting any pre\-existing results.
 1183 .RE
 1184 .sp
 1185 \fBreshare\fP (\fBCCACHE_RESHARE\fP or \fBCCACHE_NORESHARE\fP, see \fIBoolean values\fP above)
 1186 .RS 4
 1187 If true, ccache will write results to secondary storage even for primary
 1188 storage cache hits. The default is false.
 1189 .RE
 1190 .sp
 1191 \fBrun_second_cpp\fP (\fBCCACHE_CPP2\fP or \fBCCACHE_NOCPP2\fP, see \fIBoolean values\fP above)
 1192 .RS 4
 1193 If true, ccache will first run the preprocessor to preprocess the source
 1194 code (see \fIThe preprocessor mode\fP) and then on a cache miss run the
 1195 compiler on the source code to get hold of the object file. This is the
 1196 default.
 1197 .sp
 1198 If false, ccache will first run preprocessor to preprocess the source code and
 1199 then on a cache miss run the compiler on the \fIpreprocessed source code\fP instead
 1200 of the original source code. This makes cache misses slightly faster since the
 1201 source code only has to be preprocessed once. The downside is that some
 1202 compilers won\(cqt produce the same result (for instance diagnostics warnings)
 1203 when compiling preprocessed source code.
 1204 .sp
 1205 A solution to the above mentioned downside is to set \fBrun_second_cpp\fP to false
 1206 and pass \fB\-fdirectives\-only\fP (for GCC) or \fB\-frewrite\-includes\fP (for Clang) to
 1207 the compiler. This will cause the compiler to leave the macros and other
 1208 preprocessor information, and only process the \fB#include\fP directives. When run
 1209 in this way, the preprocessor arguments will be passed to the compiler since it
 1210 still has to do \fIsome\fP preprocessing (like macros).
 1211 .sp
 1212 This option is ignored with MSVC, as there is no way to make it compile without
 1213 preprocessing first.
 1214 .RE
 1215 .sp
 1216 \fBsecondary_storage\fP (\fBCCACHE_SECONDARY_STORAGE\fP)
 1217 .RS 4
 1218 This option specifies one or several storage backends (separated by space)
 1219 to query after the primary cache storage. See
 1220 \fISECONDARY STORAGE BACKENDS\fP for documentation of syntax and available
 1221 backends.
 1222 .sp
 1223 Examples:
 1224 .sp
 1225 .RS 4
 1226 .ie n \{\
 1227 \h'-04'\(bu\h'+03'\c
 1228 .\}
 1229 .el \{\
 1230 .  sp -1
 1231 .  IP \(bu 2.3
 1232 .\}
 1233 \fBfile:/shared/nfs/directory\fP
 1234 .RE
 1235 .sp
 1236 .RS 4
 1237 .ie n \{\
 1238 \h'-04'\(bu\h'+03'\c
 1239 .\}
 1240 .el \{\
 1241 .  sp -1
 1242 .  IP \(bu 2.3
 1243 .\}
 1244 \fBfile:///shared/nfs/one|read\-only file:///shared/nfs/two\fP
 1245 .RE
 1246 .sp
 1247 .RS 4
 1248 .ie n \{\
 1249 \h'-04'\(bu\h'+03'\c
 1250 .\}
 1251 .el \{\
 1252 .  sp -1
 1253 .  IP \(bu 2.3
 1254 .\}
 1255 \fBhttp://example.com/cache\fP
 1256 .RE
 1257 .sp
 1258 .RS 4
 1259 .ie n \{\
 1260 \h'-04'\(bu\h'+03'\c
 1261 .\}
 1262 .el \{\
 1263 .  sp -1
 1264 .  IP \(bu 2.3
 1265 .\}
 1266 \fBredis://example.com\fP
 1267 .RE
 1268 .RE
 1269 .sp
 1270 \fBsloppiness\fP (\fBCCACHE_SLOPPINESS\fP)
 1271 .RS 4
 1272 By default, ccache tries to give as few false cache hits as possible.
 1273 However, in certain situations it\(cqs possible that you know things that
 1274 ccache can\(cqt take for granted. This option makes it possible to tell
 1275 ccache to relax some checks in order to increase the hit rate. The value
 1276 should be a comma\-separated string with one or several of the following
 1277 values:
 1278 .sp
 1279 \fBclang_index_store\fP
 1280 .RS 4
 1281 Ignore the Clang compiler option \fB\-index\-store\-path\fP and its argument when
 1282 computing the manifest hash. This is useful if you use Xcode, which uses an
 1283 index store path derived from the local project path. Note that the index
 1284 store won\(cqt be updated correctly on cache hits if you enable this
 1285 sloppiness.
 1286 .RE
 1287 .sp
 1288 \fBfile_stat_matches\fP
 1289 .RS 4
 1290 Ccache normally examines a file\(cqs contents to determine whether it matches
 1291 the cached version. With this sloppiness set, ccache will consider a file
 1292 as matching its cached version if the mtimes and ctimes match.
 1293 .RE
 1294 .sp
 1295 \fBfile_stat_matches_ctime\fP
 1296 .RS 4
 1297 Ignore ctimes when \fBfile_stat_matches\fP is enabled. This can be useful when
 1298 backdating files\*(Aq mtimes in a controlled way.
 1299 .RE
 1300 .sp
 1301 \fBgcno_cwd\fP
 1302 .RS 4
 1303 By default, ccache will include the current working directory in the hash
 1304 when producing a \fB.gcno\fP file (when compiling with \fB\-ftest\-coverage\fP or
 1305 \fB\-\-coverage\fP). This is because GCC 9+ includes the current working directory
 1306 in the \fB.gcno\fP file. The \fBgcno_cwd\fP sloppiness makes ccache not hash the
 1307 current working directory so that you can get cache hits when compiling in
 1308 different directories, with the tradeoff of potentially getting an incorrect
 1309 directory in the \fB.gcno\fP file.
 1310 .RE
 1311 .sp
 1312 \fBinclude_file_ctime\fP
 1313 .RS 4
 1314 By default, ccache will not cache a file if it includes a header whose ctime
 1315 is too new. This sloppiness disables that check. See also
 1316 \fIHANDLING OF NEWLY CREATED HEADER FILES\fP.
 1317 .RE
 1318 .sp
 1319 \fBinclude_file_mtime\fP
 1320 .RS 4
 1321 By default, ccache will not cache a file if it includes a header whose mtime
 1322 is too new. This sloppiness disables that check. See also
 1323 \fIHANDLING OF NEWLY CREATED HEADER FILES\fP.
 1324 .RE
 1325 .sp
 1326 \fBivfsoverlay\fP
 1327 .RS 4
 1328 Ignore the Clang compiler option \fB\-ivfsoverlay\fP and its argument. This is
 1329 useful if you use Xcode, which uses a virtual file system (VFS) for things
 1330 like combining Objective\-C and Swift code.
 1331 .RE
 1332 .sp
 1333 \fBlocale\fP
 1334 .RS 4
 1335 Ccache includes the environment variables \fBLANG\fP, \fBLC_ALL\fP, \fBLC_CTYPE\fP and
 1336 \fBLC_MESSAGES\fP in the hash by default since they may affect localization of
 1337 compiler warning messages. Set this sloppiness to tell ccache not to do
 1338 that.
 1339 .RE
 1340 .sp
 1341 \fBpch_defines\fP
 1342 .RS 4
 1343 Be sloppy about \fB#define\fP directives when precompiling a header file. See
 1344 \fIPRECOMPILED HEADERS\fP for more information.
 1345 .RE
 1346 .sp
 1347 \fBmodules\fP
 1348 .RS 4
 1349 By default, ccache will not cache compilations if \fB\-fmodules\fP is used since
 1350 it cannot hash the state of compiler\(cqs internal representation of relevant
 1351 modules. This sloppiness allows caching in such a case. See
 1352 \fIC++ MODULES\fP for more information.
 1353 .RE
 1354 .sp
 1355 \fBsystem_headers\fP
 1356 .RS 4
 1357 By default, ccache will also include all system headers in the manifest.
 1358 With this sloppiness set, ccache will only include system headers in the
 1359 hash but not add the system header files to the list of include files.
 1360 .RE
 1361 .sp
 1362 \fBtime_macros\fP
 1363 .RS 4
 1364 Ignore \fB__DATE__\fP, \fB__TIME__\fP and \fB__TIMESTAMP__\fP being present in the
 1365 source code.
 1366 .RE
 1367 .sp
 1368 See the discussion under \fITROUBLESHOOTING\fP for more information.
 1369 .RE
 1370 .sp
 1371 \fBstats\fP (\fBCCACHE_STATS\fP or \fBCCACHE_NOSTATS\fP, see \fIBoolean values\fP above)
 1372 .RS 4
 1373 If true, ccache will update the statistics counters on each compilation.
 1374 The default is true.
 1375 .RE
 1376 .sp
 1377 \fBstats_log\fP (\fBCCACHE_STATSLOG\fP)
 1378 .RS 4
 1379 If set to a file path, ccache will write statistics counter updates to the
 1380 specified file. This is useful for getting statistics for individual builds.
 1381 To show a summary of the current stats log, use \fBccache \-\-show\-log\-stats\fP.
 1382 .if n .sp
 1383 .RS 4
 1384 .it 1 an-trap
 1385 .nr an-no-space-flag 1
 1386 .nr an-break-flag 1
 1387 .br
 1388 .ps +1
 1389 .B Note
 1390 .ps -1
 1391 .br
 1392 .sp
 1393 Lines in the stats log starting with a hash sign (\fB#\fP) are comments.
 1394 .sp .5v
 1395 .RE
 1396 .RE
 1397 .sp
 1398 \fBtemporary_dir\fP (\fBCCACHE_TEMPDIR\fP)
 1399 .RS 4
 1400 This option specifies where ccache will put temporary files. The default is
 1401 \fB/run/user/<UID>/ccache\-tmp\fP if \fB/run/user/<UID>\fP exists, otherwise
 1402 \fB<cache_dir>/tmp\fP.
 1403 .if n .sp
 1404 .RS 4
 1405 .it 1 an-trap
 1406 .nr an-no-space-flag 1
 1407 .nr an-break-flag 1
 1408 .br
 1409 .ps +1
 1410 .B Note
 1411 .ps -1
 1412 .br
 1413 .sp
 1414 In previous versions of ccache, \fBCCACHE_TEMPDIR\fP had to be on the same
 1415 filesystem as the \fBCCACHE_DIR\fP path, but this requirement has been relaxed.
 1416 .sp .5v
 1417 .RE
 1418 .RE
 1419 .sp
 1420 \fBumask\fP (\fBCCACHE_UMASK\fP)
 1421 .RS 4
 1422 This option (an octal integer) specifies the umask for files and directories
 1423 in the cache directory. This is mostly useful when you wish to share your
 1424 cache with other users.
 1425 .RE
 1426 .SH "SECONDARY STORAGE BACKENDS"
 1427 .sp
 1428 The \fBsecondary_storage\fP option lets you configure
 1429 ccache to use one or several other storage backends in addition to the primary
 1430 cache storage located in \fBcache_dir\fP. Note that cache
 1431 statistics counters will still be kept in the primary cache directory \(em secondary storage backends only store cache results and manifests.
 1432 .sp
 1433 A secondary storage backend is specified with a URL, optionally followed by a
 1434 pipe (\fB|\fP) and a pipe\-separated list of attributes. An attribute is
 1435 \fIkey\fP=\fIvalue\fP or just \fIkey\fP as a short form of \fIkey\fP=\fBtrue\fP. Attribute values
 1436 must be \c
 1437 .URL "https://en.wikipedia.org/wiki/Percent\-encoding" "percent\-encoded" ""
 1438 if they
 1439 contain percent, pipe or space characters.
 1440 .SS "Attributes for all backends"
 1441 .sp
 1442 These optional attributes are available for all secondary storage backends:
 1443 .sp
 1444 .RS 4
 1445 .ie n \{\
 1446 \h'-04'\(bu\h'+03'\c
 1447 .\}
 1448 .el \{\
 1449 .  sp -1
 1450 .  IP \(bu 2.3
 1451 .\}
 1452 \fBread\-only\fP: If \fBtrue\fP, only read from this backend, don\(cqt write. The default
 1453 is \fBfalse\fP.
 1454 .RE
 1455 .sp
 1456 .RS 4
 1457 .ie n \{\
 1458 \h'-04'\(bu\h'+03'\c
 1459 .\}
 1460 .el \{\
 1461 .  sp -1
 1462 .  IP \(bu 2.3
 1463 .\}
 1464 \fBshards\fP: A comma\-separated list of names for sharding (partitioning) the
 1465 cache entries using
 1466 .URL "https://en.wikipedia.org/wiki/Rendezvous_hashing" "Rendezvous hashing" ","
 1467 typically to spread the cache over a server cluster. When set, the storage URL
 1468 must contain an asterisk (\fB*\fP), which will be replaced by one of the shard
 1469 names to form a real URL. A shard name can optionally have an appended weight
 1470 within parentheses to indicate how much of the key space should be associated
 1471 with that shard. A shard with weight \fBw\fP will contain \fBw\fP/\fBS\fP of the cache,
 1472 where \fBS\fP is the sum of all shard weights. A weight could for instance be set
 1473 to represent the available memory for a memory cache on a specific server. The
 1474 default weight is \fB1\fP.
 1475 .sp
 1476 Examples:
 1477 .sp
 1478 .RS 4
 1479 .ie n \{\
 1480 \h'-04'\(bu\h'+03'\c
 1481 .\}
 1482 .el \{\
 1483 .  sp -1
 1484 .  IP \(bu 2.3
 1485 .\}
 1486 \fBredis://cache\-*.example.com|shards=a(3),b(1),c(1.5)\fP will put 55% (3/5.5)
 1487 of the cache on \fBredis://cache\-a.example.com\fP, 18% (1/5.5) on
 1488 \fBredis://cache\-b.example.com\fP and 27% (1.5/5.5) on
 1489 \fBredis://cache\-c.example.com\fP.
 1490 .RE
 1491 .sp
 1492 .RS 4
 1493 .ie n \{\
 1494 \h'-04'\(bu\h'+03'\c
 1495 .\}
 1496 .el \{\
 1497 .  sp -1
 1498 .  IP \(bu 2.3
 1499 .\}
 1500 \fBhttp://example.com/*|shards=alpha,beta\fP will put 50% of the cache on
 1501 \fBhttp://example.com/alpha\fP and 50% on \fBhttp://example.com/beta\fP.
 1502 .RE
 1503 .RE
 1504 .sp
 1505 .RS 4
 1506 .ie n \{\
 1507 \h'-04'\(bu\h'+03'\c
 1508 .\}
 1509 .el \{\
 1510 .  sp -1
 1511 .  IP \(bu 2.3
 1512 .\}
 1513 \fBshare\-hits\fP: If \fBtrue\fP, write hits for this backend to primary storage. The
 1514 default is \fBtrue\fP.
 1515 .RE
 1516 .SS "Storage interaction"
 1517 .sp
 1518 The table below describes the interaction between primary and secondary storage
 1519 on cache hits and misses:
 1520 .TS
 1521 allbox tab(:);
 1522 lt lt lt.
 1523 T{
 1524 .sp
 1525 \fBPrimary storage\fP
 1526 T}:T{
 1527 .sp
 1528 \fBSecondary storage\fP
 1529 T}:T{
 1530 .sp
 1531 \fBWhat happens\fP
 1532 T}
 1533 T{
 1534 .sp
 1535 miss
 1536 T}:T{
 1537 .sp
 1538 miss
 1539 T}:T{
 1540 .sp
 1541 Compile, write to primary, write to secondary[1]
 1542 T}
 1543 T{
 1544 .sp
 1545 miss
 1546 T}:T{
 1547 .sp
 1548 hit
 1549 T}:T{
 1550 .sp
 1551 Read from secondary, write to primary[2]
 1552 T}
 1553 T{
 1554 .sp
 1555 hit
 1556 T}:T{
 1557 .sp
 1558 \-
 1559 T}:T{
 1560 .sp
 1561 Read from primary, don\(cqt write to secondary[3]
 1562 T}
 1563 .TE
 1564 .sp
 1565 .sp
 1566 [1] Unless secondary storage has attribute \fBread\-only=true\fP.
 1567 .br
 1568 [2] Unless secondary storage has attribute \fBshare\-hits=false\fP.
 1569 .br
 1570 [3] Unless primary storage is set to share its cache hits with the
 1571 \fBreshare\fP option.
 1572 .SS "File storage backend"
 1573 .sp
 1574 URL format: \fBfile:DIRECTORY\fP or \fBfile://DIRECTORY\fP
 1575 .sp
 1576 This backend stores data as separate files in a directory structure below
 1577 \fBDIRECTORY\fP (an absolute path), similar (but not identical) to the primary cache
 1578 storage. A typical use case for this backend would be sharing a cache on an NFS
 1579 directory.
 1580 .if n .sp
 1581 .RS 4
 1582 .it 1 an-trap
 1583 .nr an-no-space-flag 1
 1584 .nr an-break-flag 1
 1585 .br
 1586 .ps +1
 1587 .B Important
 1588 .ps -1
 1589 .br
 1590 .sp
 1591 ccache will not perform any cleanup of the storage \(em that has to be
 1592 done by other means, for instance by running \fBccache \-\-trim\-dir\fP periodically.
 1593 .sp .5v
 1594 .RE
 1595 .sp
 1596 Examples:
 1597 .sp
 1598 .RS 4
 1599 .ie n \{\
 1600 \h'-04'\(bu\h'+03'\c
 1601 .\}
 1602 .el \{\
 1603 .  sp -1
 1604 .  IP \(bu 2.3
 1605 .\}
 1606 \fBfile:/shared/nfs/directory\fP
 1607 .RE
 1608 .sp
 1609 .RS 4
 1610 .ie n \{\
 1611 \h'-04'\(bu\h'+03'\c
 1612 .\}
 1613 .el \{\
 1614 .  sp -1
 1615 .  IP \(bu 2.3
 1616 .\}
 1617 \fBfile:///shared/nfs/directory|umask=002|update\-mtime=true\fP
 1618 .RE
 1619 .sp
 1620 Optional attributes:
 1621 .sp
 1622 .RS 4
 1623 .ie n \{\
 1624 \h'-04'\(bu\h'+03'\c
 1625 .\}
 1626 .el \{\
 1627 .  sp -1
 1628 .  IP \(bu 2.3
 1629 .\}
 1630 \fBlayout\fP: How to store file under the cache directory. Available values:
 1631 .sp
 1632 .RS 4
 1633 .ie n \{\
 1634 \h'-04'\(bu\h'+03'\c
 1635 .\}
 1636 .el \{\
 1637 .  sp -1
 1638 .  IP \(bu 2.3
 1639 .\}
 1640 \fBflat\fP: Store all files directly under the cache directory.
 1641 .RE
 1642 .sp
 1643 .RS 4
 1644 .ie n \{\
 1645 \h'-04'\(bu\h'+03'\c
 1646 .\}
 1647 .el \{\
 1648 .  sp -1
 1649 .  IP \(bu 2.3
 1650 .\}
 1651 \fBsubdirs\fP: Store files in 256 subdirectories of the cache directory.
 1652 .RE
 1653 .sp
 1654 The default is \fBsubdirs\fP.
 1655 .RE
 1656 .sp
 1657 .RS 4
 1658 .ie n \{\
 1659 \h'-04'\(bu\h'+03'\c
 1660 .\}
 1661 .el \{\
 1662 .  sp -1
 1663 .  IP \(bu 2.3
 1664 .\}
 1665 \fBumask\fP: This attribute (an octal integer) overrides the umask to use for
 1666 files and directories in the cache directory.
 1667 .RE
 1668 .sp
 1669 .RS 4
 1670 .ie n \{\
 1671 \h'-04'\(bu\h'+03'\c
 1672 .\}
 1673 .el \{\
 1674 .  sp -1
 1675 .  IP \(bu 2.3
 1676 .\}
 1677 \fBupdate\-mtime\fP: If \fBtrue\fP, update the modification time (mtime) of cache
 1678 entries that are read. The default is \fBfalse\fP.
 1679 .RE
 1680 .SS "HTTP storage backend"
 1681 .sp
 1682 URL format: \fBhttp://HOST[:PORT][/PATH]\fP
 1683 .sp
 1684 This backend stores data in an HTTP\-compatible server. The required HTTP methods
 1685 are \fBGET\fP, \fBPUT\fP and \fBDELETE\fP.
 1686 .if n .sp
 1687 .RS 4
 1688 .it 1 an-trap
 1689 .nr an-no-space-flag 1
 1690 .nr an-break-flag 1
 1691 .br
 1692 .ps +1
 1693 .B Important
 1694 .ps -1
 1695 .br
 1696 .sp
 1697 ccache will not perform any cleanup of the storage \(em that has to be
 1698 done by other means, for instance by running \fBccache \-\-trim\-dir\fP periodically.
 1699 .sp .5v
 1700 .RE
 1701 .if n .sp
 1702 .RS 4
 1703 .it 1 an-trap
 1704 .nr an-no-space-flag 1
 1705 .nr an-break-flag 1
 1706 .br
 1707 .ps +1
 1708 .B Note
 1709 .ps -1
 1710 .br
 1711 .sp
 1712 HTTPS is not supported.
 1713 .sp .5v
 1714 .RE
 1715 .if n .sp
 1716 .RS 4
 1717 .it 1 an-trap
 1718 .nr an-no-space-flag 1
 1719 .nr an-break-flag 1
 1720 .br
 1721 .ps +1
 1722 .B Tip
 1723 .ps -1
 1724 .br
 1725 .sp
 1726 See \c
 1727 .URL "https://ccache.dev/howto/http\-storage.html" "How to set up HTTP storage"
 1728 for hints on how to set up an HTTP server for use with ccache.
 1729 .sp .5v
 1730 .RE
 1731 .sp
 1732 Examples:
 1733 .sp
 1734 .RS 4
 1735 .ie n \{\
 1736 \h'-04'\(bu\h'+03'\c
 1737 .\}
 1738 .el \{\
 1739 .  sp -1
 1740 .  IP \(bu 2.3
 1741 .\}
 1742 \fBhttp://localhost\fP
 1743 .RE
 1744 .sp
 1745 .RS 4
 1746 .ie n \{\
 1747 \h'-04'\(bu\h'+03'\c
 1748 .\}
 1749 .el \{\
 1750 .  sp -1
 1751 .  IP \(bu 2.3
 1752 .\}
 1753 \fBhttp://someusername:p4ssw0rd@example.com/cache/\fP
 1754 .RE
 1755 .sp
 1756 .RS 4
 1757 .ie n \{\
 1758 \h'-04'\(bu\h'+03'\c
 1759 .\}
 1760 .el \{\
 1761 .  sp -1
 1762 .  IP \(bu 2.3
 1763 .\}
 1764 \fBhttp://localhost:8080|layout=bazel|connect\-timeout=50\fP
 1765 .RE
 1766 .sp
 1767 Optional attributes:
 1768 .sp
 1769 .RS 4
 1770 .ie n \{\
 1771 \h'-04'\(bu\h'+03'\c
 1772 .\}
 1773 .el \{\
 1774 .  sp -1
 1775 .  IP \(bu 2.3
 1776 .\}
 1777 \fBbearer\-token\fP: Bearer token used to authorize the HTTP requests.
 1778 .RE
 1779 .sp
 1780 .RS 4
 1781 .ie n \{\
 1782 \h'-04'\(bu\h'+03'\c
 1783 .\}
 1784 .el \{\
 1785 .  sp -1
 1786 .  IP \(bu 2.3
 1787 .\}
 1788 \fBconnect\-timeout\fP: Timeout (in ms) for network connection. The default is 100.
 1789 .RE
 1790 .sp
 1791 .RS 4
 1792 .ie n \{\
 1793 \h'-04'\(bu\h'+03'\c
 1794 .\}
 1795 .el \{\
 1796 .  sp -1
 1797 .  IP \(bu 2.3
 1798 .\}
 1799 \fBkeep\-alive\fP: If \fBtrue\fP, keep the HTTP connection to the storage server open
 1800 to avoid reconnects. The default is \fBtrue\fP.
 1801 .RE
 1802 .sp
 1803 .RS 4
 1804 .ie n \{\
 1805 \h'-04'\(bu\h'+03'\c
 1806 .\}
 1807 .el \{\
 1808 .  sp -1
 1809 .  IP \(bu 2.3
 1810 .\}
 1811 \fBlayout\fP: How to map key names to the path part of the URL. Available values:
 1812 .sp
 1813 .RS 4
 1814 .ie n \{\
 1815 \h'-04'\(bu\h'+03'\c
 1816 .\}
 1817 .el \{\
 1818 .  sp -1
 1819 .  IP \(bu 2.3
 1820 .\}
 1821 \fBbazel\fP: Store values in a format compatible with the Bazel HTTP caching
 1822 protocol. More specifically, the entries will be stored as 64 hex digits
 1823 under the \fB/ac/\fP part of the cache.
 1824 .if n .sp
 1825 .RS 4
 1826 .it 1 an-trap
 1827 .nr an-no-space-flag 1
 1828 .nr an-break-flag 1
 1829 .br
 1830 .ps +1
 1831 .B Note
 1832 .ps -1
 1833 .br
 1834 .sp
 1835 You may have to disable verification of action cache values in the server
 1836 for this to work since ccache entries are not valid action result metadata
 1837 values.
 1838 .sp .5v
 1839 .RE
 1840 .RE
 1841 .sp
 1842 .RS 4
 1843 .ie n \{\
 1844 \h'-04'\(bu\h'+03'\c
 1845 .\}
 1846 .el \{\
 1847 .  sp -1
 1848 .  IP \(bu 2.3
 1849 .\}
 1850 \fBflat\fP: Append the key directly to the path part of the URL (with a leading
 1851 slash if needed).
 1852 .RE
 1853 .sp
 1854 .RS 4
 1855 .ie n \{\
 1856 \h'-04'\(bu\h'+03'\c
 1857 .\}
 1858 .el \{\
 1859 .  sp -1
 1860 .  IP \(bu 2.3
 1861 .\}
 1862 \fBsubdirs\fP: Append the first two characters of the key to the URL (with a
 1863 leading slash if needed), followed by a slash and the rest of the key. This
 1864 divides the entries into 256 buckets.
 1865 .RE
 1866 .sp
 1867 The default is \fBsubdirs\fP.
 1868 .RE
 1869 .sp
 1870 .RS 4
 1871 .ie n \{\
 1872 \h'-04'\(bu\h'+03'\c
 1873 .\}
 1874 .el \{\
 1875 .  sp -1
 1876 .  IP \(bu 2.3
 1877 .\}
 1878 \fBoperation\-timeout\fP: Timeout (in ms) for HTTP requests. The default is 10000.
 1879 .RE
 1880 .SS "Redis storage backend"
 1881 .sp
 1882 URL format: \fBredis://[[USERNAME:]PASSWORD@]HOST[:PORT][/DBNUMBER]\fP
 1883 .sp
 1884 This backend stores data in a \c
 1885 .URL "https://redis.io" "Redis" ""
 1886 (or Redis\-compatible)
 1887 server. There are implementations for both memory\-based and disk\-based storage.
 1888 \fBPORT\fP defaults to \fB6379\fP and \fBDBNUMBER\fP defaults to \fB0\fP.
 1889 .if n .sp
 1890 .RS 4
 1891 .it 1 an-trap
 1892 .nr an-no-space-flag 1
 1893 .nr an-break-flag 1
 1894 .br
 1895 .ps +1
 1896 .B Note
 1897 .ps -1
 1898 .br
 1899 .sp
 1900 ccache will not perform any cleanup of the Redis storage, but you can
 1901 .URL "https://redis.io/topics/lru\-cache" "configure LRU eviction" "."
 1902 .sp .5v
 1903 .RE
 1904 .if n .sp
 1905 .RS 4
 1906 .it 1 an-trap
 1907 .nr an-no-space-flag 1
 1908 .nr an-break-flag 1
 1909 .br
 1910 .ps +1
 1911 .B Tip
 1912 .ps -1
 1913 .br
 1914 .sp
 1915 See \c
 1916 .URL "https://ccache.dev/howto/redis\-storage.html" "How to set up Redis
 1917 storage"  for hints on setting up a Redis server for use with ccache.
 1918 .sp .5v
 1919 .RE
 1920 .if n .sp
 1921 .RS 4
 1922 .it 1 an-trap
 1923 .nr an-no-space-flag 1
 1924 .nr an-break-flag 1
 1925 .br
 1926 .ps +1
 1927 .B Tip
 1928 .ps -1
 1929 .br
 1930 .sp
 1931 You can set up a cluster of Redis servers using the \fBshards\fP attribute
 1932 described in \fISECONDARY STORAGE BACKENDS\fP.
 1933 .sp .5v
 1934 .RE
 1935 .sp
 1936 Examples:
 1937 .sp
 1938 .RS 4
 1939 .ie n \{\
 1940 \h'-04'\(bu\h'+03'\c
 1941 .\}
 1942 .el \{\
 1943 .  sp -1
 1944 .  IP \(bu 2.3
 1945 .\}
 1946 \fBredis://localhost\fP
 1947 .RE
 1948 .sp
 1949 .RS 4
 1950 .ie n \{\
 1951 \h'-04'\(bu\h'+03'\c
 1952 .\}
 1953 .el \{\
 1954 .  sp -1
 1955 .  IP \(bu 2.3
 1956 .\}
 1957 \fBredis://p4ssw0rd@cache.example.com:6379/0|connect\-timeout=50\fP
 1958 .RE
 1959 .sp
 1960 Optional attributes:
 1961 .sp
 1962 .RS 4
 1963 .ie n \{\
 1964 \h'-04'\(bu\h'+03'\c
 1965 .\}
 1966 .el \{\
 1967 .  sp -1
 1968 .  IP \(bu 2.3
 1969 .\}
 1970 \fBconnect\-timeout\fP: Timeout (in ms) for network connection. The default is 100.
 1971 .RE
 1972 .sp
 1973 .RS 4
 1974 .ie n \{\
 1975 \h'-04'\(bu\h'+03'\c
 1976 .\}
 1977 .el \{\
 1978 .  sp -1
 1979 .  IP \(bu 2.3
 1980 .\}
 1981 \fBoperation\-timeout\fP: Timeout (in ms) for Redis commands. The default is 10000.
 1982 .RE
 1983 .SH "CACHE SIZE MANAGEMENT"
 1984 .sp
 1985 By default, ccache has a 5 GB limit on the total size of files in the cache and
 1986 no limit on the number of files. You can set different limits using the command
 1987 line options \fB\-M\fP/\fB\-\-max\-size\fP and \fB\-F\fP/\fB\-\-max\-files\fP. Use the
 1988 \fB\-s\fP/\fB\-\-show\-stats\fP option to see the cache size and the currently configured
 1989 limits (in addition to other various statistics).
 1990 .sp
 1991 Cleanup can be triggered in two different ways: automatic and manual.
 1992 .SS "Automatic cleanup"
 1993 .sp
 1994 Ccache maintains counters for various statistics about the cache, including the
 1995 size and number of all cached files. In order to improve performance and reduce
 1996 issues with concurrent ccache invocations, there is one statistics file for
 1997 each of the sixteen subdirectories in the cache.
 1998 .sp
 1999 After a new compilation result has been written to the cache, ccache will
 2000 update the size and file number statistics for the subdirectory (one of
 2001 sixteen) to which the result was written. Then, if the size counter for said
 2002 subdirectory is greater than \fBmax_size / 16\fP or the file number counter is
 2003 greater than \fBmax_files / 16\fP, automatic cleanup is triggered.
 2004 .sp
 2005 When automatic cleanup is triggered for a subdirectory in the cache, ccache
 2006 will:
 2007 .sp
 2008 .RS 4
 2009 .ie n \{\
 2010 \h'-04' 1.\h'+01'\c
 2011 .\}
 2012 .el \{\
 2013 .  sp -1
 2014 .  IP " 1." 4.2
 2015 .\}
 2016 Count all files in the subdirectory and compute their aggregated size.
 2017 .RE
 2018 .sp
 2019 .RS 4
 2020 .ie n \{\
 2021 \h'-04' 2.\h'+01'\c
 2022 .\}
 2023 .el \{\
 2024 .  sp -1
 2025 .  IP " 2." 4.2
 2026 .\}
 2027 Remove files in LRU (least recently used) order until the size is at most
 2028 \fBlimit_multiple * max_size / 16\fP and the number of files is at most
 2029 \fBlimit_multiple * max_files / 16\fP, where
 2030 \fBlimit_multiple\fP, \fBmax_size\fP
 2031 and \fBmax_files\fP are configuration options.
 2032 .RE
 2033 .sp
 2034 .RS 4
 2035 .ie n \{\
 2036 \h'-04' 3.\h'+01'\c
 2037 .\}
 2038 .el \{\
 2039 .  sp -1
 2040 .  IP " 3." 4.2
 2041 .\}
 2042 Set the size and file number counters to match the files that were kept.
 2043 .RE
 2044 .sp
 2045 The reason for removing more files than just those needed to not exceed the max
 2046 limits is that a cleanup is a fairly slow operation, so it would not be a good
 2047 idea to trigger it often, like after each cache miss.
 2048 .sp
 2049 The LRU cleanup makes use of the file modification time (mtime) of cache
 2050 entries; ccache updates mtime of the cache entries read on a cache hit to mark
 2051 them as "recently used".
 2052 .SS "Manual cleanup"
 2053 .sp
 2054 You can run \fBccache \-c/\-\-cleanup\fP to force cleanup of the whole cache, i.e. all
 2055 of the sixteen subdirectories. This will recalculate the statistics counters
 2056 and make sure that the configuration options \fBmax_size\fP and
 2057 \fBmax_files\fP are not exceeded. Note that
 2058 \fBlimit_multiple\fP is not taken into account for manual
 2059 cleanup.
 2060 .SH "CACHE COMPRESSION"
 2061 .sp
 2062 Ccache will by default compress all data it puts into the cache using the
 2063 compression algorithm \c
 2064 .URL "http://zstd.net" "Zstandard" ""
 2065 (zstd) using compression level
 2066 1. The algorithm is fast enough that there should be little reason to turn off
 2067 compression to gain performance. One exception is if the cache is located on a
 2068 compressed file system, in which case the compression performed by ccache of
 2069 course is redundant. See the documentation for the configuration options
 2070 \fBcompression\fP and
 2071 \fBcompression_level\fP for more information.
 2072 .sp
 2073 You can use the command line option \fB\-x\fP/\fB\-\-show\-compression\fP to print
 2074 information related to compression. Example:
 2075 .sp
 2076 .if n .RS 4
 2077 .nf
 2078 .fam C
 2079 Total data:           14.8 GB (16.0 GB disk blocks)
 2080 Compressed data:      11.3 GB (30.6% of original size)
 2081   Original size:      36.9 GB
 2082   Compression ratio: 3.267 x  (69.4% space savings)
 2083 Incompressible data:   3.5 GB
 2084 .fam
 2085 .fi
 2086 .if n .RE
 2087 .sp
 2088 Notes:
 2089 .sp
 2090 .RS 4
 2091 .ie n \{\
 2092 \h'-04'\(bu\h'+03'\c
 2093 .\}
 2094 .el \{\
 2095 .  sp -1
 2096 .  IP \(bu 2.3
 2097 .\}
 2098 The \(lqdisk blocks\(rq size is the cache size when taking disk block size into
 2099 account. This value should match the \(lqCache size\(rq value from \(lqccache
 2100 \-\-show\-stats\(rq. The other size numbers refer to actual content sizes.
 2101 .RE
 2102 .sp
 2103 .RS 4
 2104 .ie n \{\
 2105 \h'-04'\(bu\h'+03'\c
 2106 .\}
 2107 .el \{\
 2108 .  sp -1
 2109 .  IP \(bu 2.3
 2110 .\}
 2111 \(lqCompressed data\(rq refers to result and manifest files stored in the cache.
 2112 .RE
 2113 .sp
 2114 .RS 4
 2115 .ie n \{\
 2116 \h'-04'\(bu\h'+03'\c
 2117 .\}
 2118 .el \{\
 2119 .  sp -1
 2120 .  IP \(bu 2.3
 2121 .\}
 2122 \(lqIncompressible data\(rq refers to files that are always stored uncompressed
 2123 (triggered by enabling \fBfile_clone\fP or
 2124 \fBhard_link\fP) or unknown files (for instance files
 2125 created by older ccache versions).
 2126 .RE
 2127 .sp
 2128 .RS 4
 2129 .ie n \{\
 2130 \h'-04'\(bu\h'+03'\c
 2131 .\}
 2132 .el \{\
 2133 .  sp -1
 2134 .  IP \(bu 2.3
 2135 .\}
 2136 The compression ratio is affected by
 2137 \fBcompression_level\fP.
 2138 .RE
 2139 .sp
 2140 The cache data can also be recompressed to another compression level (or made
 2141 uncompressed) with the command line option \fB\-X\fP/\fB\-\-recompress\fP. If you choose to
 2142 disable compression by default or to use a low compression level, you can
 2143 (re)compress newly cached data with a higher compression level after the build
 2144 or at another time when there are more CPU cycles available, for instance every
 2145 night. Full recompression potentially takes a lot of time, but only files that
 2146 are currently compressed with a different level than the target level will be
 2147 recompressed.
 2148 .SH "CACHE STATISTICS"
 2149 .sp
 2150 \fBccache \-\-show\-stats\fP shows a summary of statistics, including cache size,
 2151 cleanups (number of performed cleanups, either implicitly due to a cache size
 2152 limit being reached or due to explicit \fBccache \-c\fP calls), overall hit rate, hit
 2153 rate for direct/preprocessed modes
 2154 and hit rate for primary and secondary storage.
 2155 .sp
 2156 The summary also includes counters called \(lqErrors\(rq and \(lqUncacheable\(rq, which
 2157 are sums of more detailed counters. To see those detailed counters, use the
 2158 \fB\-v\fP/\fB\-\-verbose\fP flag. The verbose mode can show the following counters:
 2159 .TS
 2160 allbox tab(:);
 2161 lt lt.
 2162 T{
 2163 .sp
 2164 \fBCounter\fP
 2165 T}:T{
 2166 .sp
 2167 \fBDescription\fP
 2168 T}
 2169 T{
 2170 .sp
 2171 Autoconf compile/link
 2172 T}:T{
 2173 .sp
 2174 Uncacheable compilation or linking by an Autoconf test.
 2175 T}
 2176 T{
 2177 .sp
 2178 Bad compiler arguments
 2179 T}:T{
 2180 .sp
 2181 Malformed compiler argument, e.g. missing a value for a compiler option that
 2182 requires an argument or failure to read a file specified by a compiler option
 2183 argument.
 2184 T}
 2185 T{
 2186 .sp
 2187 Called for linking
 2188 T}:T{
 2189 .sp
 2190 The compiler was called for linking, not compiling. Ccache only supports
 2191 compilation of a single file, i.e. calling the compiler with the \fB\-c\fP option to
 2192 produce a single object file from a single source file.
 2193 T}
 2194 T{
 2195 .sp
 2196 Called for preprocessing
 2197 T}:T{
 2198 .sp
 2199 The compiler was called for preprocessing, not compiling.
 2200 T}
 2201 T{
 2202 .sp
 2203 Could not use modules
 2204 T}:T{
 2205 .sp
 2206 Preconditions for using C++ MODULES were not fulfilled.
 2207 T}
 2208 T{
 2209 .sp
 2210 Could not use precompiled header
 2211 T}:T{
 2212 .sp
 2213 Preconditions for using precompiled headers were not
 2214 fulfilled.
 2215 T}
 2216 T{
 2217 .sp
 2218 Could not write to output file
 2219 T}:T{
 2220 .sp
 2221 The output path specified with \fB\-o\fP could not be written to.
 2222 T}
 2223 T{
 2224 .sp
 2225 Compilation failed
 2226 T}:T{
 2227 .sp
 2228 The compilation failed. No result stored in the cache.
 2229 T}
 2230 T{
 2231 .sp
 2232 Compiler check failed
 2233 T}:T{
 2234 .sp
 2235 A compiler check program specified by
 2236 \fBcompiler_check\fP (\fBCCACHE_COMPILERCHECK\fP) failed.
 2237 T}
 2238 T{
 2239 .sp
 2240 Compiler produced empty output
 2241 T}:T{
 2242 .sp
 2243 The compiler\(cqs output file (typically an object file) was empty after
 2244 compilation.
 2245 T}
 2246 T{
 2247 .sp
 2248 Compiler produced no output
 2249 T}:T{
 2250 .sp
 2251 The compiler\(cqs output file (typically an object file) was missing after
 2252 compilation.
 2253 T}
 2254 T{
 2255 .sp
 2256 Could not find the compiler
 2257 T}:T{
 2258 .sp
 2259 The compiler to execute could not be found.
 2260 T}
 2261 T{
 2262 .sp
 2263 Error hashing extra file
 2264 T}:T{
 2265 .sp
 2266 Failure reading a file specified by
 2267 \fBextra_files_to_hash\fP (\fBCCACHE_EXTRAFILES\fP).
 2268 T}
 2269 T{
 2270 .sp
 2271 Forced recache
 2272 T}:T{
 2273 .sp
 2274 \fBCCACHE_RECACHE\fP was used to overwrite an existing result.
 2275 T}
 2276 T{
 2277 .sp
 2278 Internal error
 2279 T}:T{
 2280 .sp
 2281 Unexpected failure, e.g. due to problems reading/writing the cache.
 2282 T}
 2283 T{
 2284 .sp
 2285 Missing cache file
 2286 T}:T{
 2287 .sp
 2288 A file was unexpectedly missing from the cache. This only happens in rare
 2289 situations, e.g. if one ccache instance is about to get a file from the cache
 2290 while another instance removed the file as part of cache cleanup.
 2291 T}
 2292 T{
 2293 .sp
 2294 Multiple source files
 2295 T}:T{
 2296 .sp
 2297 The compiler was called to compile multiple source files in one go. This is not
 2298 supported by ccache.
 2299 T}
 2300 T{
 2301 .sp
 2302 No input file
 2303 T}:T{
 2304 .sp
 2305 No input file was specified to the compiler.
 2306 T}
 2307 T{
 2308 .sp
 2309 Output to stdout
 2310 T}:T{
 2311 .sp
 2312 The compiler was instructed to write its output to standard output using \fB\-o \-\fP.
 2313 This is not supported by ccache.
 2314 T}
 2315 T{
 2316 .sp
 2317 Preprocessing failed
 2318 T}:T{
 2319 .sp
 2320 Preprocessing the source code using the compiler\(cqs \fB\-E\fP option failed.
 2321 T}
 2322 T{
 2323 .sp
 2324 Unsupported code directive
 2325 T}:T{
 2326 .sp
 2327 Code like the assembler \fB.incbin\fP directive was found. This is not supported
 2328 by ccache.
 2329 T}
 2330 T{
 2331 .sp
 2332 Unsupported compiler option
 2333 T}:T{
 2334 .sp
 2335 A compiler option not supported by ccache was found.
 2336 T}
 2337 T{
 2338 .sp
 2339 Unsupported environment variable
 2340 T}:T{
 2341 .sp
 2342 An environment variable not supported by ccache was set.
 2343 T}
 2344 T{
 2345 .sp
 2346 Unsupported source language
 2347 T}:T{
 2348 .sp
 2349 A source language e.g. specified with \fB\-x\fP was unsupported by ccache.
 2350 T}
 2351 .TE
 2352 .sp
 2353 .SH "HOW CCACHE WORKS"
 2354 .sp
 2355 The basic idea is to detect when you are compiling exactly the same code a
 2356 second time and reuse the previously produced output. The detection is done by
 2357 hashing different kinds of information that should be unique for the
 2358 compilation and then using the hash sum to identify the cached output. Ccache
 2359 uses BLAKE3, a very fast cryptographic hash algorithm, for the hashing. On a
 2360 cache hit, ccache is able to supply all of the correct compiler outputs
 2361 (including all warnings, dependency file, etc) from the cache. Data stored in
 2362 the cache is checksummed with XXH3, an extremely fast non\-cryptographic
 2363 algorithm, to detect corruption.
 2364 .sp
 2365 Ccache has two ways of gathering information used to look up results in the
 2366 cache:
 2367 .sp
 2368 .RS 4
 2369 .ie n \{\
 2370 \h'-04'\(bu\h'+03'\c
 2371 .\}
 2372 .el \{\
 2373 .  sp -1
 2374 .  IP \(bu 2.3
 2375 .\}
 2376 the \fBpreprocessor mode\fP, where ccache runs the preprocessor on the source
 2377 code and hashes the result
 2378 .RE
 2379 .sp
 2380 .RS 4
 2381 .ie n \{\
 2382 \h'-04'\(bu\h'+03'\c
 2383 .\}
 2384 .el \{\
 2385 .  sp -1
 2386 .  IP \(bu 2.3
 2387 .\}
 2388 the \fBdirect mode\fP, where ccache hashes the source code and include files
 2389 directly
 2390 .RE
 2391 .sp
 2392 The direct mode is generally faster since running the preprocessor has some
 2393 overhead.
 2394 .sp
 2395 If no previous result is detected (i.e., there is a cache miss) using the direct
 2396 mode, ccache will fall back to the preprocessor mode unless the \fBdepend mode\fP is
 2397 enabled. In the depend mode, ccache never runs the preprocessor, not even on
 2398 cache misses. Read more in \fIThe depend mode\fP below.
 2399 .SS "Common hashed information"
 2400 .sp
 2401 The following information is always included in the hash:
 2402 .sp
 2403 .RS 4
 2404 .ie n \{\
 2405 \h'-04'\(bu\h'+03'\c
 2406 .\}
 2407 .el \{\
 2408 .  sp -1
 2409 .  IP \(bu 2.3
 2410 .\}
 2411 the extension used by the compiler for a file with preprocessor output
 2412 (normally \fB.i\fP for C code and \fB.ii\fP for C++ code)
 2413 .RE
 2414 .sp
 2415 .RS 4
 2416 .ie n \{\
 2417 \h'-04'\(bu\h'+03'\c
 2418 .\}
 2419 .el \{\
 2420 .  sp -1
 2421 .  IP \(bu 2.3
 2422 .\}
 2423 the compiler\(cqs size and modification time (or other compiler\-specific
 2424 information specified by \fBcompiler_check\fP)
 2425 .RE
 2426 .sp
 2427 .RS 4
 2428 .ie n \{\
 2429 \h'-04'\(bu\h'+03'\c
 2430 .\}
 2431 .el \{\
 2432 .  sp -1
 2433 .  IP \(bu 2.3
 2434 .\}
 2435 the name of the compiler
 2436 .RE
 2437 .sp
 2438 .RS 4
 2439 .ie n \{\
 2440 \h'-04'\(bu\h'+03'\c
 2441 .\}
 2442 .el \{\
 2443 .  sp -1
 2444 .  IP \(bu 2.3
 2445 .\}
 2446 the current directory (if \fBhash_dir\fP is enabled)
 2447 .RE
 2448 .sp
 2449 .RS 4
 2450 .ie n \{\
 2451 \h'-04'\(bu\h'+03'\c
 2452 .\}
 2453 .el \{\
 2454 .  sp -1
 2455 .  IP \(bu 2.3
 2456 .\}
 2457 contents of files specified by
 2458 \fBextra_files_to_hash\fP (if any)
 2459 .RE
 2460 .SS "The preprocessor mode"
 2461 .sp
 2462 In the preprocessor mode, the hash is formed of the common information and:
 2463 .sp
 2464 .RS 4
 2465 .ie n \{\
 2466 \h'-04'\(bu\h'+03'\c
 2467 .\}
 2468 .el \{\
 2469 .  sp -1
 2470 .  IP \(bu 2.3
 2471 .\}
 2472 the preprocessor output from running the compiler with \fB\-E\fP
 2473 .RE
 2474 .sp
 2475 .RS 4
 2476 .ie n \{\
 2477 \h'-04'\(bu\h'+03'\c
 2478 .\}
 2479 .el \{\
 2480 .  sp -1
 2481 .  IP \(bu 2.3
 2482 .\}
 2483 the command line options except those that affect include files (\fB\-I\fP,
 2484 \fB\-include\fP, \fB\-D\fP, etc; the theory is that these command line options will
 2485 change the preprocessor output if they have any effect at all)
 2486 .RE
 2487 .sp
 2488 .RS 4
 2489 .ie n \{\
 2490 \h'-04'\(bu\h'+03'\c
 2491 .\}
 2492 .el \{\
 2493 .  sp -1
 2494 .  IP \(bu 2.3
 2495 .\}
 2496 any standard error output generated by the preprocessor
 2497 .RE
 2498 .sp
 2499 Based on the hash, the cached compilation result can be looked up directly in
 2500 the cache.
 2501 .SS "The direct mode"
 2502 .sp
 2503 In the direct mode, the hash is formed of the common information and:
 2504 .sp
 2505 .RS 4
 2506 .ie n \{\
 2507 \h'-04'\(bu\h'+03'\c
 2508 .\}
 2509 .el \{\
 2510 .  sp -1
 2511 .  IP \(bu 2.3
 2512 .\}
 2513 the input source file
 2514 .RE
 2515 .sp
 2516 .RS 4
 2517 .ie n \{\
 2518 \h'-04'\(bu\h'+03'\c
 2519 .\}
 2520 .el \{\
 2521 .  sp -1
 2522 .  IP \(bu 2.3
 2523 .\}
 2524 the compiler options
 2525 .RE
 2526 .sp
 2527 Based on the hash, a data structure called \(lqmanifest\(rq is looked up in the
 2528 cache. The manifest contains:
 2529 .sp
 2530 .RS 4
 2531 .ie n \{\
 2532 \h'-04'\(bu\h'+03'\c
 2533 .\}
 2534 .el \{\
 2535 .  sp -1
 2536 .  IP \(bu 2.3
 2537 .\}
 2538 references to cached compilation results (object file, dependency file, etc)
 2539 that were produced by previous compilations that matched the hash
 2540 .RE
 2541 .sp
 2542 .RS 4
 2543 .ie n \{\
 2544 \h'-04'\(bu\h'+03'\c
 2545 .\}
 2546 .el \{\
 2547 .  sp -1
 2548 .  IP \(bu 2.3
 2549 .\}
 2550 paths to the include files that were read at the time the compilation results
 2551 were stored in the cache
 2552 .RE
 2553 .sp
 2554 .RS 4
 2555 .ie n \{\
 2556 \h'-04'\(bu\h'+03'\c
 2557 .\}
 2558 .el \{\
 2559 .  sp -1
 2560 .  IP \(bu 2.3
 2561 .\}
 2562 hash sums of the include files at the time the compilation results were
 2563 stored in the cache
 2564 .RE
 2565 .sp
 2566 The current contents of the include files are then hashed and compared to the
 2567 information in the manifest. If there is a match, ccache knows the result of
 2568 the compilation. If there is no match, ccache falls back to running the
 2569 preprocessor. The output from the preprocessor is parsed to find the include
 2570 files that were read. The paths and hash sums of those include files are then
 2571 stored in the manifest along with information about the produced compilation
 2572 result.
 2573 .sp
 2574 There is a catch with the direct mode: header files that were used by the
 2575 compiler are recorded, but header files that were \fBnot\fP used, but would have
 2576 been used if they existed, are not. So, when ccache checks if a result can be
 2577 taken from the cache, it currently can\(cqt check if the existence of a new header
 2578 file should invalidate the result. In practice, the direct mode is safe to use
 2579 in the absolute majority of cases.
 2580 .sp
 2581 The direct mode will be disabled if any of the following holds:
 2582 .sp
 2583 .RS 4
 2584 .ie n \{\
 2585 \h'-04'\(bu\h'+03'\c
 2586 .\}
 2587 .el \{\
 2588 .  sp -1
 2589 .  IP \(bu 2.3
 2590 .\}
 2591 \fBdirect_mode\fP is false
 2592 .RE
 2593 .sp
 2594 .RS 4
 2595 .ie n \{\
 2596 \h'-04'\(bu\h'+03'\c
 2597 .\}
 2598 .el \{\
 2599 .  sp -1
 2600 .  IP \(bu 2.3
 2601 .\}
 2602 a modification time of one of the include files is too new (needed to avoid a
 2603 race condition)
 2604 .RE
 2605 .sp
 2606 .RS 4
 2607 .ie n \{\
 2608 \h'-04'\(bu\h'+03'\c
 2609 .\}
 2610 .el \{\
 2611 .  sp -1
 2612 .  IP \(bu 2.3
 2613 .\}
 2614 a compiler option not supported by the direct mode is used:
 2615 .sp
 2616 .RS 4
 2617 .ie n \{\
 2618 \h'-04'\(bu\h'+03'\c
 2619 .\}
 2620 .el \{\
 2621 .  sp -1
 2622 .  IP \(bu 2.3
 2623 .\}
 2624 a \fB\-Wp,*\fP compiler option other than \fB\-Wp,\-MD,<path>\fP, \fB\-Wp,\-MMD,<path>\fP
 2625 and \fB\-Wp,\-D<define>\fP
 2626 .RE
 2627 .sp
 2628 .RS 4
 2629 .ie n \{\
 2630 \h'-04'\(bu\h'+03'\c
 2631 .\}
 2632 .el \{\
 2633 .  sp -1
 2634 .  IP \(bu 2.3
 2635 .\}
 2636 \fB\-Xpreprocessor\fP
 2637 .RE
 2638 .RE
 2639 .sp
 2640 .RS 4
 2641 .ie n \{\
 2642 \h'-04'\(bu\h'+03'\c
 2643 .\}
 2644 .el \{\
 2645 .  sp -1
 2646 .  IP \(bu 2.3
 2647 .\}
 2648 the string \fB__TIME__\fP is present in the source code
 2649 .RE
 2650 .SS "The depend mode"
 2651 .sp
 2652 If the depend mode is enabled, ccache will not use the preprocessor at all. The
 2653 hash used to identify results in the cache will be based on the direct mode
 2654 hash described above plus information about include files read from the
 2655 dependency file generated by the compiler with \fB\-MD\fP or \fB\-MMD\fP.
 2656 .sp
 2657 Advantages:
 2658 .sp
 2659 .RS 4
 2660 .ie n \{\
 2661 \h'-04'\(bu\h'+03'\c
 2662 .\}
 2663 .el \{\
 2664 .  sp -1
 2665 .  IP \(bu 2.3
 2666 .\}
 2667 The ccache overhead of a cache miss will be much smaller.
 2668 .RE
 2669 .sp
 2670 .RS 4
 2671 .ie n \{\
 2672 \h'-04'\(bu\h'+03'\c
 2673 .\}
 2674 .el \{\
 2675 .  sp -1
 2676 .  IP \(bu 2.3
 2677 .\}
 2678 Not running the preprocessor at all can be good if compilation is performed
 2679 remotely, for instance when using distcc or similar; ccache then won\(cqt make
 2680 potentially costly preprocessor calls on the local machine.
 2681 .RE
 2682 .sp
 2683 Disadvantages:
 2684 .sp
 2685 .RS 4
 2686 .ie n \{\
 2687 \h'-04'\(bu\h'+03'\c
 2688 .\}
 2689 .el \{\
 2690 .  sp -1
 2691 .  IP \(bu 2.3
 2692 .\}
 2693 The cache hit rate will likely be lower since any change to compiler options
 2694 or source code will make the hash different. Compare this with the default
 2695 setup where ccache will fall back to the preprocessor mode, which is tolerant
 2696 to some types of changes of compiler options and source code changes.
 2697 .RE
 2698 .sp
 2699 .RS 4
 2700 .ie n \{\
 2701 \h'-04'\(bu\h'+03'\c
 2702 .\}
 2703 .el \{\
 2704 .  sp -1
 2705 .  IP \(bu 2.3
 2706 .\}
 2707 If \-MD is used, the manifest entries will include system header files as
 2708 well, thus slowing down cache hits slightly, just as using \-MD slows down
 2709 make.
 2710 .RE
 2711 .sp
 2712 .RS 4
 2713 .ie n \{\
 2714 \h'-04'\(bu\h'+03'\c
 2715 .\}
 2716 .el \{\
 2717 .  sp -1
 2718 .  IP \(bu 2.3
 2719 .\}
 2720 If \-MMD is used, the manifest entries will not include system header files,
 2721 which means ccache will ignore changes in them.
 2722 .RE
 2723 .sp
 2724 The depend mode will be disabled if any of the following holds:
 2725 .sp
 2726 .RS 4
 2727 .ie n \{\
 2728 \h'-04'\(bu\h'+03'\c
 2729 .\}
 2730 .el \{\
 2731 .  sp -1
 2732 .  IP \(bu 2.3
 2733 .\}
 2734 \fBdepend_mode\fP is false.
 2735 .RE
 2736 .sp
 2737 .RS 4
 2738 .ie n \{\
 2739 \h'-04'\(bu\h'+03'\c
 2740 .\}
 2741 .el \{\
 2742 .  sp -1
 2743 .  IP \(bu 2.3
 2744 .\}
 2745 \fBrun_second_cpp\fP is false.
 2746 .RE
 2747 .sp
 2748 .RS 4
 2749 .ie n \{\
 2750 \h'-04'\(bu\h'+03'\c
 2751 .\}
 2752 .el \{\
 2753 .  sp -1
 2754 .  IP \(bu 2.3
 2755 .\}
 2756 The compiler is not generating dependencies using \fB\-MD\fP or \fB\-MMD\fP.
 2757 .RE
 2758 .SH "HANDLING OF NEWLY CREATED HEADER FILES"
 2759 .sp
 2760 If modification time (mtime) or status change time (ctime) of one of the include
 2761 files is the same second as the time compilation is being done, ccache disables
 2762 the direct mode (or, in the case of a precompiled
 2763 header, disables caching completely). This done as a safety measure to avoid a
 2764 race condition (see below).
 2765 .sp
 2766 To be able to use a newly created header files in direct mode (or use a newly
 2767 precompiled header), either:
 2768 .sp
 2769 .RS 4
 2770 .ie n \{\
 2771 \h'-04'\(bu\h'+03'\c
 2772 .\}
 2773 .el \{\
 2774 .  sp -1
 2775 .  IP \(bu 2.3
 2776 .\}
 2777 create the include file earlier in the build process, or
 2778 .RE
 2779 .sp
 2780 .RS 4
 2781 .ie n \{\
 2782 \h'-04'\(bu\h'+03'\c
 2783 .\}
 2784 .el \{\
 2785 .  sp -1
 2786 .  IP \(bu 2.3
 2787 .\}
 2788 set \fBsloppiness\fP to
 2789 \fBinclude_file_ctime,include_file_mtime\fP if you are willing to take the risk,
 2790 for instance if you know that your build system is robust enough not to
 2791 trigger the race condition.
 2792 .RE
 2793 .sp
 2794 For reference, the race condition mentioned above consists of these events:
 2795 .sp
 2796 .RS 4
 2797 .ie n \{\
 2798 \h'-04' 1.\h'+01'\c
 2799 .\}
 2800 .el \{\
 2801 .  sp -1
 2802 .  IP " 1." 4.2
 2803 .\}
 2804 The preprocessor is run.
 2805 .RE
 2806 .sp
 2807 .RS 4
 2808 .ie n \{\
 2809 \h'-04' 2.\h'+01'\c
 2810 .\}
 2811 .el \{\
 2812 .  sp -1
 2813 .  IP " 2." 4.2
 2814 .\}
 2815 An include file is modified by someone.
 2816 .RE
 2817 .sp
 2818 .RS 4
 2819 .ie n \{\
 2820 \h'-04' 3.\h'+01'\c
 2821 .\}
 2822 .el \{\
 2823 .  sp -1
 2824 .  IP " 3." 4.2
 2825 .\}
 2826 The new include file is hashed by ccache.
 2827 .RE
 2828 .sp
 2829 .RS 4
 2830 .ie n \{\
 2831 \h'-04' 4.\h'+01'\c
 2832 .\}
 2833 .el \{\
 2834 .  sp -1
 2835 .  IP " 4." 4.2
 2836 .\}
 2837 The real compiler is run on the preprocessor\(cqs output, which contains data
 2838 from the old header file.
 2839 .RE
 2840 .sp
 2841 .RS 4
 2842 .ie n \{\
 2843 \h'-04' 5.\h'+01'\c
 2844 .\}
 2845 .el \{\
 2846 .  sp -1
 2847 .  IP " 5." 4.2
 2848 .\}
 2849 The wrong object file is stored in the cache.
 2850 .RE
 2851 .SH "CACHE DEBUGGING"
 2852 .sp
 2853 To find out what information ccache actually is hashing, you can enable the
 2854 debug mode via the configuration option \fBdebug\fP or by setting
 2855 \fBCCACHE_DEBUG\fP in the environment. This can be useful if you are investigating
 2856 why you don\(cqt get cache hits. Note that performance will be reduced slightly.
 2857 .sp
 2858 When the debug mode is enabled, ccache will create up to five additional files
 2859 next to the object file:
 2860 .TS
 2861 allbox tab(:);
 2862 lt lt.
 2863 T{
 2864 .sp
 2865 \fBFilename\fP
 2866 T}:T{
 2867 .sp
 2868 \fBDescription\fP
 2869 T}
 2870 T{
 2871 .sp
 2872 \fB<objectfile>.ccache\-input\-c\fP
 2873 T}:T{
 2874 .sp
 2875 Binary input hashed by both the direct mode and the preprocessor mode.
 2876 T}
 2877 T{
 2878 .sp
 2879 \fB<objectfile>.ccache\-input\-d\fP
 2880 T}:T{
 2881 .sp
 2882 Binary input only hashed by the direct mode.
 2883 T}
 2884 T{
 2885 .sp
 2886 \fB<objectfile>.ccache\-input\-p\fP
 2887 T}:T{
 2888 .sp
 2889 Binary input only hashed by the preprocessor mode.
 2890 T}
 2891 T{
 2892 .sp
 2893 \fB<objectfile>.ccache\-input\-text\fP
 2894 T}:T{
 2895 .sp
 2896 Human\-readable combined diffable text version of the three files above.
 2897 T}
 2898 T{
 2899 .sp
 2900 \fB<objectfile>.ccache\-log\fP
 2901 T}:T{
 2902 .sp
 2903 Log for this object file.
 2904 T}
 2905 .TE
 2906 .sp
 2907 .sp
 2908 If \fBdebug_dir\fP (environment variable \fBCCACHE_DEBUGDIR\fP) is
 2909 set, the files above will be written to that directory with full absolute paths
 2910 instead of next to the object file.
 2911 .sp
 2912 In the direct mode, ccache uses the 160 bit BLAKE3 hash of the
 2913 \(lqccache\-input\-c\(rq + \(lqccache\-input\-d\(rq data (where \fB+\fP means concatenation),
 2914 while the \(lqccache\-input\-c\(rq + \(lqccache\-input\-p\(rq data is used in the
 2915 preprocessor mode.
 2916 .sp
 2917 The \(lqccache\-input\-text\(rq file is a combined text version of the three binary
 2918 input files. It has three sections (\(lqCOMMON\(rq, \(lqDIRECT MODE\(rq and
 2919 \(lqPREPROCESSOR MODE\(rq), which is turn contain annotations that say what kind of
 2920 data comes next.
 2921 .sp
 2922 To debug why you don\(cqt get an expected cache hit for an object file, you can do
 2923 something like this:
 2924 .sp
 2925 .RS 4
 2926 .ie n \{\
 2927 \h'-04' 1.\h'+01'\c
 2928 .\}
 2929 .el \{\
 2930 .  sp -1
 2931 .  IP " 1." 4.2
 2932 .\}
 2933 Build with debug mode enabled.
 2934 .RE
 2935 .sp
 2936 .RS 4
 2937 .ie n \{\
 2938 \h'-04' 2.\h'+01'\c
 2939 .\}
 2940 .el \{\
 2941 .  sp -1
 2942 .  IP " 2." 4.2
 2943 .\}
 2944 Save the \fB<objectfile>.ccache\-*\fP files.
 2945 .RE
 2946 .sp
 2947 .RS 4
 2948 .ie n \{\
 2949 \h'-04' 3.\h'+01'\c
 2950 .\}
 2951 .el \{\
 2952 .  sp -1
 2953 .  IP " 3." 4.2
 2954 .\}
 2955 Build again with debug mode enabled.
 2956 .RE
 2957 .sp
 2958 .RS 4
 2959 .ie n \{\
 2960 \h'-04' 4.\h'+01'\c
 2961 .\}
 2962 .el \{\
 2963 .  sp -1
 2964 .  IP " 4." 4.2
 2965 .\}
 2966 Compare \fB<objectfile>.ccache\-input\-text\fP for the two builds. This together
 2967 with the \fB<objectfile>.ccache\-log\fP files should give you some clues about
 2968 what is happening.
 2969 .RE
 2970 .SH "COMPILING IN DIFFERENT DIRECTORIES"
 2971 .sp
 2972 Some information included in the hash that identifies a unique compilation can
 2973 contain absolute paths:
 2974 .sp
 2975 .RS 4
 2976 .ie n \{\
 2977 \h'-04'\(bu\h'+03'\c
 2978 .\}
 2979 .el \{\
 2980 .  sp -1
 2981 .  IP \(bu 2.3
 2982 .\}
 2983 The preprocessed source code may contain absolute paths to include files if
 2984 the compiler option \fB\-g\fP is used or if absolute paths are given to \fB\-I\fP and
 2985 similar compiler options.
 2986 .RE
 2987 .sp
 2988 .RS 4
 2989 .ie n \{\
 2990 \h'-04'\(bu\h'+03'\c
 2991 .\}
 2992 .el \{\
 2993 .  sp -1
 2994 .  IP \(bu 2.3
 2995 .\}
 2996 Paths specified by compiler options (such as \fB\-I\fP, \fB\-MF\fP, etc) on the command
 2997 line may be absolute.
 2998 .RE
 2999 .sp
 3000 .RS 4
 3001 .ie n \{\
 3002 \h'-04'\(bu\h'+03'\c
 3003 .\}
 3004 .el \{\
 3005 .  sp -1
 3006 .  IP \(bu 2.3
 3007 .\}
 3008 The source code file path may be absolute, and that path may substituted for
 3009 \fB__FILE__\fP macros in the source code or included in warnings emitted to
 3010 standard error by the preprocessor.
 3011 .RE
 3012 .sp
 3013 This means that if you compile the same code in different locations, you can\(cqt
 3014 share compilation results between the different build directories since you get
 3015 cache misses because of the absolute build directory paths that are part of the
 3016 hash.
 3017 .sp
 3018 Here\(cqs what can be done to enable cache hits between different build
 3019 directories:
 3020 .sp
 3021 .RS 4
 3022 .ie n \{\
 3023 \h'-04'\(bu\h'+03'\c
 3024 .\}
 3025 .el \{\
 3026 .  sp -1
 3027 .  IP \(bu 2.3
 3028 .\}
 3029 If you build with \fB\-g\fP (or similar) to add debug information to the object
 3030 file, you must either:
 3031 .sp
 3032 .RS 4
 3033 .ie n \{\
 3034 \h'-04'\(bu\h'+03'\c
 3035 .\}
 3036 .el \{\
 3037 .  sp -1
 3038 .  IP \(bu 2.3
 3039 .\}
 3040 use the compiler option \fB\-fdebug\-prefix\-map=<old>=<new>\fP for relocating
 3041 debug info to a common prefix (e.g. \fB\-fdebug\-prefix\-map=$PWD=.\fP); or
 3042 .RE
 3043 .sp
 3044 .RS 4
 3045 .ie n \{\
 3046 \h'-04'\(bu\h'+03'\c
 3047 .\}
 3048 .el \{\
 3049 .  sp -1
 3050 .  IP \(bu 2.3
 3051 .\}
 3052 set \fBhash_dir = false\fP.
 3053 .RE
 3054 .RE
 3055 .sp
 3056 .RS 4
 3057 .ie n \{\
 3058 \h'-04'\(bu\h'+03'\c
 3059 .\}
 3060 .el \{\
 3061 .  sp -1
 3062 .  IP \(bu 2.3
 3063 .\}
 3064 If you use absolute paths anywhere on the command line (e.g. the source code
 3065 file path or an argument to compiler options like \fB\-I\fP and \fB\-MF\fP), you must
 3066 set \fBbase_dir\fP to an absolute path to a \(lqbase
 3067 directory\(rq. Ccache will then rewrite absolute paths under that directory to
 3068 relative before computing the hash.
 3069 .RE
 3070 .SH "PRECOMPILED HEADERS"
 3071 .sp
 3072 Ccache has support for GCC\(cqs precompiled headers. However, you have to do some
 3073 things to make it work properly:
 3074 .sp
 3075 .RS 4
 3076 .ie n \{\
 3077 \h'-04'\(bu\h'+03'\c
 3078 .\}
 3079 .el \{\
 3080 .  sp -1
 3081 .  IP \(bu 2.3
 3082 .\}
 3083 You must set \fBsloppiness\fP to \fBpch_defines,time_macros\fP.
 3084 The reason is that ccache can\(cqt tell whether \fB__TIME__\fP, \fB__DATE__\fP or
 3085 \fB__TIMESTAMP__\fP is used when using a precompiled header. Further, it can\(cqt
 3086 detect changes in \fB#define\fPs in the source code because of how preprocessing
 3087 works in combination with precompiled headers.
 3088 .RE
 3089 .sp
 3090 .RS 4
 3091 .ie n \{\
 3092 \h'-04'\(bu\h'+03'\c
 3093 .\}
 3094 .el \{\
 3095 .  sp -1
 3096 .  IP \(bu 2.3
 3097 .\}
 3098 You may also want to include \fBinclude_file_mtime,include_file_ctime\fP in
 3099 \fBsloppiness\fP. See
 3100 \fIHANDLING OF NEWLY CREATED HEADER FILES\fP.
 3101 .RE
 3102 .sp
 3103 .RS 4
 3104 .ie n \{\
 3105 \h'-04'\(bu\h'+03'\c
 3106 .\}
 3107 .el \{\
 3108 .  sp -1
 3109 .  IP \(bu 2.3
 3110 .\}
 3111 You must either:
 3112 .sp
 3113 .RS 4
 3114 .ie n \{\
 3115 \h'-04'\(bu\h'+03'\c
 3116 .\}
 3117 .el \{\
 3118 .  sp -1
 3119 .  IP \(bu 2.3
 3120 .\}
 3121 use the compiler option \fB\-include\fP to include the precompiled header (i.e.,
 3122 don\(cqt use \fB#include\fP in the source code to include the header; the filename
 3123 itself must be sufficient to find the header, i.e. \fB\-I\fP paths are not
 3124 searched); or
 3125 .RE
 3126 .sp
 3127 .RS 4
 3128 .ie n \{\
 3129 \h'-04'\(bu\h'+03'\c
 3130 .\}
 3131 .el \{\
 3132 .  sp -1
 3133 .  IP \(bu 2.3
 3134 .\}
 3135 (for the Clang compiler) use the compiler option \fB\-include\-pch\fP to include
 3136 the PCH file generated from the precompiled header; or
 3137 .RE
 3138 .sp
 3139 .RS 4
 3140 .ie n \{\
 3141 \h'-04'\(bu\h'+03'\c
 3142 .\}
 3143 .el \{\
 3144 .  sp -1
 3145 .  IP \(bu 2.3
 3146 .\}
 3147 (for the GCC compiler) add the compiler option \fB\-fpch\-preprocess\fP when
 3148 compiling.
 3149 .RE
 3150 .sp
 3151 If you don\(cqt do this, either the non\-precompiled version of the header file will
 3152 be used (if available) or ccache will fall back to running the real compiler and
 3153 increase the statistics counter \(lqPreprocessing failed\(rq (if the non\-precompiled
 3154 header file is not available).
 3155 .RE
 3156 .SH "C++ MODULES"
 3157 .sp
 3158 Ccache has support for Clang\(cqs \fB\-fmodules\fP option. In practice ccache only
 3159 additionally hashes \fBmodule.modulemap\fP files; it does not know how Clang
 3160 handles its cached binary form of modules so those are ignored. This should not
 3161 matter in practice: as long as everything else (including \fBmodule.modulemap\fP
 3162 files) is the same the cached result should work. Still, you must set
 3163 \fBsloppiness\fP to \fBmodules\fP to allow caching.
 3164 .sp
 3165 You must use both \fBdirect mode\fP and
 3166 \fBdepend mode\fP. When using
 3167 the preprocessor mode Clang does not provide enough
 3168 information to allow hashing of \fBmodule.modulemap\fP files.
 3169 .SH "SHARING A CACHE"
 3170 .sp
 3171 A group of developers can increase the cache hit rate by sharing a cache
 3172 directory. To share a cache without unpleasant side effects, the following
 3173 conditions should to be met:
 3174 .sp
 3175 .RS 4
 3176 .ie n \{\
 3177 \h'-04'\(bu\h'+03'\c
 3178 .\}
 3179 .el \{\
 3180 .  sp -1
 3181 .  IP \(bu 2.3
 3182 .\}
 3183 Use the same cache directory.
 3184 .RE
 3185 .sp
 3186 .RS 4
 3187 .ie n \{\
 3188 \h'-04'\(bu\h'+03'\c
 3189 .\}
 3190 .el \{\
 3191 .  sp -1
 3192 .  IP \(bu 2.3
 3193 .\}
 3194 Make sure that the configuration option \fBhard_link\fP is
 3195 false (which is the default).
 3196 .RE
 3197 .sp
 3198 .RS 4
 3199 .ie n \{\
 3200 \h'-04'\(bu\h'+03'\c
 3201 .\}
 3202 .el \{\
 3203 .  sp -1
 3204 .  IP \(bu 2.3
 3205 .\}
 3206 Make sure that all users are in the same group.
 3207 .RE
 3208 .sp
 3209 .RS 4
 3210 .ie n \{\
 3211 \h'-04'\(bu\h'+03'\c
 3212 .\}
 3213 .el \{\
 3214 .  sp -1
 3215 .  IP \(bu 2.3
 3216 .\}
 3217 Set the configuration option \fBumask\fP to \fB002\fP. This ensures
 3218 that cached files are accessible to everyone in the group.
 3219 .RE
 3220 .sp
 3221 .RS 4
 3222 .ie n \{\
 3223 \h'-04'\(bu\h'+03'\c
 3224 .\}
 3225 .el \{\
 3226 .  sp -1
 3227 .  IP \(bu 2.3
 3228 .\}
 3229 Make sure that all users have write permission in the entire cache directory
 3230 (and that you trust all users of the shared cache).
 3231 .RE
 3232 .sp
 3233 .RS 4
 3234 .ie n \{\
 3235 \h'-04'\(bu\h'+03'\c
 3236 .\}
 3237 .el \{\
 3238 .  sp -1
 3239 .  IP \(bu 2.3
 3240 .\}
 3241 Make sure that the setgid bit is set on all directories in the cache. This
 3242 tells the filesystem to inherit group ownership for new directories. The
 3243 following command might be useful for this:
 3244 .sp
 3245 .if n .RS 4
 3246 .nf
 3247 .fam C
 3248 find $CCACHE_DIR \-type d | xargs chmod g+s
 3249 .fam
 3250 .fi
 3251 .if n .RE
 3252 .RE
 3253 .sp
 3254 The reason to avoid the hard link mode is that the hard links cause unwanted
 3255 side effects, as all links to a cached file share the file\(cqs modification
 3256 timestamp. This results in false dependencies to be triggered by
 3257 timestamp\-based build systems whenever another user links to an existing file.
 3258 Typically, users will see that their libraries and binaries are relinked
 3259 without reason.
 3260 .sp
 3261 You may also want to make sure that a base directory is set appropriately, as
 3262 discussed in a previous section.
 3263 .SH "SHARING A CACHE ON NFS"
 3264 .sp
 3265 It is possible to put the cache directory on an NFS filesystem (or similar
 3266 filesystems), but keep in mind that:
 3267 .sp
 3268 .RS 4
 3269 .ie n \{\
 3270 \h'-04'\(bu\h'+03'\c
 3271 .\}
 3272 .el \{\
 3273 .  sp -1
 3274 .  IP \(bu 2.3
 3275 .\}
 3276 Having the cache on NFS may slow down compilation. Make sure to do some
 3277 benchmarking to see if it\(cqs worth it.
 3278 .RE
 3279 .sp
 3280 .RS 4
 3281 .ie n \{\
 3282 \h'-04'\(bu\h'+03'\c
 3283 .\}
 3284 .el \{\
 3285 .  sp -1
 3286 .  IP \(bu 2.3
 3287 .\}
 3288 Ccache hasn\(cqt been tested very thoroughly on NFS.
 3289 .RE
 3290 .sp
 3291 A tip is to set \fBtemporary_dir\fP to a directory on the
 3292 local host to avoid NFS traffic for temporary files.
 3293 .sp
 3294 It is recommended to use the same operating system version when using a shared
 3295 cache. If operating system versions are different then system include files
 3296 will likely be different and there will be few or no cache hits between the
 3297 systems. One way of improving cache hit rate in that case is to set
 3298 \fBsloppiness\fP to \fBsystem_headers\fP to ignore system
 3299 headers.
 3300 .sp
 3301 An alternative to putting the main cache directory on NFS is to set up a
 3302 secondary storage file cache.
 3303 .SH "USING CCACHE WITH OTHER COMPILER WRAPPERS"
 3304 .sp
 3305 The recommended way of combining ccache with another compiler wrapper (such as
 3306 \(lqdistcc\(rq) is by letting ccache execute the compiler wrapper. This is
 3307 accomplished by defining \fBprefix_command\fP, for
 3308 example by setting the environment variable \fBCCACHE_PREFIX\fP to the name of the
 3309 wrapper (e.g. \fBdistcc\fP). Ccache will then prefix the command line with the
 3310 specified command when running the compiler. To specify several prefix
 3311 commands, set \fBprefix_command\fP to a colon\-separated
 3312 list of commands.
 3313 .sp
 3314 Unless you set \fBcompiler_check\fP to a suitable command
 3315 (see the description of that configuration option), it is not recommended to use
 3316 the form \fBccache anotherwrapper compiler args\fP as the compilation command. It\(cqs
 3317 also not recommended to use the masquerading technique for the other compiler
 3318 wrapper. The reason is that by default, ccache will in both cases hash the mtime
 3319 and size of the other wrapper instead of the real compiler, which means that:
 3320 .sp
 3321 .RS 4
 3322 .ie n \{\
 3323 \h'-04'\(bu\h'+03'\c
 3324 .\}
 3325 .el \{\
 3326 .  sp -1
 3327 .  IP \(bu 2.3
 3328 .\}
 3329 Compiler upgrades will not be detected properly.
 3330 .RE
 3331 .sp
 3332 .RS 4
 3333 .ie n \{\
 3334 \h'-04'\(bu\h'+03'\c
 3335 .\}
 3336 .el \{\
 3337 .  sp -1
 3338 .  IP \(bu 2.3
 3339 .\}
 3340 The cached results will not be shared between compilations with and without
 3341 the other wrapper.
 3342 .RE
 3343 .sp
 3344 Another minor thing is that if \fBprefix_command\fP is
 3345 used, ccache will not invoke the other wrapper when running the preprocessor,
 3346 which increases performance. You can use
 3347 \fBprefix_command_cpp\fP if you also want to invoke
 3348 the other wrapper when doing preprocessing (normally by adding \fB\-E\fP).
 3349 .SH "CAVEATS"
 3350 .sp
 3351 .RS 4
 3352 .ie n \{\
 3353 \h'-04'\(bu\h'+03'\c
 3354 .\}
 3355 .el \{\
 3356 .  sp -1
 3357 .  IP \(bu 2.3
 3358 .\}
 3359 The direct mode fails to pick up new header files in some rare scenarios. See
 3360 \fIThe direct mode\fP above.
 3361 .RE
 3362 .SH "TROUBLESHOOTING"
 3363 .SS "General"
 3364 .sp
 3365 A general tip for getting information about what ccache is doing is to enable
 3366 debug logging by setting the configuration option \fBdebug\fP (or
 3367 the environment variable \fBCCACHE_DEBUG\fP); see \fICACHE DEBUGGING\fP
 3368 for more information. Another way of keeping track of what is
 3369 happening is to check the output of \fBccache \-s\fP.
 3370 .SS "Performance"
 3371 .sp
 3372 Ccache has been written to perform well out of the box, but sometimes you may
 3373 have to do some adjustments of how you use the compiler and ccache in order to
 3374 improve performance.
 3375 .sp
 3376 Since ccache works best when I/O is fast, put the cache directory on a fast
 3377 storage device if possible. Having lots of free memory so that files in the
 3378 cache directory stay in the disk cache is also preferable.
 3379 .sp
 3380 A good way of monitoring how well ccache works is to run \fBccache \-s\fP before and
 3381 after your build and then compare the statistics counters. Here are some common
 3382 problems and what may be done to increase the hit rate:
 3383 .sp
 3384 .RS 4
 3385 .ie n \{\
 3386 \h'-04'\(bu\h'+03'\c
 3387 .\}
 3388 .el \{\
 3389 .  sp -1
 3390 .  IP \(bu 2.3
 3391 .\}
 3392 If the counter for preprocessed cache hits has been incremented instead of the
 3393 one for direct cache hits, ccache has fallen back to preprocessor mode, which
 3394 is generally slower. Some possible reasons are:
 3395 .sp
 3396 .RS 4
 3397 .ie n \{\
 3398 \h'-04'\(bu\h'+03'\c
 3399 .\}
 3400 .el \{\
 3401 .  sp -1
 3402 .  IP \(bu 2.3
 3403 .\}
 3404 The source code has been modified in such a way that the preprocessor output
 3405 is not affected.
 3406 .RE
 3407 .sp
 3408 .RS 4
 3409 .ie n \{\
 3410 \h'-04'\(bu\h'+03'\c
 3411 .\}
 3412 .el \{\
 3413 .  sp -1
 3414 .  IP \(bu 2.3
 3415 .\}
 3416 Compiler arguments that are hashed in the direct mode but not in the
 3417 preprocessor mode have changed (\fB\-I\fP, \fB\-include\fP, \fB\-D\fP, etc) and they didn\(cqt
 3418 affect the preprocessor output.
 3419 .RE
 3420 .sp
 3421 .RS 4
 3422 .ie n \{\
 3423 \h'-04'\(bu\h'+03'\c
 3424 .\}
 3425 .el \{\
 3426 .  sp -1
 3427 .  IP \(bu 2.3
 3428 .\}
 3429 The compiler option \fB\-Xpreprocessor\fP or \fB\-Wp,*\fP (except \fB\-Wp,\-MD,<path>\fP,
 3430 \fB\-Wp,\-MMD,<path>\fP, and \fB\-Wp,\-D<define>\fP) is used.
 3431 .RE
 3432 .sp
 3433 .RS 4
 3434 .ie n \{\
 3435 \h'-04'\(bu\h'+03'\c
 3436 .\}
 3437 .el \{\
 3438 .  sp -1
 3439 .  IP \(bu 2.3
 3440 .\}
 3441 This was the first compilation with a new value of the
 3442 base directory.
 3443 .RE
 3444 .sp
 3445 .RS 4
 3446 .ie n \{\
 3447 \h'-04'\(bu\h'+03'\c
 3448 .\}
 3449 .el \{\
 3450 .  sp -1
 3451 .  IP \(bu 2.3
 3452 .\}
 3453 A modification or status change time of one of the include files is too new
 3454 (created the same second as the compilation is being done). See
 3455 \fIHANDLING OF NEWLY CREATED HEADER FILES\fP.
 3456 .RE
 3457 .sp
 3458 .RS 4
 3459 .ie n \{\
 3460 \h'-04'\(bu\h'+03'\c
 3461 .\}
 3462 .el \{\
 3463 .  sp -1
 3464 .  IP \(bu 2.3
 3465 .\}
 3466 The \fB__TIME__\fP preprocessor macro is (potentially) being used. Ccache turns
 3467 off direct mode if \fB__TIME__\fP is present in the source code. This is done
 3468 as a safety measure since the string indicates that a \fB__TIME__\fP macro
 3469 \fImay\fP affect the output. (To be sure, ccache would have to run the
 3470 preprocessor, but the sole point of the direct mode is to avoid that.) If you
 3471 know that \fB__TIME__\fP isn\(cqt used in practise, or don\(cqt care if ccache
 3472 produces objects where \fB__TIME__\fP is expanded to something in the past, you
 3473 can set \fBsloppiness\fP to \fBtime_macros\fP.
 3474 .RE
 3475 .sp
 3476 .RS 4
 3477 .ie n \{\
 3478 \h'-04'\(bu\h'+03'\c
 3479 .\}
 3480 .el \{\
 3481 .  sp -1
 3482 .  IP \(bu 2.3
 3483 .\}
 3484 The \fB__DATE__\fP preprocessor macro is (potentially) being used and the date
 3485 has changed. This is similar to how \fB__TIME__\fP is handled. If \fB__DATE__\fP
 3486 is present in the source code, ccache hashes the current date in order to be
 3487 able to produce the correct object file if the \fB__DATE__\fP macro affects the
 3488 output. If you know that \fB__DATE__\fP isn\(cqt used in practise, or don\(cqt care
 3489 if ccache produces objects where \fB__DATE__\fP is expanded to something in the
 3490 past, you can set \fBsloppiness\fP to \fBtime_macros\fP.
 3491 .RE
 3492 .sp
 3493 .RS 4
 3494 .ie n \{\
 3495 \h'-04'\(bu\h'+03'\c
 3496 .\}
 3497 .el \{\
 3498 .  sp -1
 3499 .  IP \(bu 2.3
 3500 .\}
 3501 The \fB__TIMESTAMP__\fP preprocessor macro is (potentially) being used and the
 3502 source file\(cqs modification time has changed. This is similar to how
 3503 \fB__TIME__\fP is handled. If \fB__TIMESTAMP__\fP is present in the source code,
 3504 ccache hashes the string representation of the source file\(cqs modification
 3505 time in order to be able to produce the correct object file if the
 3506 \fB__TIMESTAMP__\fP macro affects the output. If you know that
 3507 \fB__TIMESTAMP__\fP isn\(cqt used in practise, or don\(cqt care if ccache produces
 3508 objects where \fB__TIMESTAMP__\fP is expanded to something in the past, you can
 3509 set \fBsloppiness\fP to \fBtime_macros\fP.
 3510 .RE
 3511 .sp
 3512 .RS 4
 3513 .ie n \{\
 3514 \h'-04'\(bu\h'+03'\c
 3515 .\}
 3516 .el \{\
 3517 .  sp -1
 3518 .  IP \(bu 2.3
 3519 .\}
 3520 The input file path has changed. Ccache includes the input file path in the
 3521 direct mode hash to be able to take relative include files into account and
 3522 to produce a correct object file if the source code includes a \fB__FILE__\fP
 3523 macro.
 3524 .RE
 3525 .RE
 3526 .sp
 3527 .RS 4
 3528 .ie n \{\
 3529 \h'-04'\(bu\h'+03'\c
 3530 .\}
 3531 .el \{\
 3532 .  sp -1
 3533 .  IP \(bu 2.3
 3534 .\}
 3535 If a cache hit counter was not incremented even though the same code has been
 3536 compiled and cached before, ccache has either detected that something has
 3537 changed anyway or a cleanup has been performed (either explicitly or
 3538 implicitly when a cache limit has been reached). Some perhaps unobvious things
 3539 that may result in a cache miss are usage of \fB__TIME__\fP, \fB__DATE__\fP or
 3540 \fB__TIMESTAMP__\fP macros, or use of automatically generated code that contains
 3541 a timestamp, build counter or other volatile information.
 3542 .RE
 3543 .sp
 3544 .RS 4
 3545 .ie n \{\
 3546 \h'-04'\(bu\h'+03'\c
 3547 .\}
 3548 .el \{\
 3549 .  sp -1
 3550 .  IP \(bu 2.3
 3551 .\}
 3552 If \(lqMultiple source files\(rq has been incremented, it\(cqs an indication that the
 3553 compiler has been invoked on several source code files at once. Ccache doesn\(cqt
 3554 support that. Compile the source code files separately if possible.
 3555 .RE
 3556 .sp
 3557 .RS 4
 3558 .ie n \{\
 3559 \h'-04'\(bu\h'+03'\c
 3560 .\}
 3561 .el \{\
 3562 .  sp -1
 3563 .  IP \(bu 2.3
 3564 .\}
 3565 If \(lqUnsupported compiler option\(rq has been incremented, enable debug logging
 3566 and check which compiler option was rejected.
 3567 .RE
 3568 .sp
 3569 .RS 4
 3570 .ie n \{\
 3571 \h'-04'\(bu\h'+03'\c
 3572 .\}
 3573 .el \{\
 3574 .  sp -1
 3575 .  IP \(bu 2.3
 3576 .\}
 3577 If \(lqPreprocessing failed\(rq has been incremented, one possible reason is that
 3578 precompiled headers are being used. See \fIPRECOMPILED HEADERS\fP for how to
 3579 remedy this.
 3580 .RE
 3581 .sp
 3582 .RS 4
 3583 .ie n \{\
 3584 \h'-04'\(bu\h'+03'\c
 3585 .\}
 3586 .el \{\
 3587 .  sp -1
 3588 .  IP \(bu 2.3
 3589 .\}
 3590 If \(lqCould not use precompiled header\(rq has been incremented, see
 3591 \fIPRECOMPILED HEADERS\fP.
 3592 .RE
 3593 .sp
 3594 .RS 4
 3595 .ie n \{\
 3596 \h'-04'\(bu\h'+03'\c
 3597 .\}
 3598 .el \{\
 3599 .  sp -1
 3600 .  IP \(bu 2.3
 3601 .\}
 3602 If \(lqCould not use modules\(rq has been incremented, see \fIC++ MODULES\fP.
 3603 .RE
 3604 .SS "Corrupt object files"
 3605 .sp
 3606 It should be noted that ccache is susceptible to general storage problems. If a
 3607 bad object file sneaks into the cache for some reason, it will of course stay
 3608 bad. Some possible reasons for erroneous object files are bad hardware (disk
 3609 drive, disk controller, memory, etc), buggy drivers or file systems, a bad
 3610 \fBprefix_command\fP or compiler wrapper. If this
 3611 happens, the easiest way of fixing it is this:
 3612 .sp
 3613 .RS 4
 3614 .ie n \{\
 3615 \h'-04' 1.\h'+01'\c
 3616 .\}
 3617 .el \{\
 3618 .  sp -1
 3619 .  IP " 1." 4.2
 3620 .\}
 3621 Build so that the bad object file ends up in the build tree.
 3622 .RE
 3623 .sp
 3624 .RS 4
 3625 .ie n \{\
 3626 \h'-04' 2.\h'+01'\c
 3627 .\}
 3628 .el \{\
 3629 .  sp -1
 3630 .  IP " 2." 4.2
 3631 .\}
 3632 Remove the bad object file from the build tree.
 3633 .RE
 3634 .sp
 3635 .RS 4
 3636 .ie n \{\
 3637 \h'-04' 3.\h'+01'\c
 3638 .\}
 3639 .el \{\
 3640 .  sp -1
 3641 .  IP " 3." 4.2
 3642 .\}
 3643 Rebuild with \fBCCACHE_RECACHE\fP set.
 3644 .RE
 3645 .sp
 3646 An alternative is to clear the whole cache with \fBccache \-C\fP if you don\(cqt mind
 3647 losing other cached results.
 3648 .sp
 3649 There are no reported issues about ccache producing broken object files
 3650 reproducibly. That doesn\(cqt mean it can\(cqt happen, so if you find a repeatable
 3651 case, please report it.
 3652 .SH "MORE INFORMATION"
 3653 .sp
 3654 Credits, mailing list information, bug reporting instructions, source code,
 3655 etc, can be found on ccache\(cqs web site: \c
 3656 .URL "https://ccache.dev" "" "."
 3657 .SH "AUTHOR"
 3658 .sp
 3659 Ccache was originally written by Andrew Tridgell and is currently developed and
 3660 maintained by Joel Rosdahl. See AUTHORS.txt or AUTHORS.html and
 3661 .URL "https://ccache.dev/credits.html" "" ""
 3662 for a list of contributors.

Generated by cgit