What's in a Rust binary?

36 points AlmaemberTheGreat

Hello!

I'm a C programmer (hobbyist, but... irrelevant). I don't know much about Rust (beyond having tried it a little), but I do use some Rust software, mostly random system utilities.

Now, one thing I have noticed is the file size of binaries from Rust programs are huge, at least compared to C.

For example:
uu_ls, in Rust, uses 5.5M of disk space (1.9M stripped). Compare this to the Coreutils ls, which is 143K, orders of magnitude less. That's already stripped, by the way. Coreutils is also a little more than twice as fast on my machine, but that's irrelevant.

My question is: what is that space doing? Wasn't Rust statically linked? Is it the language's fault, or the developer's?

(By the way, the suckless sbase's ls is 27K, but I think comparing size to suckless is kind of unfair.)

I'm assuming something useful happens with that space, and that it's not just boundary checks.

Thanks for the attention in advance!