Tiny Binaries

December 31, 2021

Out of curiousity I experimented with building the smallest possible static x86-64 Linux binaries in several programming languages.

Each binary does the following:

  1. Print hi! and a newline to standard output.
  2. Return an exit code of 0.

I tested Assembly, C, Go, and Rust with various combinations of optimizations and build options.

Here’s a plot of the results (note: log scale X axis):

All Static Binary Sizes

All Static Binary Sizes

Here’s a plot of the smallest static binary sizes (<1k, linear scale X axis):

Tiny Static Binary Sizes (&lt;1k)

Tiny Static Binary Sizes (<1k)

Full Disclosure: asm-opt is the smallest legitimate result; asm-elf uses dirty tricks from Tiny ELF Files: Revisited in 2021.

Source code, build instructions, a CSV of results, and additional details are available in the companion GitHub repository.

Update (2022-01-01): See Tiny Binaries: Assembly Optimization for an explanation of the assembly results.