siso: restore mtimes only for directories Flush actually wrote

When Flush writes a directory's members to disk, those writes bump the
directory's on-disk mtime. Flush therefore sets the directory's mtime
back to the recorded value afterwards, so that the next build sees the
directory as unchanged.

The bug: Flush queued a directory for this mtime restore as soon as it
saw the entry, before the lready check that decides whether there is
anything to write at all. So even directories that Flush then skipped
got their mtime rewritten. That is wrong in two ways:

- Flush also runs on inputs (prepareLocalInputs), so source
  directories pass through it. If the user changed such a directory
  during the build, for example by adding a file, the restore reset
  its mtime to the old recorded value. updateDir then saw no change,
  and the new file stayed invisible to ReadDir and Glob.
- If the path on disk had changed type in the meantime, Flush rewrote
  the mtime of whatever now sits at that path, for example a user's
  source file.

Now Flush queues a directory for the mtime restore only when flushDir
actually wrote it, plus one more case: generated directories (cmdhash
set) that are already local-ready. For those, a trailing-slash flush
can still write missing members beneath them, which bumps the on-disk
mtime. Without the restore the saved state no longer matches disk, and
the next build sees entryBeforeLocal and re-runs the producing step
for nothing. Source directories (no cmdhash) never get their mtime
rewritten, so a user's mid-build change stays visible; see
TestFlush_LocalReadyDirMtimeNotRestored.

Change-Id: If04f07c6a5ce04eda3b316107dfbaa6440dc933c
Reviewed-on: https://chromium-review.googlesource.com/c/build/+/8037821
Commit-Queue: Neri Marschik <nerima@google.com>
Reviewed-by: Yuke Liao <liaoyuke@google.com>
Auto-Submit: Philipp Wollermann <philwo@google.com>
3 files changed
tree: 02c118885f2f546a083f06ebef09eb0253fee507
  1. bench/
  2. gong/
  3. hashigo/
  4. infra/
  5. kajiya/
  6. kzipinfo/
  7. remote-apis/
  8. runmc/
  9. siso/
  10. .gitignore
  11. .golangci.yml
  12. .style.yapf
  13. BUILD_OWNERS
  14. BUILD_TEAM_OWNERS
  15. CONTRIBUTING.md
  16. LICENSE
  17. OWNERS
  18. PRESUBMIT.py
  19. README.md
  20. WATCHLISTS
README.md

build.git repository

This repository contains tools developed and owned by the Chrome Build Team.

Quick start

The steps for getting the code are:

  1. Install depot_tools
  2. Run git clone https://chromium.googlesource.com/build

We use the standard Go module workflow to work on our projects.

Links