This question already has an answer here:
- Why are Rust executables so huge? 5 answers
fn main() {
println!("hello");
}
This program compiles 600 ms and the resulting binary is 600KB in size. Why is that? I am just trying Rust, and comparing it to C. C would compile similar program 10 times faster and the binary output will be 100 times smaller. So why is that?
The executable size is mostly because rust's standard library is statically linked in by default. Try compiling with
rustc -O -C prefer-dynamic
and you should get a binary that's comparable to the C version.