[Media] Bringing Rust to the 70s: I wrote a full LLVM backend for the Zilog Z80.

317 points zlfn 13 comments
[Media] Bringing Rust to the 70s: I wrote a full LLVM backend for the Zilog Z80.

Two years ago, I started a project called Rust-GB to compile Rust for the Game Boy. At the time, there was no stable LLVM backend that supported the Game Boy’s CPU. I had to use a complex workaround: transpiling Rust to C via LLVM-CBE, and then compiling that C code using SDCC. Back then, I dreamed of building a native LLVM backend, but I simply didn't have the time.

Fast forward two years, and things have changed. With the help of LLMs, I have successfully implemented a complete LLVM-Z80 backend (which includes subtarget support for the Game Boy's SM83). Even the performance is generally better than SDCC, though it results in a larger binary size.

I’m happy to report that I’ve successfully built the entire Rust core and alloc libraries for both the Z80 and SM83! :)

(If you find this project interesting, I'd appreciate a star on the repo lol)