logo

Pcc – a C compiler in Python, powerful enough to compile Lua 5.5.0

Posted by jiamo |3 hours ago |3 comments

jiamo 3 hours ago

Pcc lets you run C programs like Python scripts: pcc test.c. It handles parsing (via pycparser), code generation, and LLVM JIT execution in Python, while leveraging the system C preprocessor (cc -E) and make -nB for Makefile-driven builds. It's complete enough to compile and run the entire Lua 5.5.0 interpreter (~30k lines of C), passing 30+ official test scripts with output identical to gcc-compiled Lua. It can also be used as a Python library to call C functions directly. Next goal: compiling other real-world C projects to make it more robust. (I will not tell what AI I am using. One AI can't solve all problems — different AIs have different debugging skills.