Making the case that Cargo features could be improved to alleviate Rust compile times

6 points by dryya


jmillikin

Cargo features are fundamentally incompatible with the DAG-style compilation graphs needed for efficient build caching, and is a big part of the reason why Cargo builds so are so incredibly slow compared to other build systems (e.g. Bazel) despite using the same rustc. You just can't get fast builds if a dependent library can alter the compilation inputs of its dependencies, transitively.

And when you start investigating why Rust codebases use Cargo features in the first place, they often exist to work around the crates.io limitation of one library per package. Instead of a foo package containing foo and foo_alloc and foo_std libraries, you get a foo package with alloc and std features, which per above mess with the caching.