Skip to content

martinraison/tiny-hello-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tiny "Hello, world!" binary in Rust

This shows how to create a tiny "Hello, world!" binary in Rust. On my system (macOS), the resulting binary size is 8432 bytes, which is the same as when compiling the following C program with gcc -Os -o main main.c:

#include <stdio.h>

int main() {
  printf("Hello, World!\n");
}

The goal here is to stay as close as possible to the C "Hello, world!" program above. However it's possible to get even smaller binaries, as documented in this post.

Look into the official Rust documentation for additional information about creating Rust executables without the standard library.

Get started

$ cargo +nightly build --release
$ ./target/release/tiny-hello-rs
Hello, world!
$ wc -c ./target/release/tiny-hello-rs
    8432 ./target/release/tiny-hello-rs

About

Tiny "Hello, world!" binary in Rust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages