Windows: Make runfiles symlink tree actions depend on the runfiles artifacts. #12018
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Windows distinguishes between symlinks to files and symlinks to directories. The
code to create symlink trees on Windows thus inspects the targets of the links
to learn what kind of symlink to make. Unfortunately, the symlinking code did
not depend on the link targets actually being created. This race could lead to
non-deterministic and non-functional symlink trees.
Fix this problem by depending on runfiles artifacts in the SymtreeTreeAction
when the host platform is Windows.
It's certainly possible to avoid this os-dependent input dependency—by using
in-memory Artifact state for the in-process implementation and extending the
runfiles manifest format to indicate target type for build-runfiles-windows—but
this commit is the most straightforward change that remediates the serious
correctness issue represented by the previous state.
This topic has a long history. When Windows runfiles trees were actually copies
of artifacts, the "symlink" action obviously had to depend on the origin
artifacts (41f4456). That code was removed in
an interregnum period where runfiles trees weren't supported at all on Windows
(0885abd). However, the dependency was not
added back when Windows symlinked runfiles trees support was finally added
(b592dbd).
Fixes #12033.