forked from bazelbuild/bazel
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not force unresolved symlinks to be absolute
The documentation of `ctx.actions.symlink(target_path = ...)` states that the given path is used as the symlink target without any changes, but in reality this path has so far always been converted into an absolute path by prepending the exec root. This is changed by this commit, which gets very close to the documented behavior by preserving the target path as is except for the standard normalization applied by `PathFragment`. Improving the situation even further would require modifying or adding to Bazel's core file system API, which may be done in a follow-up PR. Since relative symlinks only resolve correctly at the location they were originally created, they have to be handled specially when staged as runfiles. This commit adds a new `declared_symlinks` parameter to the rule context's `runfiles` method that takes in symlink artifacts declared via `ctx.actions.declare_symlink`. These symlinks are staged at their runfiles path directly, with no further processing of their target and without any intermediate runfiles pointing back to the artifact's location under the exec root. This has to main benefits: * With local execution, symlinks are resolved within the runfiles tree, which is more hermetic than following the runfiles symlink back into the exec root and resolving the symlink artifact there. * Actions can expect symlink artifacts to be stages as is without intermediate symlinks with local and sandboxed execution, both inside and outside the runfiles tree. This is important for packaging actions as well as rulesets sensitive to symlinks (e.g. rules_js). As a side-effect of the switch to relative symlinks, this commit resolves a non-hermeticity issue observed in bazelbuild#10298 (comment) Integration tests are added to verify that symlinks staged in the sandbox are no longer resolved non-hermetically. Fixes bazelbuild#14224
- Loading branch information
Showing
13 changed files
with
381 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.