You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 4a78001
Browse filesBrowse the repository at this point in the historyBrowse files
SCCACHE_BASEDIRS strips the base directories from the preprocessed
source, but the compiler arguments are hashed verbatim. That leaves out
the one thing that most reliably ties a cache entry to a single checkout:
a flag that names the tree it is building.
-ffile-prefix-map=/home/user/project=.
The flag exists precisely so the object file does not depend on where the
tree lives - every path it records is rewritten to `.` - so two checkouts
of the same commit produce identical objects. They just never agree on
the hash, because the flag itself spells the path out, and so they never
share an entry. Which is the case basedirs is for.
Strip basedirs from each argument before hashing it, at the places where
an argument is expected to spell a pathname, and only there: the whole
argument, as in a source file or the path of a separated option; the
value of an option written with an `=`, which covers either half of a
prefix map; and the value glued to a short option such as -I. A basedir
appearing anywhere else is left alone, so -DROOT="/home/user/project",
which the compiler bakes into the output verbatim, still counts towards
the hash.
Basedirs carry a trailing slash so that they only match whole path
components; in an argument a component can also end at the `=` of a
prefix map, or at the end of the argument, so accept those two as well.
A sibling /home/user/project-docs is still not a match. The longest
basedir wins.
Bump CACHE_VERSION and the preprocessor cache's FORMAT_VERSION, since the
arguments now reach the hash as bytes rather than through OsString's Hash
impl.
An integration test is added to tests/integration.
Path matching is **case-insensitive** on Windows and **case-sensitive** on other operating systems.
346
346
347
+
Base directories are stripped from the preprocessed source and from the compiler arguments alike. The arguments matter because a flag can name the tree it is building: `-ffile-prefix-map=/home/user/project=.` makes the object file independent of where the tree is checked out, but the flag itself is not, and it is hashed verbatim.
348
+
349
+
In an argument only the places that are expected to spell a pathname are considered: the whole argument, the value of an option written with an `=` (either half of a prefix map), and the value glued to a short option such as `-I`. A base directory appearing anywhere else is left alone, so a definition the compiler bakes into the output verbatim, `-DROOT="/home/user/project"`, still counts. A match also has to end where a path component ends, so a sibling `/home/user/project-docs` is not one.
350
+
347
351
This is similar to ccache's `CCACHE_BASEDIR` and helps when:
348
352
* Building the same project from different directories
349
353
* Sharing cache between CI jobs with different checkout paths
0 commit comments