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?
The standard library is linked statically by default. You can change that by passing the -C prefer-dynamic
option to the compiler.
Rust is still a very young language with an incompletely optimized compiler. There is still a lot of room left for improvements in compilation speed, code speed and size, wording of error messages and so on.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With