Login
You're viewing the functional.cafe public feed.
  • Sep 1, 2026, 6:16 AM

    @TheRealPomax Yes, I can :3. I'm on the compiler team (though I haven't been super active recently) and spent some time looking into disk usage, so I know what's in the target dir. It can also vary by project of course, but this is what I'd say are the most important factors. They are factors in that they all multiply each other's effect.

    The first factor is that binaries are just a lot bigger than source code in Rust. With generics and inlining you can have a lot of abstraction in the source code that compiles down to straightline efficient code. This increases the relative size.

    The second big factor is debuginfo. By default, for dev builds, Cargo enables full debuginfo `-Cdebuginfo=2` which includes variable and inlining information. Because of the previous factor of complicated abstraction, this is huge! But the good news is that if you don't debug your binaries you can remove it: doc.rust-lang.org/cargo/refere

    Then, the third factor is incremental compilation. To speed up compilation after you change something, rustc saves intermediary results for each crate (not for dependencies from crates.io though). This includes one big file with results from its internal query system, and the object file (output from LLVM) from each codegen unit, of which there are dozens per crate (up to 256 by default). Due to generics and the `#[inline]` attribute, many functions get duplicated into many of these codegen units. You can also run off incremental compilation to save tons of disk space (see previous link) but that does lose you some amount of compilation speed.

    Overall, we can say that both when it comes to the language and default build system config, Rust chose the tradeoffs against build system disk use. This gives it other advantages, but it does make the disk use huge.

    💬 1🔄 6⭐ 13

Replies

  • Sep 1, 2026, 2:38 PM

    @noratrieb Cheers. That's still a crazy amount of extra data then, though. Because dozens and dozens of separately compiled crates is still just... Two orders of magnitude =P

    💬 0🔄 0⭐ 1