fosstodon.org is one of the many independent Mastodon servers you can use to participate in the fediverse.
Fosstodon is an invite only Mastodon instance that is open to those who are interested in technology; particularly free & open source software. If you wish to join, contact us for an invite.

Administered by:

Server stats:

10K
active users

Hello world, without any arguments to gcc or rustc

Plain C 16kB
Rust 11MB

Getting the feeling that there are quite a lot of debug stuff in that rust executable...

talpa

rustc -C lto -C debuginfo=0 -C opt-level=3

And we are down to 4.5MB but did take quite a significant hit on compilation time

stripping the executables

15kB
339kB

@talpa is there no equivalent of -Os in rustc? As an embedded dev using mostly C++ currently eyeing rust from afar, i'm genuinly curious. I looked at rustc flags and didn't find one.

@BenjaminBugl There are both s and z for opt-level

Which optimizes for size (not that there is much to optimize for a hello world program

And there are definitely other things one can try like disabling "panic" code (you loose the stack trace on crashes from what I can tell)

@BenjaminBugl The size optimisations dropped it down to 323 kB ...
But yes as an embedded developer that used to be part of the demoscene, I'm not that impressed by the out of box experience.

@talpa still big. would be interesting if this is basically a static overhead and the scaling is similar to C. that would be totally ok for me then, if I get those sweet, sweet compile-time guarantees. i also must say i would trade some scaling for language, library and tooling ergonomics.

@talpa oh also the panic codes mostly don't help me on anything microcontroller adjacent, so they would probably be thrown out pretty quickly, especially in release builds.

@talpa I need to do some research on this myself. I got this itch in my fingers now...

@BenjaminBugl I just wanted to give it a try (have been for e while now), and it is actually easy enough to get compiling.

The cargo build system also seems kind of nice (not a big fan of using the package system part of it)