The Blink Team (short for Blinkenlights) is proud to announce its first milestone release, version 1.0. Blink is a brand-new unprivileged userspace virtual machine that can emulate x86-64-linux binaries on any POSIX platform. It’s basically a 220kb dependency-free static binary that implements about 600 x86 instructions and 180 Linux system calls, which makes Blink pretty good at running simple command line programs.
./configure # use `./configure --help | less` for help
make -j8 # build blink and blinkenlights
doas make install # doas is modern sudo
blink program # use `man blink` for help
Blink has a snappy JIT that in some cases goes 2x faster than Qemu for use-cases like ephemeral programs. That’s because Blink has a baseline JIT that generates code fast using a printf-style DSL. That means Blink has an approachable codebase since we’ve only got 63,500 lines of ANSI C11 code. Blink currently doesn’t even try to perform optimizations, which makes this project a total greenfield for algorithms. The only complicated things it does right now are (1) trapping segfaults to RWX memory fast, (2) managing a trie of semaphores for tracking memory pages, and (3) storing JIT hooks in a multithreaded lockless hashtable. Here’s a screenshot of Blink vs. Qemu running GCC’s CC1 command. You’ll notice that Blink is able to compile Hello World at least 2x faster.
While the blink
command is headless, Blink also has a TUI interface (called blinkenlights
) which lets you debug and visualize programs in real time. Here’s an example of it running a bare metal Game of Life demo, written in Rust, which boots from BIOS in i8086 mode, bootstraps to long mode, and then draws to Blinkenlight’s text-based CGA display.
man blinkenlights
blinkenlights -jmr third_party/gameoflife/gameoflife.bin
# Press CTRL-T several times for Turbo mode
Blinkenlights supports running the dynamically-linked binaries shipped by your Linux distro. Here’s a screenshot of Blink executing the ls
program on an actual Alpine Linux install. Alpine is such a great distro for Blink, since Musl Libc only uses the sane POSIX subset of Linux system calls that are easy for Blink to support.
blinkenlights ls # on alpine linux
The best feature offered by the Blinkenlights TUI is reverse debugging. All you need to do is scroll wheel over the assembly display. Blink also profiles your program functions in real time if you press the p
key. You can also control-wheel the memory panels to zoom out memory using a lanczos kernel.
reverse-debugging2.mp4
Blink works best for command line programs, although Blink has some support for emulating GUI applications too. Here’s a screenshot of Blink running the Emacs GUI on Debian Linux.
Unlike qemu-user (which only runs on Linux) Blink is able to run on other operating systems. Here’s what happens i