johnthagen / min-sized-rust

🦀 How to minimize Rust binary size 📦
MIT License
8.23k stars 212 forks source link

Dynamic linking #68

Open the8472 opened 3 months ago

the8472 commented 3 months ago

Dynamically linking against libstd and possibly other libraries can significantly reduce binary size (even though not overall size).

This has of course the caveat that rust has no stable ABI so everything needs to be compiled with the same compiler version and build flags. But it can still be useful for multi-binary projects that share a lot of code or embedded-linux-builds where recompile-the-world is an acceptable cost.

johnthagen commented 3 months ago

I think this would be a great example for a blog post that showed how this could work and the resulting binary size savings.

If someone writes such a blog post, I'll link to it in min-sized-rust.

otavio commented 2 months ago

Just for the sake of completeness, I think that recompiling the world is not a problem for embedded devices, mostly because this is usually done.