-
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
Windows: Building py binaries remotely is broken ("rule is missing dependency declarations") #5087
Comments
Some progress. It turns out that adding "third_party/zlib" prefix (similar to what is done in See this commit in my fork: jasharpe@8c016bf I'm not sure if this is the correct fix (someone else with more context may be able to say), but sheds some light on the origin of the problem. |
More partial progress. The problem is here: bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/HeaderDiscovery.java Line 182 in 060b162
If you comment out this line then the build succeeds (without the change I have above). Something about this is overzealous for remote builds (or underzealous for local builds). |
Ah, I have figured out the specific issue, but I'm not sure what the correct fix is. We're hitting this "problem": bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/HeaderDiscovery.java Line 150 in 060b162
The execPathFragment here is something like This problem is not encountered locally because we fall into the "funky but tolerable" exception here (since the file when running locally is under the local exec root, but it isn't when executing remotely): bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/HeaderDiscovery.java Line 148 in 060b162
So, the question remains: what should be done about it? Is it WAI that we should have to add the "third_party/zlib" prefixes to includes so we don't fall into the "funky but tolerable" bucket? If we leave it in this state it's pretty hostile to remote execution use cases, since they're treated much more strictly and we may run into this problem again. |
I think we should make Bazel realize the remote exec root and use it during header checking. |
/cc @mhlopko Well, it's definitely not trivial, but I think the right thing to do here is to make input validation work with remote execution. In a pinch, we could do with just not doing input validation and rely on the right files being shipped to the executor. I haven't thought very deeply about the implementation, but |
This include validation is blocking us pretty hard on building non-trivial things remotely on Windows. Any possibility that a short-term fix like an experimental flag to disable include validation would be okay? |
@jasharpe Do you know why it's not an issue on Linux? |
@nlopezgi had some insight into how this works on Linux (AFAIK it is not an issue anymore). |
A workaround that doesn't involve making changes to Bazel itself is to add something like this to CROSSTOOL (path matching whatever is given to the local remote worker's --work_path flag):
|
|
iirc, the headers file produced by gcc/clang in Linux have relative paths (e.g., instead of "C:/tmp/lre/build-908a6a0b-0ac0-457d-b58c-06ef6220bf72/external/bazel_tools/third_party/zlib/zconf.h" the line would be "external/bazel_tools/third_party/zlib/zconf.h"), if an only if, it was invoked in "the right way". I.e., invoking it from an absolute path resulted in a params file with absolute paths and invoking it in a relative path (from the bazel execroot) resulted in a params file with relative paths. If the files are produced with relative paths, header checking in Linux verifies these relative paths as files in the Bazel runfiles tree, and for files in absolute paths (which are always outside of the runfiles tree) we use cxx_builtin_include_directory. We did have some issues with this check when we were doing hermetic toolchains, and at some point we did think we would have to include wrapper scripts to change paths, but we got around it by calling the compiler in "the right way". Now, I don't know if this is possible for Windows. I think that issue here is that the folder in which the bazel command runs inside the remote worker (inside docker) should not be leaking in the outputs (in the params file), so we have two options:
|
For the record, here's a typical compile step (found with the
When you run this, it prints out a bunch of system includes, but also the problematic:
The |
I tried out whether cl.exe cares whether it's invoked via absolute path or via the PATH (as Nick said gcc/clang care about), and it doesn't seem to make a difference to the output of |
So, here's a naive suggestion. If we were able to modify the
Then we could trivially parse the exec root in https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/cpp/ShowIncludesFilter.java and remove this directory from included headers wherever it appears as a prefix. The issue with this is adding an extra command here doesn't seem that easy, or even possible. Maybe this is tantamount to a wrapper in any case. |
@jasharpe Sorry for the late reply. |
Sorry, let me clarify. Running I don't think this is actually feasible since it gets out of the realm of running a single program for an action. Another possible solution off the top of my head could be to add a "remote exec root" field to ExecuteResponse returned by the remote execution API, and have Bazel use this. |
I like the second solution, it would also work for other platforms if needed. |
Here's another idea. I just discovered the Is there some reason I shouldn't use |
@jasharpe I not sure we should re-enable the wrapper script again. The main reason we don't like it is because it's slow. I had a 40% build time reduce for |
Closed for lack of activity. Please ping the reviewers to reopen if this is still a problem. |
Description of the problem / feature request:
Building py binaries remotely on Windows (on the local remote worker) is broken, due to an error like this:
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Create an empty WORKSPACE and add these files: https://gist.github.com/jasharpe/bd4f346d3338abe430ef6022a6c85e39
Demonstrate that it works locally:
Get error similar to:
What operating system are you running Bazel on?
Windows Server 2016
What's the output of
bazel info release
?release 0.12.0
(Note, I've also tried this with 0.11.1 and HEAD Bazel and it fails in the same way.)
If
bazel info release
returns "development version" or "(@non-git)", tell us how you built Bazel.N/A
What's the output of
git remote get-url origin ; git rev-parse master ; git rev-parse HEAD
?N/A
Have you found anything relevant by searching the web?
No, lots of "rule is missing dependency declarations" type of bugs, but nothing quite like this.
Any other information, logs, or outputs that you want to share?
No.
The text was updated successfully, but these errors were encountered: