-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create and stage symlink artifacts with unmodified target path #16272
Conversation
src/main/java/com/google/devtools/build/lib/analysis/SourceManifestAction.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
@Override | ||
public Depset getStarlarkInputs() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can also make this throw an Exception if you prefer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropped it for now as per fmeum@a2fdd4a#r83921660.
db9de37
to
62256c8
Compare
62256c8
to
f4ee830
Compare
src/main/java/com/google/devtools/build/lib/analysis/SourceManifestAction.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/analysis/SourceManifestAction.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/analysis/SourceManifestAction.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/analysis/starlark/UnresolvedSymlinkAction.java
Outdated
Show resolved
Hide resolved
Unresolved symlink artifacts created with `ctx.actions.symlink(target_path = ...)` are now created without making the target path absolute by prepending the exec root, which diverged from the documentation and intended goal and also gave rise to hermeticity issues as such symlinks would regularly resolve outside the sandbox. Furthermore, in order to bring local execution in line with other execution types, the runfiles manifest entry (and thus the runfiles directory contents) for symlink artifacts are now their target paths rather than their exec paths, which along the way resolves another soure of non-hermetic resolution outside the runfiles directory. This requires making symlink artifacts (but not artifacts representing regular files) inputs of `SourceManifestAction`, which previously had no inputs. The change flattens a nested set in `getInputs`, but benchmarks confirm that this does not result in a performance regression. Alternatives considered either result in a substantially worse Starlark API or wouldn't work for symlinks created by spawns.
f4ee830
to
eb6ba2b
Compare
From my POV, this looks good; @alexjski , mind taking a look whether you can live with the way |
Tested this change against rules_js here aspect-build/rules_js#453 with a release from our bazel fork https://github.com/aspect-build/bazel/releases/tag/6.0.0-pre_20220823_1_aspect. Working as expected. Great work @fmeum! |
Based on fmeum@a2fdd4a#r84014073, I would leave this PR as is then, tight? |
Yeah, let's merge this as it is then. |
cc @tjgq as this is relevant to our discussion about metadata handling for symlinks. |
Going to give this a test against some internal benchmarks. |
This seems to allow creating symlinks to anywhere, including outside of the Bazel tree. Do we really want that? Are there use cases that require that? |
This has been possible even before this commit and in fact happened more easily by accident since the symlink action created absolute symlinks that pointed outside the sandbox. Generally speaking, I would expect most symlinks to be relative and stay within the tree. I do see use cases for absolute symlinks (e.g. LLVM ships symlinks to |
Sponsor of this change here! Yes, this allows creating symlinks to anywhere, but that, as @fmeum says, is not a new behavior; any action was able to do that before this change. The reason why this is not a problem is that an "unresolved symlink" means that actions should only do Of course, if an action breaks this contract, it's a problem. That's the same kind of issue as reading a file that's not a declared input of the action: not allowed by contract and if there is a sandbox, it may prevent doing that mistake. |
Ok, thank you. I have gained further understanding now. |
Unresolved symlink artifacts created with `ctx.actions.symlink(target_path = ...)` are now created without making the target path absolute by prepending the exec root, which diverged from the documentation and intended goal and also gave rise to hermeticity issues as such symlinks would regularly resolve outside the sandbox. Furthermore, in order to bring local execution in line with other execution types, the runfiles manifest entry (and thus the runfiles directory contents) for symlink artifacts are now their target paths rather than their exec paths, which along the way resolves another soure of non-hermetic resolution outside the runfiles directory. This requires making symlink artifacts (but not artifacts representing regular files) inputs of `SourceManifestAction`, which previously had no inputs. The change flattens a nested set in `getInputs`, but benchmarks confirm that this does not result in a performance regression. Alternatives considered either result in a substantially worse Starlark API or wouldn't work for symlinks created by spawns. Work towards bazelbuild#10298 Closes bazelbuild#16272. PiperOrigin-RevId: 474784371 Change-Id: I15d318c30542c1da54d86d9b1ae769fe2a0ec970
Unresolved symlink artifacts created with
ctx.actions.symlink(target_path = ...)
are now created without making the target path absolute by prepending the exec root, which diverged from the documentation and intended goal and also gave rise to hermeticity issues as such symlinks would regularly resolve outside the sandbox.Furthermore, in order to bring local execution in line with other execution types, the runfiles manifest entry (and thus the runfiles directory contents) for symlink artifacts are now their target paths rather than their exec paths, which along the way resolves another soure of non-hermetic resolution outside the runfiles directory.
This requires making symlink artifacts (but not artifacts representing regular files) inputs of
SourceManifestAction
, which previously had no inputs. The change flattens a nested set ingetInputs
, but benchmarks confirm that this does not result in a performance regression. Alternatives considered either result in a substantially worse Starlark API or wouldn't work for symlinks created by spawns.Work towards #10298