2
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?

Shepmaster
  • 326,504
  • 69
  • 892
  • 1,159
exebook
  • 29,722
  • 29
  • 120
  • 210

1 Answers1

9

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.

fjh
  • 10,640
  • 3
  • 40
  • 42