Hacker News new | ask | show | jobs
by timlyo 2942 days ago
There'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-executab...

1 comments

s/z was made stable ten days ago: https://github.com/rust-lang/rust/pull/50265

So, two releases :)