rui314/chibicc logo

rui314/chibicc

Free

A small C compiler

FreeFree tier
Type
Open Source

About rui314/chibicc

chibicc is a small C compiler that implements most C11 features, including preprocessor, floating-point types (float, double, long double using x87 80-bit), bit-fields, alloca, variable-length arrays, compound literals, thread-local variables, atomic variables, common symbols, designated initializers, wide string literals (L, u, U, u8), and functions passing/returning structs by value per x86-64 SystemV ABI. It is capable of compiling real-world programs such as Git, SQLite, libpng, and itself without modifications, and the generated executables pass their respective test suites. The compiler is developed as a reference implementation for an upcoming book on C compiler and low-level programming, with each commit corresponding to a section in the book, enabling incremental learning. chibicc is licensed under an open-source permissive license and is available on GitHub.

Key Features

Implements most mandatory and optional C11 features
Compiles real-world programs (Git, SQLite, libpng, itself) without modification
Passes test suites of compiled programs
Readable commit history designed for incremental learning of compiler construction
Supports preprocessor, float/double/long double, bit-fields, alloca, variable-length arrays, compound literals, thread-local variables, atomic variables, common symbols, designated initializers, L/u/U/u8 string literals, struct by value (x86-64 ABI)
Permissive open-source license

Pros & Cons

Pros
  • Small codebase with readable commits for educational purposes
  • Supports a wide range of C11 features often missing in toy compilers
  • Can compile real-world, complex C programs like Git and SQLite
  • Actively maintained as part of a book project with clear documentation
  • Free and open source under a permissive license
Cons
  • Does not support complex numbers, K&R-style function prototypes, or GCC inline assembly
  • Digraphs and trigraphs are intentionally not supported
  • Targets only x86-64 Linux (limited platform portability)
  • Still considered a 'toy compiler' compared to GCC or Clang for large-scale production use

Best For

Learning how a C compiler is built, with incremental commitsCompiling small to medium C projects that adhere to C11Reference implementation for a book on low-level programming and compiler designEmbedded or educational environments requiring a lightweight C compiler

FAQ

What does 'chibicc' stand for?
It is pronounced 'chee bee cee cee' – 'chibi' means 'mini' or 'small' in Japanese, and 'cc' stands for C compiler.
Can chibicc compile large real-world programs?
Yes, it can compile programs like Git, SQLite, libpng, and itself without modifications, and the generated executables pass their test suites.
What is the purpose of chibicc?
It is the reference implementation for a book on C compiler and low-level programming, with each commit corresponding to a section in the book to teach incremental compiler construction.
Does chibicc support all C11 features?
It implements almost all mandatory features and most optional features, but does not support complex numbers, K&R-style function prototypes, GCC inline assembly, digraphs, or trigraphs.