Compiling a simple hello world application like this:
fn main() {
println!("Hello, World!");
}
Generates a relatively huge 822 KB executable using the default compiler options (rustc hello.rs
).
Why does this happen and what is the best way to reduce the size of the executable?
-O
and/orstrip
. For kicks and giggles you may also link to libstd etc dynamically (not sure how, though). – sellibitze-Z lto
(link-time optimisations) shrinks things plenty too. – Chris Morgan