问题
Is there any small c compiler which follows ansi c extensions and still it has less than 10,000 LOC. Basically 'm trying to port such small compiler to one of such educational OS kernel known as xv6. Thanks.
回答1:
I don't think that's possible. You might try something like https://github.com/alexfru/SmallerC , a very small compiler for a subset of C. (See the wiki for the language)
Or look at pcc, but that is significantly larger.
回答2:
It turns out xv6 badly needs several improvements in order to host a decent C compiler or just an assembler and a linker:
- larger maximum file size (currently capped at around 64KB)
- lseek
- FPU state saving/restoring on context switches
A few other minor improvements may be needed.
Links:
- Increasing the filesystem block size in the xv6 OS
- system calls & toolchains
回答3:
The smallest one I know is TCC http://bellard.org/tcc/ which has around 30 000 LOC.
来源:https://stackoverflow.com/questions/20267092/small-c-compiler-for-educational-purpose