Skip to content

Instantly share code, notes, and snippets.

@rhizoome
Created August 5, 2018 18:10
Show Gist options
  • Save rhizoome/76348c6b2362759a4f68a4f6ecd1e916 to your computer and use it in GitHub Desktop.
Save rhizoome/76348c6b2362759a4f68a4f6ecd1e916 to your computer and use it in GitHub Desktop.
Smallest rust binary size in stable (using musl based OS)
$> rustc -C opt-level=2 -C lto=fat hello.rs; strip hello; ls -lh hello
-rwxr-xr-x 1 ganwell ganwell 150.2K Aug 5 20:08 hello
fn main() {
println!("Hello World!");
}
@rhizoome
Copy link
Author

rhizoome commented Aug 5, 2018

Use x86_64-unknown-linux-musl on gnu system

@rhizoome
Copy link
Author

rhizoome commented Aug 5, 2018

In nightly use -C opt-level=z and

#![feature(alloc_system)]
extern crate alloc_system;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment