whatisgithub

What is chibicc?

rui314/chibicc — explained in plain English

Analysis updated 2026-06-24

11,617CAudience · developerComplexity · 4/5Setup · moderate

In one sentence

A teaching C compiler that handles most of C11, built commit by commit as the reference code for a book on compilers, starting from a single-number parser and growing to compile real programs like SQLite.

Mindmap

mindmap
  root((repo))
    What it does
      Compiles C11 source
      Teaching compiler
      Book companion code
    Four stages
      Tokenize source text
      Preprocess macros
      Parse to tree
      Generate assembly
    Capabilities
      Compiles SQLite and Git
      Floating-point support
      No optimization pass
    Audience
      CS students
      Compiler learners
      Systems programmers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Follow the book commit by commit to learn how tokenizing, preprocessing, parsing, and code generation work in a real compiler.

USE CASE 2

Read the source to understand how a C11 preprocessor expands macros and handles include directives.

USE CASE 3

Compile SQLite or libpng with chibicc to see how far a teaching compiler can handle real-world C code.

What is it built with?

C

How does it compare?

rui314/chibicctsl0922/ttydklipper3d/klipper
Stars11,61711,61211,529
LanguageCCC
Setup difficultymoderateeasyhard
Complexity4/52/54/5
Audiencedeveloperops devopsops devops

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 1h+

Requires a C compiler and build tools, the repo rewrites history when bugs are fixed so pull requests are not accepted.

No license information was mentioned in the explanation.

So what is it?

chibicc is a C compiler built primarily as a teaching tool. A compiler is a program that reads source code written in a programming language and converts it into instructions the computer can actually run. Most people who write software in C use professional compilers like GCC or Clang, this project builds a simpler one, step by step, to show how the process works. The compiler was written by a Japanese author as the reference implementation for a book about C compilers and low-level programming. The book is structured so that readers start by building a compiler that understands only a single number, then add one language feature at a time until the compiler handles the C11 standard. Each commit in this repository corresponds to one section of the book, and the author wrote every commit with first-time readers in mind. You can follow the entire learning path from the very first commit. Despite being called small, chibicc is more capable than most projects in that category. It can compile real programs including Git, SQLite, and libpng without modifying them, and the resulting programs pass their test suites. It supports most of the C11 standard, including a preprocessor, floating-point types, variable-length arrays, and thread-local variables. It does not include an optimization step, so the code it generates runs slower than what a production compiler would produce. The compiler processes code in four stages: tokenize (split the source text into pieces), preprocess (expand macros and handle directives), parse (build a tree structure representing the code's meaning), and code generation (produce assembly output). The source code is intentionally kept simple and avoids clever abstractions so that readers encountering compiler internals for the first time can understand it. The project does not accept pull requests in the conventional way. Because the repository also serves as the book's commit-by-commit narrative, the author rewrites history when bugs are found, keeping every commit clean and correct.

Copy-paste prompts

Prompt 1
I'm reading the chibicc book on the parsing chapter. Explain how the parse function builds an abstract syntax tree from tokens and what data structure is used for the tree nodes.
Prompt 2
Show me how chibicc handles variable-length arrays in its code generation phase, which source file handles this and what assembly output does it produce?
Prompt 3
I want to understand how chibicc's preprocessor expands a simple define macro. Walk me through the relevant source code step by step.
Prompt 4
Compare chibicc's code generation approach to GCC, what does chibicc deliberately leave out to keep the code readable for first-time compiler learners?

Frequently asked questions

What is chibicc?

A teaching C compiler that handles most of C11, built commit by commit as the reference code for a book on compilers, starting from a single-number parser and growing to compile real programs like SQLite.

What language is chibicc written in?

Mainly C. The stack also includes C.

What license does chibicc use?

No license information was mentioned in the explanation.

How hard is chibicc to set up?

Setup difficulty is rated moderate, with roughly 1h+ to a first successful run.

Who is chibicc for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.