5 ms·
5MB is nothing compared to what you'd use for a similar project in node or Python or Ruby. Sure, it's not the tiniest it could be, but using tools like strip, n
by sondr3 8y ago
5MB is nothing compared to what you'd use for a similar project in node or Python or Ruby. Sure, it's not the tiniest it could be, but using tools like strip, not including debug symbols etc it gets pretty damn small. Honestly though, at that point I think size becomes entirely pointless to even mention unless you need to run it in a super constrained environment, which you're probably not when you're using the standard library :)
- reacharavindh 8y agoYes, I'm not constrained in any way to not be able to run a 5 MB binary. I was curious if that was an indication of what is to come for large projects... I guess I was tangentially pointing to complexity and abstraction there.
- empath75 8y agorust doesn't use dynamic linking, which contributes a lot to that size.
- steveklabnik 8y agoIt can, but for practical reasons, generally does not. For Rust code anyway; often anything bound via FFI is dynamically linked.
- kingosticks 8y agoWont a crate compiled with 'crate_type = "dylib"' be dynamically linked if you specify '-C prefer-dynamic' when compiling your program? https://doc.rust-lang.org/reference/linkage.html https://doc.rust-lang.org/reference/linkage.html
- skolemtotem 8y agoThis is pedantic, but rust does link dynamically, but only to libc.
- timlyo 8y agoThere's a lot that can be done to shrink a Rust binary[0]. A copy of the summary: - Compile with --release. - Before distribution, enable LTO and strip the binary. - If your program is not memory-intensive, use the system allocator (assuming nightly). - You may be able to use the optimization level s/z in the future as well. - I didn’t mention this because it doesn’t improve such a small program, but you can also try UPX and other executable compressors if you are working with a much larger application. [0]https://lifthrasiir.github.io/rustlog/why-is-a-rust-executable-large.html https://lifthrasiir.github.io/rustlog/why-is-a-rust-executab...
- steveklabnik 8y agos/z was made stable ten days ago: https://github.com/rust-lang/rust/pull/50265 https://github.com/rust-lang/rust/pull/50265 So, two releases :)