Skip to content

Instantly share code, notes, and snippets.

@seven1m
Last active June 15, 2018 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seven1m/830b5067a8784f9f570152063de03f52 to your computer and use it in GitHub Desktop.
Save seven1m/830b5067a8784f9f570152063de03f52 to your computer and use it in GitHub Desktop.
I was interested to see static binary size difference between Crystal and Rust.
➜ ~/Desktop cat hello_crystal.cr
puts "hello world"
➜ ~/Desktop cat hello_rust.rs
fn main() {
println!("hello world");
}
➜ ~/Desktop crystal --version
Crystal 0.25.0 [7fb783f7a] (2018-06-11)
LLVM: 4.0.0
Default target: x86_64-unknown-linux-gnu
➜ ~/Desktop rustc --version
rustc 1.25.0 (84203cac6 2018-03-25)
➜ ~/Desktop crystal build hello_crystal.cr --release --static
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libevent.a(evutil.o): In function `test_for_getaddrinfo_hacks':
(.text+0x300): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libevent.a(evutil.o): In function `evutil_getaddrinfo_common_':
(.text+0x1b3b): warning: Using 'getprotobynumber' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
(.text+0x1c04): warning: Using 'getservbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
➜ ~/Desktop rustc -O hello_rust.rs
➜ ~/Desktop ls -lh
-rwxr-xr-x 1 tim tim 2.4M Jun 15 11:44 hello_crystal
-rw-r--r-- 1 tim tim 19 Jun 15 11:34 hello_crystal.cr
-rwxr-xr-x 1 tim tim 4.5M Jun 15 11:44 hello_rust
-rw-r--r-- 1 tim tim 43 Jun 15 11:36 hello_rust.rs
➜ ~/Desktop strip hello_crystal hello_rust
➜ ~/Desktop ls -lh
-rwxr-xr-x 1 tim tim 1.4M Jun 15 11:45 hello_crystal
-rw-r--r-- 1 tim tim 19 Jun 15 11:34 hello_crystal.cr
-rwxr-xr-x 1 tim tim 443K Jun 15 11:45 hello_rust
-rw-r--r-- 1 tim tim 43 Jun 15 11:36 hello_rust.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment