I applaud this initiative. yet I wonder - the ideal situation would be to not throw away the debug info (ever), but rather it should be put into an external file. even Linux supports this for many years and nowadays we even have direct support with dwarf5/dwo. is trust taken any action towards that direction? after all: without debug info (which you do not want to ship to customers necessarily), you cannot do profili…
Making Rust binaries smaller by default
41–50 of 199 posts
Re: Making Rust binaries smaller by default
#42> I can imagine a situation where a seasoned C or C++ programmer wants to try Rust, compiles a small program in release mode, notices the resulting binary size, and then immediately gives up on the language and goes to make fun of it on the forums. While I'm not a seasoned C or C++ programmer I have definitely done this to a few new languages when playing around with them. My thought was "If helloworld.rust is this l…
Re: Making Rust binaries smaller by default
#43Earlier quoted context omitted.
I would hope that it could statically link libc and exclude the unreachable portions.
Rust can't do this very well because it doesn't build std as part of the project, that's still an unstable option. It's linking object code.
Re: Making Rust binaries smaller by default
#44I applaud this initiative. yet I wonder - the ideal situation would be to not throw away the debug info (ever), but rather it should be put into an external file. even Linux supports this for many years and nowadays we even have direct support with dwarf5/dwo. is trust taken any action towards that direction? after all: without debug info (which you do not want to ship to customers necessarily), you cannot do profili…
Splitting the debug info from the executable is supported on the 3-big-OSes but only enabled by default on Windows (and maybe macOS?)
Re: Making Rust binaries smaller by default
#45Initial binary size, like of a hello world, is a great indicator of how much abstraction the language has that youre also paying for. For example, java has to set up a constants pool, parse it from the classfile, run init and cinit, resolve references, allocatea a frame, and so on, just to get to the entrypoint. Compared to C without stdlib which needs to basically just run a few bytes to syscall write(). There are o…
Re: Making Rust binaries smaller by default
#46> I can imagine a situation where a seasoned C or C++ programmer wants to try Rust, compiles a small program in release mode, notices the resulting binary size, and then immediately gives up on the language and goes to make fun of it on the forums. While I'm not a seasoned C or C++ programmer I have definitely done this to a few new languages when playing around with them. My thought was "If helloworld.rust is this l…
Re: Making Rust binaries smaller by default
#47Earlier quoted context omitted.
It's not a great sign that this bug existed for 7 years, people noticed, asked about it, wrote tickets, everybody agreed that it should be fixed but then nobody took the time to actually do it (and the eventual fix is a rather crude hack by just stripping the output binary instead of preventing that debug symbols slip into a release binary in the first place). Looks more like a systemic issue in the Rust development…
> but then nobody took the time to actually do it That happens all the time, it's called prioritizing. If you don't let people prioritize, they will burn out and leave the project. That's not what you want.
Re: Making Rust binaries smaller by default
#48So what's in the remaining huge 415KB hello world program? Can we get rid of 90% of it a couple more times?
[profile.release]
strip = true
opt-level = "z"
lto = true
codegen-units = 1
panic = "abort"
cargo +nightly build -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --target x86_64-unknown-linux-gnu --releaseAs mentioned in another thread, I've simply followed https://github.com/johnthagen/min-sized-rust
Re: Making Rust binaries smaller by default
#49It's great to see rust maturing. That people care about binary size and work to improve it is a good sign.
It's not a great sign that this bug existed for 7 years, people noticed, asked about it, wrote tickets, everybody agreed that it should be fixed but then nobody took the time to actually do it (and the eventual fix is a rather crude hack by just stripping the output binary instead of preventing that debug symbols slip into a release binary in the first place). Looks more like a systemic issue in the Rust development…
Because in the end almost nobody actually cares about it enough to create a fix.
Small binaries are great, but people care mainly about how fast it compiles and how fast it runs, and in the few cases where the binary size is important it was already possible to shrink it significantly (more than with this new change). In my entire life I have never heard a user complain about the size of the binary, what people really care about is efficiency/speed at runtime. That's why people regularly mention VS Code using Electron, but not that its installation package alone has >500MB.
Re: Making Rust binaries smaller by default
#50Earlier quoted context omitted.
> but then nobody took the time to actually do it That happens all the time, it's called prioritizing. If you don't let people prioritize, they will burn out and leave the project. That's not what you want.
If people only pick "interesting" problems to work on and ignore fundamental (but boring) issues like this, then those issues will just pile up and frustration and burnout will grow even more in the long run. At some point you'll have to stop feature development for a while and put all hands on cleaning up the accumulated cruft.