[all-commits] [llvm/llvm-project] bc1a29: [clang][deps] Separate filesystem caches for minim...

Jan Svoboda via All-commits all-commits at lists.llvm.org
Tue Jul 20 03:09:00 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: bc1a2979fc70d954ae97122205c71c8404a1b17e
      https://github.com/llvm/llvm-project/commit/bc1a2979fc70d954ae97122205c71c8404a1b17e
  Author: Jan Svoboda <jan_svoboda at apple.com>
  Date:   2021-07-20 (Tue, 20 Jul 2021)

  Changed paths:
    M clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
    M clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
    M clang/unittests/Tooling/CMakeLists.txt
    M clang/unittests/Tooling/DependencyScannerTest.cpp

  Log Message:
  -----------
  [clang][deps] Separate filesystem caches for minimized and original files

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.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D106146




More information about the All-commits mailing list