Awesome project!<p>> 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! "Chibicc Vol. II, The Bugs" !?<p>In all seriousness, a book about the bugs would be (IMO) even more fun to read than the compiler book.
Related discussions on Reddit:<p><a href="https://www.reddit.com/r/programming/comments/j35w0i/im_writing_a_c_compiler_called_chibicc_and_a_book/" rel="nofollow">https://www.reddit.com/r/programming/comments/j35w0i/im_writ...</a><p><a href="https://www.reddit.com/r/C_Programming/comments/j2wjyp/chibicc_a_small_c_compiler/" rel="nofollow">https://www.reddit.com/r/C_Programming/comments/j2wjyp/chibi...</a><p><a href="https://www.reddit.com/r/Compilers/comments/j2py9x/im_writing_a_c_compiler_called_chibicc_and_a_book/" rel="nofollow">https://www.reddit.com/r/Compilers/comments/j2py9x/im_writin...</a>
I love 'the incremental approach to compiler construction'. Here are a few other courses that use this approach to teach compiler construction:<p>* <a href="http://www.ccs.neu.edu/course/cs4410/" rel="nofollow">http://www.ccs.neu.edu/course/cs4410/</a><p>* <a href="https://ucsd-cse131-f19.github.io/" rel="nofollow">https://ucsd-cse131-f19.github.io/</a><p>* <a href="https://jeapostrophe.github.io/courses/2017/spring/406/notes/book.pdf" rel="nofollow">https://jeapostrophe.github.io/courses/2017/spring/406/notes...</a>
Another small C compiler by the same author: <a href="https://github.com/rui314/8cc" rel="nofollow">https://github.com/rui314/8cc</a>
For a different optimizing C compiler that is also small, and usable as a JIT see MIR project by Vladimir Makarov - <a href="https://github.com/vnmakarov/mir/tree/master/c2mir" rel="nofollow">https://github.com/vnmakarov/mir/tree/master/c2mir</a>
<a href="https://bellard.org/tcc/" rel="nofollow">https://bellard.org/tcc/</a><p>Probably best know and with loooong beard...
Oh man I used to be a die hard fan of the author's 'turing complete fm[1]' podcast. It seems like he has stopped publishing new episodes, wonder what happened.<p>[1] <a href="https://turingcomplete.fm/" rel="nofollow">https://turingcomplete.fm/</a>
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.
Outstanding. A professional C compiler with a hackable codebase that emits x86_64 code. I'm noticing it assumes glibc-based linux. What if I modified it to emit Actually Portable Executables without needing ld/as?
>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
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.
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's `cc -o executable file.S`.
It would be helpful if the title was edited to feature the compiler's name: chibicc. It would make it easier to search and SEO-wise it would be helpful to disseminate the project.
<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't imagine Brian Kernighan or Dennis Ritchie making those sorts of commits.