-
-
Notifications
You must be signed in to change notification settings - Fork 14.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
bazel: 0.24.0 -> 0.26.0 #62336
bazel: 0.24.0 -> 0.26.0 #62336
Conversation
@GrahamcOfBorg build bazel |
My local Darwin build error is:
|
My local linux build succeeds, but tests are failing with:
|
Here's a fix for the Darwin issue: diff --git a/pkgs/development/tools/build-managers/bazel/default.nix b/pkgs/development/tools/build-managers/bazel/default.nix
index 3b23ca395e8..3a880541228 100644
--- a/pkgs/development/tools/build-managers/bazel/default.nix
+++ b/pkgs/development/tools/build-managers/bazel/default.nix
@@ -160,6 +160,9 @@ stdenv.mkDerivation rec {
src/tools/xcode/realpath/BUILD \
src/tools/xcode/stdredirect/BUILD \
tools/osx/BUILD
+
+ # nixpkgs's libSystem cannot user pthread headers directly, must import GCD headers instead
+ sed -i -e "/#include <pthread\/spawn.h>/i #include <dispatch/dispatch.h>" src/main/cpp/blaze_util_darwin.cc
# clang installed from Xcode has a compatibility wrapper that forwards
# invocations of gcc to clang, but vanilla clang doesn't |
Legend! Thanks @uri-canva I'll kick off a local test now. I think I'll have to fetch the I think I understand what is happening during the This is failing under Nix. I'm not 100% clear on how or if this should be fixed. I wonder if the whole approach to these tests may fail, given that Bazel can fetch rules remotely. |
@GrahamcOfBorg build bazel |
Success on Darwin, failure on Linux. Must be a first! 😂 I'm looking into the Linux errors. I didn't have sandbox enabled locally, so I'll do that for Linux which will hopefully help track down errors. |
@uri-canva Thanks! Opened this issue to track what's going on: #62555 |
@matthewbauer Any chance you can kick off another build. Linux only. I'm unable to run sandboxed builds in a Docker container at the moment. I've fixed the previous error with rules_sass in f1a511a |
I suspect the Bazel tests fail on Linux because of the network sandboxing. The way the building of the tests should be done to account for that is the same way We could rewrite the whole derivation to split it in two: first build the bootstrap bazel, then use boostrap bazel with It's a lot of work though, we might want to skip the tests on Linux in the meantime. |
@Profpatsch This is now ready for review. Please kick off a build to confirm. I expect it to pass on Darwin. Fail on Linux. I'm able to reproduce the Linux failure on my local VM. |
Yes, I think given the way Bazel works, this is the only sensible solution. I think I understand what is necessary. Will that second inside |
Yes, the deps derivation is separate from the build derivation and they get cached separately. |
So we’re skipping 0.25 alltogether? #61097 |
The Bazel release cycle is too frequent to do 1:1 Nix releases. I certainly don't have time to do it. The functionality I want is in 0.26. In a week or 2 there will 0.27.... |
@GrahamcOfBorg build bazel.tests |
The linux test fails. |
@Profpatsch Yes, thanks, it is expected. We just wanted to confirm if it fails on CI with the same error as we get locally. It does, so that's great, we can hopefully fix it. The failure is due to the sandbox blocking network access during the tests. Bazel isn't very good to test in this way, as rules can go and download other rules at runtime. What are your thoughts to fixing it? |
By now I’m tempted to disable the checkPhase ( |
The problem now is that the fetch arbitrary binaries ( |
The java tools currently live here: https://github.com/bazelbuild/bazel/tree/master/src/java_tools, but they'll move them to https://github.com/bazelbuild/java_tools eventually. We can build them from source in the nix derivation using the bootstrap bazel that should be possible to build without network access. |
Sorry I'm just commenting and not helping much on the PR this time, I don't have enough time to dedicate to it at the moment. |
We can also patch out some of the remote files as long as we delete the references to them: I cannot believe the |
I agree that this is the best course of action for now. PR updated to reflect this. Passing locally on my Linux VM. I'll try to find some time to submit an additional PR to change the approach of the Bazel derivation as @uri-canva is suggesting. |
Great! Seems to have passed. I'll try a quick bump to |
The build works locally for me on Darwin (no sandbox) and a NixOS VM (sandbox = true). I'll update the title, description and squash the commits. |
Is it okay if we leave the commits as-is? I’d only squash in the fixup commits ( |
Apologies, I think I'm too late and I've squashed it all down. In some of my other |
Normally multiple commits for separate changes are not a problem. I’ll force-push the split commits. |
`py_test` tries to download unnecessary dependencies at runtime. We can just as well run it to check the assertion. Upstream issue: bazelbuild/bazel#8575
Factor out the common parts of tests & cache the bazel self-extraction (ugh) to a common store path.
xe is such a trivial package, it should build on every platform that supports a CC compiler.
Okay, I rebased to master & autosquashed the fixup commits. Will merge once it’s green again. |
Ah, I’m sorry, I didn’t see the bump to 0.26.1. Meh, can you push the diff as a separate PR? |
I'm putting a quick PR together for 0.26.1. EDIT: #63038 |
Thanks @Profpatsch @kalbasit |
I just noticed that this changed the hash of the fetch phase of |
Uuuuuuuuuuuuuuugh, I suggest we just don’t. @timokau But for the while being, can you add a |
Don't do what? Don't be careful seems like a bad idea to me ;) And we're already using it in fixed output derivations, I don't see how we could avoid that when building bazel packages. Would that actually help? Since they're fixed output, they will just be fetched from the binary cache and therefore pass the tests even though they're broken. |
@timokau you can probably override one of the phases of the fetcher to invalidate it's input, and force it to compile. Something like |
Interesting idea! I feel like there is a bit of a "just because you can doesn't mean that you should" going on here, but here we go: #63645 I have created a separate attribute for the derivation instead of a list, because a list wouldn't get built with |
Don’t ever use fixed output derivations. |
How else should we fetch bazel dependencies? I'd expect the |
We do it like with all other (well-behaved) package managers and generate nix expressions for WORKSPACE dependencies. I already wrote a mockup hack for updating bazel proper: https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/tools/build-managers/bazel/update-srcDeps.py |
Yeah Bazel is really really biased towards monorepos with full vendoring. I think something good integration-wise can be done with resolved workspaces and provided external repositories, but both mechanisms are very much in their infancy and it's unclear how well supported they are: https://blog.bazel.build/2018/07/09/bazel-sync-and-resolved-file.html |
Ah, yes, that’s the better way tbh. It’s a skylark file, so we should be able to cheat our way by evaling it in a python interpreter. |
Motivation for this change
A few new versions of Bazel have been released. This bumps to 0.26.1 to stay recent.
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nix-review --run "nix-review wip"
./result/bin/
)nix path-info -S
before and after)