Size of hello world executable is three times bigger in ubuntu than in windows


#1

Hi all,

I am playing around with rust 1.15.1.
I have a c9 instance with ubuntu trusty.
I took the code from http://rustbyexample.com/hello.html
I ran rustc -O hello.rs

and got a hello executable of 3.4 Mb.

Is this normal?

In windows i got one with 1 Mb

Thanks


#2

There is a deep rathole that you can go down regarding binary sizes of rustc-compiled files, so I will give you a short version

oh…and the deep end is http://mainisusuallyafunction.blogspot.com/2015/01/151-byte-static-linux-binary-in-rust.html


#3

cool :slight_smile:


#4

This sounds like something that may have been fixed by https://github.com/rust-lang/rust/pull/38117 - you might want to try building with a nightly compiler on Linux and see how things look there.


#5

For your Windows version, were you using the pc-windows-gnu toolchain? If you used pc-windows-msvc your hello world binary would be only 108KiB.