hn.today

Kcc, a C compiler built solo with an LLM on $100/month boot Linux kernel

github.com18 points22 comments
Screenshot of Kcc, a C compiler built solo with an LLM on $100/month boot Linux kernel

KCC is a formally specified C17 compiler implemented entirely in ARM64 assembly and expressed as a single literate program using weft. It parses and checks C against the Standard, performs optimisations and register allocation, emits native machine code, and is self-hosting - producing a byte-identical recompiled binary. KCC cross-compiles to x86-64 on Linux and macOS, builds nontrivial software such as Lua, SQLite, and DOOM, and is capable of booting a Linux kernel. The entire implementation and explanation is published as a roughly 1,000-page typeset book: the .weft literate sources are the sole source of truth, every assembly instruction is preceded by prose, generated build artifacts are never edited directly, and the committed kcc.pdf provides a readable snapshot of the current text.

The build and verification workflow is deterministic and reproducible: tangling the weft sources produces a generated tree (gen/) and Makefile, then make assembles gen/kcc and runs extensive test targets (difftest, diagtest, codegen/e2e/interop, self-host, meta-c and a full verification CI). make pdf weaves and typesets the book with LuaLaTeX; optional steps use rsvg-convert for covers, Docker and qemu-user for kernel reproduction. Prerequisites include weft ≥2.0, a C toolchain’s as/ld, and a TeX distribution. The project is MIT-licensed and authored by Cuauhtémoc Pacheco with an AI collaborator (Claude), advancing a literate-driven approach to verified compiler construction.

Read on github.com22 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in AI

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.