This is an archive of the discontinued LLVM Phabricator instance.

[clang][deps] Separate filesystem caches for minimized and original files
ClosedPublic

Authored by jansvoboda11 on Jul 16 2021, 5:58 AM.

Details

Summary

This patch separates the local and global caches of DependencyScanningFilesystem into two buckets: minimized files and original files. This is necessary to deal with precompiled modules/headers.

Consider a single worker with its instance of filesystem:

  1. Build system uses the worker to scan dependencies of module A => filesystem cache gets populated with minimized input files.
  2. Build system uses the results to explicitly build module A => explicitly built module captures the state of the real filesystem (containing non-minimized input files).
  3. Build system uses the prebuilt module A as an explicit precompiled dependency for another compile job B.
  4. Build system uses the same worker to scan dependencies for job B => worker uses implicit modular build to discover dependencies, which validates the filesystem state embedded in the prebuilt module (non-minimized files) to the current view of the filesystem (minimized files), resulting in validation failures.

This problem can be avoided in step 4 by collecting input files from the precompiled module and marking them as "ignored" in the minimizing filesystem. This way, the validation should succeed, since we should be always dealing with the original (non-minized) input files. However, the filesystem already minimized the input files in step 1 and put it in the cache, which gets used in step 4 as well even though it's marked ignored (do not minimize). This patch essentially fixes this oversight by making the "file is minimized" part of the cache key (from high level).

Depends on D106064.

Diff Detail

Event Timeline

jansvoboda11 created this revision.Jul 16 2021, 5:58 AM
dexonsmith accepted this revision.Jul 16 2021, 12:26 PM

LGTM.

clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
169–172

Nit: I suggest calling this ShouldMinimize.

This revision is now accepted and ready to land.Jul 16 2021, 12:26 PM
This revision was landed with ongoing or failed builds.Jul 20 2021, 3:08 AM
This revision was automatically updated to reflect the committed changes.