Bazel Build System Support for LLVM
github.com
github.com
A bunch of comments seem to be comparing and contrasting CMake+Ninja vs. Bazel. Just my two cents, but I think that's missing the real point of this work.
It isn't about whether Bazel is a better build system for LLVM. At least, that isn't my motivation.
There are users of LLVM's libraries that use Bazel. Whether for good or bad reasons, it is extremely useful to enable them to use LLVM's libraries with a fully native Bazel build. That is my motivation: enabling the users of LLVM libraries that need to use Bazel for whatever reason to have the best possible experience.
- cmake: ~2900 files @ 28:21.07 total (https://snapshot.raintank.io/dashboard/snapshot/ijkptI1dlteB...)
- bazel: ~5k targets @ 23:55.13 total (https://snapshot.raintank.io/dashboard/snapshot/TbOP6L814R3q...)
If anyone can recommend a file to modify I'd also be happy to test out incremental build times. Anyway, super glad to see google externalizing some of this stuff! I also have the metrics from this prometheus instance saved so if anyone wants to see any other metrics from node_exporter let me know!
fwiw bazel "felt" slower because the number of targets is an estimate and that kept going up while cmake was constant progress to "finish". I'd love to see how the bazel time looks with remote build execution enabled to see how much faster that goes.
If this really is a correct result, I bet the ninja people would want to hear about it. (And, kudos to the Bazel folks!) But I think it's more likely measurement error. Maybe the build flags or host compiler aren't the same in the two configurations?
This is absolutely not a definitive "X is better than Y" since X and Y are completely different things.
- clean, caching disabled @ 5.93m INFO: Elapsed time: 356.189s, Critical Path: 187.81s INFO: 4235 processes: 4235 remote.
- clean, fully remote cached @ 27.33s INFO: Elapsed time: 27.330s, Critical Path: 15.93s INFO: 4235 processes: 4235 remote cache hit.
Full disclosure - I co-founded BuildBuddy (YC W20) which provides bazel remote build execution and other open core bazel tooling
I think ultimately it needs a company like npm that can upstream the needed changes to Bazel itself so that it supports these workflows better. With the right focus you could hit cargo levels of ease of use, but for large multi-language projects.
The tl;dr version of the doc: https://docs.google.com/document/d/1uzsmnc0hcGb3kSWF0kNqvACr...
The full doc: https://docs.google.com/document/d/1moQfNcEIttsk6vYanNKIy3Zu...
It's in an open-to-comments state and the author of the design doc has been SUPER responsive and extremely amazing to talk to. He's been fully willing to put up with all of my stupid questions.
It's also not easy to publish a version of your package (A) that depends on another package (B). This would create a diamond-problem like situation where your package (C) depends on both packages (A->B, C->A, C->B). So, some code needs to resolve these issues and reproducible identify the exact hashs of everything to pull in to make it a not-manual process.
Also, something great about the design docs linked in my other post: there's a presubmit.yaml standard so, pulling in a library, will include tests that bazel will run for whatever arch you're compiling for. For instance, say you pull in sqlite and need to build it for RISC-V. Before you just needed to hope that sqlite worked correctly on your arch, now you'll be able to test those situations in CI with RBE runners for all architectures.
I agree, but I don't think a "Bazel management system" would solve this issue, because the problem is people buying into bazel in the first place
> It's also not easy to publish a version of your package (A) that depends on another package (B). This would create a diamond-problem like situation where your package (C) depends on both packages (A->B, C->A, C->B). So, some code needs to resolve these issues and reproducible identify the exact hashs of everything to pull in to make it a not-manual process.
This is a good point. However, I think realistically, effort would be better spent currently on making it easy to bazelize existing code. I have (unfortunately) never been able to pull an external library without manually bazelizing it, and this only actually ends up becoming a problem when bazel picks up enough momentum in OSS that you are likely to find a external library that is already bazelised.
This is pretty standardized and "recommended" by bazel-federation: https://github.com/bazelbuild/bazel-federation
A good example of how this becomes a massive mess: https://github.com/bazelbuild/rules_docker/blob/master/repos...
I agree on the bootstrapping issues resulting from that, though.
Advocating for Java as a general purpose tool language sort of overlooks the incredibly broad and prevasive installbase of machines more than ten years old, as well as the rapidly growing installbase of ARM SOC machines.
For many, a tool eating up a gigabyte or more of memory is certainly not acceptable.
Personally, my primary home/non-work machines are an RPi4 and a Pinebook Pro.
Hmm.
The fact that you personally deem the needs of others illegitimate doesn't preclude them from actually existing.
For many it is Bazel that is inferior due to development environment constraints.
And "outdated" is a questionable term: if it satisfies their needs, why upgrade?
Maybe Google should build better tools.
You're talking about computers from 20, 20+ years ago and about Raspberry Pi.
It's a personal choice.
You can get a good second hand desktop from 2012-2015 for the price of your Raspberry Pi.
Have you lived in the places you've listed?
I have family in Colombia.
I'm from a place similar to those you're describing.
Few people would get enthusiast gear like Raspberry Pi. What they would get, instead, would be an old x86 PC with pirated Windows. A crummy knock off Chinese laptop or locally assembled PC (so not from the big OEMs).
We have some peculiarities of our Bazel setup that are not common, yet are (supposed to be) fully supported.
Building can take hours.
It's a pity, feels like a real missed opportunity.
By analogy, I'd say that if Make is a hammer, Bazel is a CNC machine. Most DIYers are going to have hammers, and everyone understands how to use them, but CNC machines are becoming cheaper and more common.
Most tellingly, Google has gone through two major build system migrations (Android and Chrome), and neither project chose to migrate to Bazel/Blaze. If Google won't eat their own dogfood, it doesn't inspire much confidence.
Chromium's gn started being prototyped in 2013 [1].
Android's soong started being developed in June 2015 [2].
Bazel's first open source release was in September 2015 [3].
In addition, you surely can't be serious about Google not 'dogfooding Blaze' - it's a critical build system internally at Google. And new external projects (like gVisor) are also now built using Bazel.
[1] https://chromium.googlesource.com/chromium/src/tools/gn/+/3b...
[2] https://android.googlesource.com/platform/build/soong/+/e441...
I'm not sure what to make of this statement. Why is 156MB prohibitive? You don't need to include Bazel in the project any more than you need to include Xcode for the macOS version of a project. You can specify a version of Bazel with .bazelversion so you don't need to worry so much about people using the wrong Bazel.
There are some systems like Waf and Autotools where the build system is customarily bundled inside the source release, but this is not universal--if you use CMake, it's almost certainly not bundled either.
> Most tellingly, Google has gone through two major build system migrations (Android and Chrome), and neither project chose to migrate to Bazel/Blaze. If Google won't eat their own dogfood, it doesn't inspire much confidence.
Android is a fairly large project itself consisting of the Kernel (which has got its own custom build system) and a ton of different components. From what I understand, for NDK projects, Bazel is moving towards "the one sane way to do things", it will just take time, this stuff doesn't happen overnight. For non-NDK (pure Java or Kotlin) projects, there's not really a point.
Chromium is a bit of a special snowflake and predates Bazel's Windows support, and a codebase the size of Chromium would take a long time to migrate--but it looks like it's heading in that direction. From what I can see in the revisions to the Chromium build system, it seems that it's massive custom build system is moving towards Bazel by leaps and bounds. It's already structured like a Bazel project and uses much of the same terminology, I wouldn't be surprised if a few hundred Bazel scripts appear overnight in Chrome, because it looks like much of the groundwork has been done.
Most open-sourced Google projects use Bazel now. Of course, projects like Android and Chrome have been around for a long time and have invested in their build systems, so any change will take years.
(disclaimer: I've worked on Bazel)
What are these "issues"?
And Bazel's build system itself IIRC wants to download stuff from the Internet on build - which can be pre-fetched, but distro maintainers still don't like having to deal with taht.
bash configure && make imagesI feel your pain, We had a lot of the same complaints with Bazel, Buck, Pants etc.
It seems like a great public use case/benchmark for a large common project to test with.
Defaults to Ninja and its superfast.
So I wish someone smarter than me would go clean up the current CMake setup instead of using another build system altogether. But I guess any improvement to build usability is a good thing.
That said, I'm not sure why they don't just hash the compiler and library binaries instead of building them from scratch... but that's a different question.
[0] - https://cacm.acm.org/magazines/2016/7/204032-why-google-stor....
As of recently (LLVM/Clang 11), its CMakeLists.txt still doesn't work with Clang as a compiler (and MSVC's headers). Partly because <atomic> doesn't compile in Clang's C++11 mode (which the .cmake files use when testing for atomics), and partly because it can't detect Clang's host/target (don't know) triple. I recall getting build-time failures as well as CMake setup problems.
[0] https://github.com/hexops/llvm-go-bindings#known-issues-with...
[1] https://bugs.llvm.org/show_bug.cgi?id=44551
[3] https://llvm.org/docs/Contributing.html#how-to-submit-a-patc...
Any specific info on this? I build llvm and various associated projects, mostly on linux but on windows and macos sometimes, and don't remember issues of this nature.
I just kicked off a build of llvm and clang on windows using VS 2019 community and it finished just fine. I used the Ninja generator for speed but "Visual Studio 16 2019" also works. Those are the only two I do.
EDIT: ah, using llvm/clang to build llvm/clang. I have not done that, I use VS community. I'm not sure this is actually a CMake issue though.
I've been talking to the Meson devs about how it would be really nice to nail this in Meson.
Compiler's build systems are usually an absolute mess, and there's no reason it needs to be this way. As a distro maintainer, compiler's terrible build systems are in fact my #1 source of issues.
Still, nice build system.
Is that not really an issue in practice? Do people automate that away?
So far, it seems to result in a more accurate Makefile (with includes), but my project is pretty small. The Erlang compiler can also output a dependency file, with pretty similar looking arguments, so that helps too.
It's not just listing them once, so they get installed or such. You need to list them as dependencies for objects that get built.
> I just found this tutorial to get the compiler to list your dependencies for you with (GNU) Make
Yea, that works very well. A lot of projects sticking with make use that via some makefile hackery (e.g. postgres). Cmake etc do so automatically as well(at least for the common generators).
But with bazel you have to basically maintain that manually on a granular basis. So if you add a new #include to some random .c file you often also need to add that as a dependency. There's a bunch of error checking around that to make it easier to get it right, but it's still seems like a lot of work to me.
Bazel has a some nice ideas, but has shat in my cornflakes too many times. It's really unusable for anything that isn't an all-inclusive monorepo.
It's funny because we with Nixpkgs want to be all-inclusive too, except we don't think that requires vendoring the world / perfect synchronicity.
I'm not sure exactly what you mean by synchronicity, but that's basically how e.g. package-lock.json works... it's the direction that everything is moving in, and Bazel is a target because it's imposing this on new frontiers rather than just being a new language where "things work that way".
I think both sides want to erase that difference, and I commend them for it.
> I'm not sure exactly what you mean by synchronicity, but that's basically how e.g. package-lock.json works... it's the direction that everything is moving in, and Bazel is a target because it's imposing this on new frontiers rather than just being a new language where "things work that way".
package-lock.json stuff is fine, and Nix has long required that everything be locked.
That is the good synchronicity: it's OK if upstream moves faster, downstream catches up and just pins whatever they are using. You can see how upgrade waves cascade downstream, this is because the sychronizing is local.
The internal good model is everything just lives in one repro and must update all at once. This is global synchronicity.
----
It's a lot like 1 giant lock vs Multiversion concurrency control. The MVCC aspect is that there may be a few versions in flight as things cascade down, but old versions should be retired (like committed transactions) as new ones come.
The consistency is basically the pinning; nevermind what other transactions/development is going one elsewhere, each package sees a consistent view as structured by the pins.
If you go listen to Google people talk about dependency/version management. It's like they think it's global lock vs inconsistency. Monorepo or chaos. This false choice irks me.
I guess their dev tools people should talk to their DB people?
I watched this talk: https://www.youtube.com/watch?v=tISy7EJQPzI
I’d say this is a much more nuanced look at dependencies & versioning. We all know these days that something like semantic versioning is not enough, because it is too easy to depend on behavior which the developers of your dependencies did not expect you to depend on. So you need something more powerful than just having a bunch of developers get together and agree not to break each others’ code.
Bazel is a part of that solution—if you can analyze and understand the dependencies in a project, and do so in a very automatic and reliable way, you can provide people with tools tools for updating downstream code when upstream code changes.
I think people are focusing too much on Bazel as only a build system and not as part of a platform for building developer tooling, and people are focusing too much on Bazel’s original incarnation as a build system for a massive monorepo.
I think there’s also a reality that we must deal with that is—as software gets larger and more complex, and as we have more dependencies, relying on version pinning for stability is losing ground as a technique for making our software more reliable. We have many more dependencies in our software now, so just subscribing to a mail feed of all of the version bumps in the libraries you use would be enough to drown you, and the longer you stay on older versions the more painful it can be to upgrade.
Bazel and Nix both want to control everything...and it gets ugly. Nix is pretty wall layered, and while it has plenty of UX problems, it's quite easy to predict what it will do.
Bazel has the classic problem of new well-funded software of being more polished than architected, and so feels like working with an amorphous blob where all that polish turns on you when you do something weird and now it oozes unforeseen complexity and interactions.