Live data from Hacker News

Scaling Rust Builds with Bazel

mmapped.blog

11–20 of 133 posts

Re: Scaling Rust Builds with Bazel

#11
post #5

The joy of tooling. If there's one tool it's not a mature ecosystem, if there's two, there's no standard way to do things. "Cargo is not a build system" reminded me of "Cabal is not a package manager" https://ivanmiljenovic.wordpress.com/2010/03/15/repeat-after...

Wait til you see the eight ways Nix has of packaging Rust applications! https://nixos.wiki/wiki/Rust#Packaging_Rust_projects_with_ni...

Re: Scaling Rust Builds with Bazel

#12
Hey, what a surprise, ex-google engineers dragging everyone into bazel...

Maybe you have some really complicated use case that makes cargo insufficient, but really, it's pretty damn nice and it's integrated with everything.

There are languages that need bazel, rust isn't one of them

Re: Scaling Rust Builds with Bazel

#13
post #9

One question I have after all these articles and internal company presentations is: how exactly does Bazel track dependencies? Module A importing module B importing module C is a language-level feature, not a build system-level feature.

You basically have to declare all those dependencies in Bazel. For instance, if you look at rules for Go, they declare the whole dependency graph (Modules, their relations) in Bazel. There is tooling to generate that for you, so it's not really that bad. Where it gets harder is when this language feature is integrated with an existing build system. C# is normally build with it's own build system, and to build it with…

Have you got any more information on how to use Bazel with C#?

Re: Scaling Rust Builds with Bazel

#14
post #3

If you want something similar thats written in Rust instead of Java, look at Buck2 https://github.com/facebook/buck2

Similar to EdenFS/Sapling VCS, buck2 is being developed as such a fast pace that it's hard to imagine there would be any OSS support for it. Together with buck2 are 3-5 other repos that are supposed to be built and used together with it.

If you want stability, Bazel is still a much better choice with their LTS release program.

Re: Scaling Rust Builds with Bazel

#15
post #12

Hey, what a surprise, ex-google engineers dragging everyone into bazel... Maybe you have some really complicated use case that makes cargo insufficient, but really, it's pretty damn nice and it's integrated with everything. There are languages that need bazel, rust isn't one of them

Even just for running test suites incrementally, Bazel is pretty nice. If you have CI that takes "too long", Bazel is basically the only serious tool that can get you to incremental CI in a pretty rigorous way.

Though I seriously wish there were a better option, because there are a _lot_ of usability things with Bazel that make me very frustrated when working with a repo that is "merely" quite large.

Re: Scaling Rust Builds with Bazel

#16

One question I have after all these articles and internal company presentations is: how exactly does Bazel track dependencies? Module A importing module B importing module C is a language-level feature, not a build system-level feature.

You have to declare in Bazel as well.

But really, I think that people don't go extremely granular on this. For Rust projects that are spread over 10-100 crates, I think that most people would just model the crate dependencies rather than at a file level. Mostly for pragmatic reasons, but also because that will likely model your test suite closely and your build requirements.

Bazel is a build tool, so one "module" (in Bazel you talk about target) per build artifact basically aligns with what people want. But you can in theory go really granular, making it so that tests only run if files it depend on change (less granular and that becomes "crates they depend on change")

Re: Scaling Rust Builds with Bazel

#17
We use a similar setup where I work. One challenge we have has been generating bazel targets for different sets of crate features for dependencies. We have solved this by writing Bazel tooling, but learning how to do this has cost a fair bit of time. We also rely heavily on cargo-raze, which has rough edges.

As with all things Bazel, it's great when it works, but it has a steep learning curve that could be hard to justify in many situations. You need at least one person on the team who is willing to really spend time on it.

Re: Scaling Rust Builds with Bazel

#18
post #9

One question I have after all these articles and internal company presentations is: how exactly does Bazel track dependencies? Module A importing module B importing module C is a language-level feature, not a build system-level feature.

You basically have to declare all those dependencies in Bazel. For instance, if you look at rules for Go, they declare the whole dependency graph (Modules, their relations) in Bazel. There is tooling to generate that for you, so it's not really that bad. Where it gets harder is when this language feature is integrated with an existing build system. C# is normally build with it's own build system, and to build it with…

> There is tooling to generate that for you, so it's not really that bad.

So you need several layers of tooling just to get something built.

It's bad

Re: Scaling Rust Builds with Bazel

#19
post #16

One question I have after all these articles and internal company presentations is: how exactly does Bazel track dependencies? Module A importing module B importing module C is a language-level feature, not a build system-level feature.

You have to declare in Bazel as well. But really, I think that people don't go extremely granular on this. For Rust projects that are spread over 10-100 crates, I think that most people would just model the crate dependencies rather than at a file level. Mostly for pragmatic reasons, but also because that will likely model your test suite closely and your build requirements. Bazel is a build tool, so one "module" (in…

> You have to declare in Bazel as well.

> For Rust projects that are spread over 10-100 crates

It's already 10-100 crates you need to manually declare and keep track of, or use a yet another tool to generate this for you.

And for big projects you'd also want to go more granular and split by parts of your app I guess.

Re: Scaling Rust Builds with Bazel

#20
post #12

Hey, what a surprise, ex-google engineers dragging everyone into bazel... Maybe you have some really complicated use case that makes cargo insufficient, but really, it's pretty damn nice and it's integrated with everything. There are languages that need bazel, rust isn't one of them

I'm inclined to agree, but mainly because I can't see an issue where cargo is insufficient, it seems to me that would be an issue somewhere else. Not cargo specific.
Post reply on HN