aboutsummaryrefslogtreecommitdiff
path: root/content/posts/2021-12-31-tiny-binaries.md
diff options
context:
space:
mode:
Diffstat (limited to 'content/posts/2021-12-31-tiny-binaries.md')
-rw-r--r--content/posts/2021-12-31-tiny-binaries.md62
1 files changed, 62 insertions, 0 deletions
diff --git a/content/posts/2021-12-31-tiny-binaries.md b/content/posts/2021-12-31-tiny-binaries.md
new file mode 100644
index 0000000..415a2c1
--- /dev/null
+++ b/content/posts/2021-12-31-tiny-binaries.md
@@ -0,0 +1,62 @@
+---
+slug: tiny-binaries
+title: "Tiny Binaries"
+date: "2021-12-31T09:28:32-04:00"
+---
+Recently I experimented with building the smallest possible static
+[x86-64][] [Linux][] binaries in a variety of programming languages.
+
+Each binary does the following:
+
+1. Print `hi!` and a newline to [standard output][stdout].
+2. Return an exit code of `0`.
+
+I tested [Assembly][], [C][], [Go][], and [Rust][] with a variety of
+optimizations and build options.
+
+Here's a plot of the results (**note:** [log scale][] X axis):
+
+{{< figure
+ src="/files/posts/tiny-binaries/sizes-all.svg"
+ class=image
+ caption="All Static Binary Sizes"
+>}}
+
+Here's a plot of the smallest static binary sizes (<1k, linear scale X
+axis):
+
+{{< figure
+ src="/files/posts/tiny-binaries/sizes-tiny.svg"
+ class=image
+ caption="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][tiny-elf].
+
+Source code, build instructions, a [CSV][] of results, and additional
+details are available in the [companion GitHub repository][repo].
+
+[x86-64]: https://en.wikipedia.org/wiki/X86-64
+ "64-bit version of x86 instruction set"
+[linux]: https://en.wikipedia.org/wiki/Linux
+ "Linux operating system"
+[assembly]: https://en.wikipedia.org/wiki/Assembly_language
+ "Assembly language"
+[c]: https://en.wikipedia.org/wiki/C_(programming_language)
+ "C programming language"
+[go]: https://golang.org/
+ "Go programming language"
+[rust]: https://www.rust-lang.org/
+ "Rust programming language"
+[log scale]: https://en.wikipedia.org/wiki/Logarithmic_scale
+ "Logarithmic scale"
+[repo]: https://github.com/pablotron/tiny-binaries
+ "Tiny Binaries GitHub repository"
+[tiny-elf]: https://nathanotterness.com/2021/10/tiny_elf_modernized.html
+ "Tiny ELF Files: Revisited in 2021"
+[stdout]: https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)
+ "Standard output."
+[csv]: https://en.wikipedia.org/wiki/Comma-separated_values
+ "Comma-Separated Values"