CC500: a tiny self-hosting C compiler
homepage.ntlworld.com
homepage.ntlworld.com
I am just interested in a small maintainable C compiler which can easily be adopted to bootstrap a new platform or cpu (on FPGA). I consider such a tiny C compiler just a convenient assembler to implement basic things on new platforms.
I know GCC and Clang/LLVM but those tool chains are really big, and I guess it requires a lot of work to support a new platform and to polish all things so that everything works properly.
A portable tiny GCC/LLVM replacement for small embedded systems would be really nice. GCC and Clang are great for powerful systems but I consider them overkill for small systems.
It is a full-blown C compiler with enough extensions to compile the Linux kernel (and boot to it directly - look at the "tccboot" project). But it's also small enough and simple enough to retarget in a few days work (make that a few month if you want optimizations ... but you don't seem to).
I realize it looks like C, but then so does anything with the words if, while, and braces. (It doesn't seem to have the word "for".) Since it says the compiler "does not even parse the types", that part seems like window-dressing and not part of the language.
I bet you could write the complete reference for the language this compiles in a paragraph.
How can we unambiguously distinguish between what qualifies for the classification of a "tiny" c-compiler versus just a "small" one?
We don't care about an unambiguous distinction.
So if your comparison is the completely unreadable otcc, then I'd say yes, this qualifies.
In contrast, GCC is nearing 10MLoC - 4 orders of magnitude difference - and its C parser alone is >10kLoC: https://github.com/gcc-mirror/gcc/blob/master/gcc/c/c-parser...