Skip to content

Commit 0c44acb

Browse files
committed
Reword and correct the preprocessor cache mode documentation
The correction is that there is a *long* list of compiler options that disable cache mode.
1 parent 912a67e commit 0c44acb

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

docs/Local.md

+9-13
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,25 @@ The local storage only supports a single sccache server at a time. Multiple conc
1010

1111
This is inspired by [ccache's direct mode](https://ccache.dev/manual/3.7.9.html#_the_direct_mode) and works roughly the same.
1212

13-
It can be set with by setting the variable:
14-
```
15-
SCCACHE_DIRECT=true
16-
```
13+
[preprocessor cache] mode is controlled by a configuration option which is true by default, as well as additional conditions described below.
1714

18-
In preprocessor cache mode, sccache caches the preprocessor step for C/C++ whenever possible. This can make the compilation a lot faster, since the preprocessor accounts for a non-negligible amount of time in the entire compile chain.
15+
In preprocessor cache mode, sccache caches the preprocessor step for C/C++ whenever possible. This can make the compilation much faster, since the preprocessor step takes a non-negligible amount of the entire compile time.
1916

20-
In order to cache the preprocessor step sccache needs to remember, among other things, all files included by the given input file. To quote ccache's documentation:
17+
In order to cache the preprocessor step, [sccache] needs to remember, among other things, all files included by a given input file. To quote ccache's documentation:
2118

22-
> There is a catch with the [preprocessor cache] mode: header files that were used by the compiler are recorded, but header files that were not used, but would have been used if they existed, are not. So, when [sccache] checks if a result can be taken from the cache, it currently can’t check if the existence of a new header file should invalidate the result. In practice, the [preprocessor cache] mode is safe to use in the absolute majority of cases.
19+
> There is a catch with the [preprocessor cache] mode: header files that were used by the compiler are recorded, but header files that were not used, but would have been used if they existed, are not. So, when [sccache] checks if a result can be taken from the cache, it currently can’t check if the existence of a new header file should invalidate the result. In practice, the [preprocessor cache] mode is safe to use in the vast majority of cases.
2320
2421
Preprocessor cache mode will be disabled if any of the following holds:
2522

26-
- the configuration setting `use_preprocessor_cache_mode` is false
27-
- a modification time of one of the include files is too new (needed to avoid a race condition)
28-
- a compiler option not supported by the preprocessor cache mode is used. Currently, this is only `-Xpreprocessor` and `-Wp,*`, but if/when sccache grows to handle options then more could be added to this list.
23+
- the configuration option is false
24+
- not using GCC or Clang with local storage (only implemented for these)
25+
- the modification time of one of the include files is too new (this avoids a race condition)
26+
- a compiler option not supported by [preprocessor cache] mode is used; this is usually because the compilation has inputs or outputs which [sccache] does not model well enough
2927
- the string `__TIME__` is present in the source code
3028

3129
Configuration options and their default values:
3230

33-
- `use_preprocessor_cache_mode`: `true`. Whether to use preprocessor cache mode entirely.
31+
- `use_preprocessor_cache_mode`: `true`. Whether to use [preprocessor cache] mode. This can be overridden for an sccache invocation by setting the environment variable `SCCACHE_DIRECT` to `true`/`on`/`1` or `false`/`off`/`0`).
3432
- `file_stat_matches`: `false`. If false, only compare header files by hashing their contents. If true, will use size + ctime + mtime to check whether a file has changed. See other flags below for more control over this behavior.
3533
- `use_ctime_for_stat`: `true`. If true, uses the ctime (file status change on UNIX, creation time on Windows) to check that a file has/hasn't changed. Can be useful to disable when backdating modification times in a controlled manner.
3634

@@ -42,8 +40,6 @@ Configuration options and their default values:
4240

4341
See where to write the config in [the configuration doc](Configuration.md).
4442

45-
*Note that preprocessor caching is currently only implemented for GCC and Clang and when using local storage.*
46-
4743
## Read-only cache mode
4844

4945
By default, the local cache operates in read/write mode. The `SCCACHE_LOCAL_RW_MODE` environment variable can be set to `READ_ONLY` (or `READ_WRITE`) to modify this behavior.

0 commit comments

Comments
 (0)