About rui314/9cc
9cc is a small C compiler written by Rui Ueyama, the successor to 8cc. The project prioritizes code simplicity and understandability, using a hand-written recursive descent parser, plain tools like Make and shell, and a brute-force approach to keep the codebase straightforward. It compiles C source code through multiple stages: parsing to abstract syntax trees, semantic analysis with type checking, conversion to an intermediate representation (IR) with an infinite number of registers, register allocation to map to finite registers, and final generation of x86-64 assembly. The compiler uses a no-memory-management policy (malloc without free) to simplify code and eliminate use-after-free bugs. Note: 9cc is no longer actively maintained; its successor is chibicc.
Key Features
Pros & Cons
- Code is designed to be extremely easy to understand
- Generates reasonably efficient x86-64 assembly
- No memory management complexity eliminates use-after-free bugs
- Hand-written parser avoids blackbox tools like lex/yacc
- Uses simple, widely-known build tools (Make, shell)
- MIT license allows free use and modification
- No longer actively maintained; successor (chibicc) recommended
- Still in early stage, may not support full C standard
- Only targets x86-64 architecture
- No memory deallocation can lead to high memory usage for large inputs
- No official releases or version tags