small c compiler for educational purpose [closed]

↘锁芯ラ 提交于 2019-12-24 03:02:22

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!