TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Chibicc: A Small C Compiler

278 pointsby marcobambiniover 4 years ago

19 comments

carapaceover 4 years ago
Awesome project!<p>&gt; When I find a bug in this compiler, I go back to the original commit that introduced the bug and rewrite the commit history as if there were no such bug from the beginning. This is an unusual way of fixing bugs, but as a a part of a book, it is important to keep every commit bug-free.<p>Ooo la la! &quot;Chibicc Vol. II, The Bugs&quot; !?<p>In all seriousness, a book about the bugs would be (IMO) even more fun to read than the compiler book.
评论 #24688345 未加载
评论 #24684824 未加载
rui314over 4 years ago
Related discussions on Reddit:<p><a href="https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;programming&#x2F;comments&#x2F;j35w0i&#x2F;im_writing_a_c_compiler_called_chibicc_and_a_book&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;programming&#x2F;comments&#x2F;j35w0i&#x2F;im_writ...</a><p><a href="https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;C_Programming&#x2F;comments&#x2F;j2wjyp&#x2F;chibicc_a_small_c_compiler&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;C_Programming&#x2F;comments&#x2F;j2wjyp&#x2F;chibi...</a><p><a href="https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;Compilers&#x2F;comments&#x2F;j2py9x&#x2F;im_writing_a_c_compiler_called_chibicc_and_a_book&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;Compilers&#x2F;comments&#x2F;j2py9x&#x2F;im_writin...</a>
gilmiover 4 years ago
I love &#x27;the incremental approach to compiler construction&#x27;. Here are a few other courses that use this approach to teach compiler construction:<p>* <a href="http:&#x2F;&#x2F;www.ccs.neu.edu&#x2F;course&#x2F;cs4410&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.ccs.neu.edu&#x2F;course&#x2F;cs4410&#x2F;</a><p>* <a href="https:&#x2F;&#x2F;ucsd-cse131-f19.github.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;ucsd-cse131-f19.github.io&#x2F;</a><p>* <a href="https:&#x2F;&#x2F;jeapostrophe.github.io&#x2F;courses&#x2F;2017&#x2F;spring&#x2F;406&#x2F;notes&#x2F;book.pdf" rel="nofollow">https:&#x2F;&#x2F;jeapostrophe.github.io&#x2F;courses&#x2F;2017&#x2F;spring&#x2F;406&#x2F;notes...</a>
saagarjhaover 4 years ago
Another small C compiler by the same author: <a href="https:&#x2F;&#x2F;github.com&#x2F;rui314&#x2F;8cc" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;rui314&#x2F;8cc</a>
评论 #24681971 未加载
dibyenduover 4 years ago
For a different optimizing C compiler that is also small, and usable as a JIT see MIR project by Vladimir Makarov - <a href="https:&#x2F;&#x2F;github.com&#x2F;vnmakarov&#x2F;mir&#x2F;tree&#x2F;master&#x2F;c2mir" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;vnmakarov&#x2F;mir&#x2F;tree&#x2F;master&#x2F;c2mir</a>
stirayover 4 years ago
<a href="https:&#x2F;&#x2F;bellard.org&#x2F;tcc&#x2F;" rel="nofollow">https:&#x2F;&#x2F;bellard.org&#x2F;tcc&#x2F;</a><p>Probably best know and with loooong beard...
评论 #24679228 未加载
评论 #24678967 未加载
philips4350over 4 years ago
Oh man I used to be a die hard fan of the author&#x27;s &#x27;turing complete fm[1]&#x27; podcast. It seems like he has stopped publishing new episodes, wonder what happened.<p>[1] <a href="https:&#x2F;&#x2F;turingcomplete.fm&#x2F;" rel="nofollow">https:&#x2F;&#x2F;turingcomplete.fm&#x2F;</a>
评论 #24684220 未加载
评论 #24679860 未加载
评论 #24680390 未加载
sdfjklover 4 years ago
I quite like the learn-by-commit style. Look at a diff and see what changes it took to add a feature. Very good way of showing things in a format everyone is already familiar with.
niek_pasover 4 years ago
Where will we be able to buy a copy? Is there a mailing list? I will certainly forget about this book in n months time.
评论 #24678282 未加载
评论 #24678139 未加载
jartover 4 years ago
Outstanding. A professional C compiler with a hackable codebase that emits x86_64 code. I&#x27;m noticing it assumes glibc-based linux. What if I modified it to emit Actually Portable Executables without needing ld&#x2F;as?
评论 #24680504 未加载
forgotmypw77over 4 years ago
&gt;Each commit of this project corresponds to a section of the book. For this purpose, not only the final state of the project but each commit was carefully written with readability in mind. Readers should be able to learn how a C language feature can be implemented just by reading one or a few commits of this project. For example, this is how while, [], ?:, and thread-local variable are implemented. If you have plenty of spare time, it might be fun to read it from the first commit.<p>nice
DethNinjaover 4 years ago
This looks great, I’ll definitely use it.<p>Is there any similar project like this where LLVM IR is used? I’ll start building a language just for fun during weekends and I plan to use LLVM but it is rather hard to understand clang on limited time, so a smaller scale project would be awesome.
评论 #24679357 未加载
评论 #24680615 未加载
评论 #24679984 未加载
garrypettetover 4 years ago
What a great resource. I will certainly pick up the book when it’s out.
emmanueloga_over 4 years ago
maybe the author can verify, from what I could see it generates assembler files that one should save to a .S file and then can be run with gcc&#x27;s `cc -o executable file.S`.
评论 #24684259 未加载
tarrudaover 4 years ago
Looking forward to the release, and will definitely get a copy!
pfdietzover 4 years ago
I wonder how it does with Csmith.
ruslanover 4 years ago
Can it compile itself ?
评论 #24679664 未加载
barumiover 4 years ago
It would be helpful if the title was edited to feature the compiler&#x27;s name: chibicc. It would make it easier to search and SEO-wise it would be helpful to disseminate the project.
评论 #24678460 未加载
评论 #24684126 未加载
IncRndover 4 years ago
<i>When I find a bug in this compiler, I go back to the original commit that introduced the bug and rewrite the commit history as if there were no such bug from the beginning. This is an unusual way of fixing bugs, but as a a part of a book, it is important to keep every commit bug-free.</i><p>Somehow I can&#x27;t imagine Brian Kernighan or Dennis Ritchie making those sorts of commits.
评论 #24678763 未加载