Hacker News new | ask | show | jobs
by jgavris 1745 days ago
I'm surprised nobody has mentioned trying out using Google's Bazel build system with the Rust rules. Bazel provides relatively straightforward 'remote caching' of build artifacts via Google Cloud Storage or S3.

https://github.com/bazelbuild/rules_rust

3 comments

Another few benefits with Bazel is that your build is mostly hermetic and reproducible. I've never had to run `bazel clean` and the output sha of your builds will always be the same (good for signing and security). You can also use remote build execution (RBE) to run your builds in parallel. This makes for a massive performance boost when you're compiling a lot of libraries (packages, source files, etc).

It also models your source code in your build system (exposing libraries, binaries, etc).

I'd love to see a performance comparison with `rules_rust`.

Of course, making the right abstractions and library / module / crate boundaries is still very much important to incremental build performance. For 'very large' Rust projects, setting up remote build execution can be hard, but a few of the original Bazel folks at Google are trying to make that easier for folks with EngFlow https://www.engflow.com/
Engflow has some very smart people.

There are also a number of other open source alternatives such as Buildbarn (https://github.com/buildbarn) and Buildfarm (https://github.com/bazelbuild/bazel-buildfarm) which you can host yourself.

Personally, I've found Buildbarn great to throw up in Kubernetes and build massive projects with.

This space is pretty healthy right now! For an updated list of people in this space you can also check out: https://bazel.build/remote-execution-services.html
Bazel's learning curve is really high if you're learning it from the scratch from the web. It took me most of a week to figure out how to write a custom rule that just calls a python script that dumps out a tree of files. What would been a few lines of makefile turned into about a hundred lines of starlark boilerplate. I haven't given up on it yet, but you need to be using it for something serious to have any hope of amortizing the cost of porting a build to it. Rust+Bazel is combining two niches; I'm surprised there is any support at all at the intersection.
There's support because Google uses Bazel and Rust, so they need a way to use Rust from Bazel.

I haven't really used Bazel much, but the features it brings are really huge: reliable pure compilation, so you can actually do globally cached and distributed builds reliably.

Maybe I should try it.

Have you personally set up bazel builds for a large rust project? Curious what that looks like.