GitHub 火线榜

GitHub 火线榜 · 仓库档案

rui314/8cc

A Small C Compiler (简介来自仓库自身文档。)

C

数据截至 10月30日rui314

最好成绩

#313

总榜 · C 语言

6428

累计 Star

765

Fork 总数

0

近 30 天在榜天数

许可证: MIT最近 push: 5月2日Open Issues(含 PR): 46自 2026-10-25 起采集;未知 = 尚未采集到

项目文档

8cc C Compiler

Note: 8cc is no longer an active project. The successor is chibicc.

8cc is a compiler for the C programming language. It's intended to support all C11 language features while keeping the code as small and simple as possible.

The compiler is able to compile itself. You can see its code both as an implementation of the C language and as an example of what this compiler is able to compile.

8cc's source code is carefully written to be as concise and easy-to-read as possible, so that the source code becomes good study material to learn about various techniques used in compilers. You may find the lexer, the preprocessor and the parser are already useful to learn how C source code is processed at each stage.

It's not an optimizing compiler. Generated code is usually 2x or more slower than GCC. I plan to implement a reasonable level of optimization in the future.

8cc supports x86-64 Linux only. I have no plan to make it portable until I fix all known miscompilations and implement an optimization pass. As of 2015, I'm using Ubuntu 14 as my development platform. It should work on other x86-64 Linux distributions though.

Note: Do not have high expectations on this compiler. If you try to compile a program other than the compiler itself, there's a good chance to see compile errors or miscompilations. This is basically a one-man project, and I have spent only a few months of my spare time so far.

Build

Run make to build:

make

8cc comes with unit tests. To run the tests, give "test" as an argument:

make test

The following target builds 8cc three times to verify that stage1 compiler can build stage2, and stage2 can build stage3. It then compares stage2 and stage3 binaries byte-by-byte to verify that we reach a fixed point.

make fulltest

Author

Rui Ueyama rui314@gmail.com

Links for C compiler development

Besides popular books about compiler, such as the Dragon Book, I found the following books/documents are very useful to develop a C compiler. Note that the standard draft versions are very close to the ratified versions. You can practically use them as the standard documents.

当前上榜

  • 313

    总榜 · 史上最强 · C

    6428 星 · 765 fork · 累计 Star

    总榜 · C →

近 30 天势头

近 30 天没有上榜记录。

同一作者的其它上榜项目

把上榜徽章放进你的 README · rui314/8cc[![把上榜徽章放进你的 README](https://git.vaiox.xyz/api/badge/rui314/8cc.svg)](https://git.vaiox.xyz/zh/repo/rui314/8cc)

Badge · 任何仓库都可以挂 —— 未上榜的仓库显示灰章,上完榜会自动点亮。

<a href="https://git.vaiox.xyz/zh/repo/rui314/8cc"><img src="https://git.vaiox.xyz/api/badge/rui314/8cc.svg" alt="把上榜徽章放进你的 README" height="20"></a>

← 回到榜单

GitHub 火线榜往日榜发现联系我们 · Contact