-
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
Exclude convenience symlinks after changing the output base #21005
Conversation
src/main/java/com/google/devtools/build/lib/skyframe/ProcessPackageDirectory.java
Outdated
Show resolved
Hide resolved
@iancha1992 Can we get someone to review this? |
|
@haxorz, is team-Core the right label for this? If not, do you know which team owns the convenience symlinks? |
(1) Was the (2) Is it intentional in your PR that we'd be changing the semantics for a traversal of a directory containing a dirent whose name just happens to start with the symlink prefix? (Consider @Wyverald - |
@haxorz Using a |
+cc @lberki because back in the day he was involved both the things mentioned below.
Yeah. In 1e66ccd we changed Bazel to respect the Yes, you could use that workaround. I was suggesting you could instruct your IDE users to create a
This would be more complicated but would be most robust because Bazel would be trying to prevent the situation in #10653 from mattering at all. A nitpick would be to either rename that or use a new one with a different name. I will preemptively say though: If you do this, the merge with Blaze internally at Google is going to require some care. |
I did some research internally and it looks running any Bazel command under the execroot is rare enough that it can be safely ignored (see internal thread; I can't discuss the details here) and I'll send out a change to remove it as soon as the presubmits pass. I consider
that directory is not traversed? |
Update: I found a corner case that @Wyverald added to the build of Bazel like a day ago: if you run Bazel query from a genrule AND you are not running in a sandbox AND you plop down a I'll still go ahead with the removal because it looks like it's a very special case only affecting who works on Bazel (in fact, it only showed up on our Windows presubmits), but with a little less confidence. |
…put base. This is legacy functionality from 2009 (in the case of "query") and 2012 (in the case of "print_action", which is when that command was invented). Motivated by #21005 . RELNOTES[INC]: "bazel query" and "bazel print_action" can't run under the output base anymore. PiperOrigin-RevId: 607036900 Change-Id: Ic9272d42d07b802924b4420408146de830a82ad8
45050a1
to
82fd2c4
Compare
@lberki I've updated the PR with the majority of the heuristics that you mentioned. However, I'm unsure of how to implement point 3, since I get the feeling from surrounding code that filesystem access should be done via skyframe rather than more directly. However I'm not too hot on how skyframe works. Could I have some pointers on how to achieve this? I'm also unsure about what depth successor the |
src/main/java/com/google/devtools/build/lib/skyframe/ProcessPackageDirectory.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/skyframe/ProcessPackageDirectory.java
Outdated
Show resolved
Hide resolved
Thanks for updating the pull request! I added a code snippet which I'm pretty sure works after some light editing (I didn't compile it) |
82fd2c4
to
6db7a6e
Compare
src/main/java/com/google/devtools/build/lib/skyframe/ProcessPackageDirectory.java
Show resolved
Hide resolved
When the output base is changed after the convenience symlinks have been created, queries such as `//...` try to traverse into them and load them as packages since they are only excluded based on whether the resolved location is in the output base. This adds some heuristics to determine if a symlink is a convenience symlink: 1. The symlink name has an appropriate suffix. 2. An ancestor of the symlink target at the appropriate level is called `execroot`. 3. The `execroot` directory contains a file called `DO_NOT_BUILD_HERE`. These heuristics should work if both the output base and the symlink prefix change while being quite robust to false positives. Fixes bazelbuild#10653
6db7a6e
to
62d8862
Compare
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.
Sorry for taking my time; this accidentally fell off my task list.
src/main/java/com/google/devtools/build/lib/skyframe/ProcessPackageDirectory.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/skyframe/ProcessPackageDirectory.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/skyframe/ProcessPackageDirectory.java
Show resolved
Hide resolved
* Split large or statement into multiple ifs. * Check if there is enough path segments in `isInExecRoot`.
@lberki I've addressed the latest review comments. |
Thanks. Looks good to me now! |
@bazel-io flag |
@bazel-io fork 7.1.0 |
When the output base is changed after the convenience symlinks have been created, queries such as `//...` try to traverse into them and load them as packages since they are only excluded based on whether the resolved location is in the output base. This adds some heuristics to determine if a symlink is a convenience symlink: 1. The symlink name has an appropriate suffix. 2. An ancestor of the symlink target at the appropriate level is called `execroot`. 3. The `execroot` directory contains a file called `DO_NOT_BUILD_HERE`. These heuristics should work if both the output base and the symlink prefix change while being quite robust to false positives. This is important for IDE integration, where the [output base is often changed](https://bazel.build/run/scripts#output-base-option) for queries, to prevent concurrent builds from blocking them. An example of this is the vscode-bazel extension. Fixes bazelbuild#10653 Fixes bazelbuild#13951 Closes bazelbuild#21005. PiperOrigin-RevId: 610667735 Change-Id: I1869c9a2063f7f526950e48c0b1ee6efa89fd202
…put base. This is legacy functionality from 2009 (in the case of "query") and 2012 (in the case of "print_action", which is when that command was invented). Motivated by bazelbuild#21005 . RELNOTES[INC]: "bazel query" and "bazel print_action" can't run under the output base anymore. PiperOrigin-RevId: 607036900 Change-Id: Ic9272d42d07b802924b4420408146de830a82ad8
…21505) When the output base is changed after the convenience symlinks have been created, queries such as `//...` try to traverse into them and load them as packages since they are only excluded based on whether the resolved location is in the output base. This adds some heuristics to determine if a symlink is a convenience symlink: 1. The symlink name has an appropriate suffix. 2. An ancestor of the symlink target at the appropriate level is called `execroot`. 3. The `execroot` directory contains a file called `DO_NOT_BUILD_HERE`. These heuristics should work if both the output base and the symlink prefix change while being quite robust to false positives. This is important for IDE integration, where the [output base is often changed](https://bazel.build/run/scripts#output-base-option) for queries, to prevent concurrent builds from blocking them. An example of this is the vscode-bazel extension. Fixes #10653 Fixes #13951 Closes #21005. Commit 8f74ace PiperOrigin-RevId: 610667735 Change-Id: I1869c9a2063f7f526950e48c0b1ee6efa89fd202 Co-authored-by: Cameron Martin <[email protected]> Co-authored-by: Yun Peng <[email protected]>
When the output base is changed after the convenience symlinks have been created, queries such as
//...
try to traverse into them and load them as packages since they are only excluded based on whether the resolved location is in the output base. This adds some heuristics to determine if a symlink is a convenience symlink:execroot
.execroot
directory contains a file calledDO_NOT_BUILD_HERE
.These heuristics should work if both the output base and the symlink prefix change while being quite robust to false positives.
This is important for IDE integration, where the output base is often changed for queries, to prevent concurrent builds from blocking them. An example of this is the vscode-bazel extension.
Fixes #10653
Fixes #13951