4 ms·
Just to continue the catalogue: pcc is simple, but very old school and a bit contorted. libfirm is small and clean and generates excellent code. (Despite the
by david-given 11y ago
Just to continue the catalogue:
pcc is simple, but very old school and a bit contorted.
libfirm is small and clean and generates excellent code. (Despite the name, it's a complete ANSI C compiler, as well as being a LLVM-light.)
The ACK is easy to port and is a complete standalone toolchain including compilers, assemblers and linkers, but (at least on modern processors) produces code so bad that it will make you want to stab yourself in the eyes to make the pain go away.
There's a look-but-don't-touch licensed compiler called vbcc which is by far the best C compiler I've ever seen; small, easy to understand, easy to port, and produces excellent code... but the author doesn't want to release it under an open source license.
Any others?
- andrewchambers 11y agolibfirm doesn't really classify as small to me, it is currently 132,638 lines of code. The cparser alone is 11k lines of code (5 times the size of my c parser).
- david-given 11y agoThat's true. I was rather thinking of it in comparison to LLVM and gcc, which are both space-distorting behemoths. (The catchphrase I've seen is that you can compile libfirm in less time than it takes to run the gcc configure script!)
- nwmcsween 11y agoDoes your cparser cover the entire c spec?
- andrewchambers 11y agoNot currently, but it covers probably more than 80 percent. Part of the problem is support gcc extensions which take some more work.
- userbinator 11y agoThe GCC extensions are just that - they're not part of the standard. You can claim 100% standards conformance without implementing a single one of them. That said, in practice a large amount of C code out there is not pure standard C so if you want to be able to compile something "interesting" like e.g. a Linux kernel you'll need to implement some.
- david-given 11y agoOh, here's a couple more I forgot about: nwcc: small, slightly unfinished, looks like it's stalled. sparse: technically this isn't a compiler, it's a code linter --- but it contains a complete ANSI C front end and a reasonable amount of a backend and can be made to generate code without much effort. I've used it to compile C to Java and Perl. There's no optimisation layer and it's a little buggy (it's not really really intended as a compiler).