Hacker News new | past | comments | ask | show | jobs | submit login

6MB is quite large. Makes me question if you were even building in release mode.

You may want to see https://github.com/johnthagen/min-sized-rust

It's not difficult to get binaries down into the 50KB range. And for embedded applications, less than 10KB is totally possible.




Yes I tried all those 'minimize rust' approaches including the above one.

they worked fine if you're statically link to its stdlib.

but if you have a few complex rust binaries, static link for each of them is not going to help on the overall combined size.

I did use a released library and build everything for release(per those minimize projects), I can easily cut a small program from 3M to 290KB but again, it is either static link, or you need a 6MB dynamic library to go with it.

the key question is, what's the smallest size for Rust shared library? so far my finding is around 6MB(after strip, otherwise it's about 11~12MB)


Oh so your problem is that when attempting to dynamically link to the standard library, you're missing out on the dead code elimination you'd get when statically linking. Rust doesn't have a stable ABI anyways, so you can't really share the standard library between programs unless you're really careful.


you nailed it.

neither LTO nor panic=abort can be used at dynamic link, no stable ABI is another thing.

to me it means Rust is not a good fit for embedded space for majority of the use cases, sadly.


I'm not sure what embedded space you're referring to, but microcontrollers, in my experience, generally use monolithic binaries. I'm unsure why you'd wish to use dynamic linking in those cases.




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: