The Design of a Self-Compiling C Transpiler Targeting POSIX Shell
summary
A C-to-POSIX-shell transpiler called pnut is implemented in C and is self-applicable: it compiles itself to human-readable shell that runs on POSIX shells (bash 2.05b and others) and serves as a seed to bootstrap a full GCC toolchain from only a shell and source. Generated shell is about 35% larger than the C, compiling the pexe compiler from shell takes ~1 minute, pexe is ~5,000 LOC, and current limits include no floats, unsigned fields, function pointers, varargs or unions.
AI-written summary · about
chapters (17)
- 0:00Peanut C Transpiler intro
- 1:05Targeting POSIX shell for bootstrapping
- 3:14Compilation and shell benefits
- 5:22Bootstrapping workflow
- 7:29Challenges in C to shell
- 8:53Arithmetic and memory handling
- 11:23Function calls in shell
- 13:31Character I/O implementation
- 14:36Magic numbers and constants
- 16:23C subset and compiler features
- 17:49Performance and compatibility
- 18:29Conclusion and future work
- 19:06Q&A: Parallelism
- 20:12Q&A: Unsupported C features
- 20:56Q&A: Structs and unions
- 21:41Q&A: Error handling
- 22:02Q&A: Auditing automation
related talks
01h 02mProgram Manipulation of C Code
01h 03mApplied Best Practices
47mPrepping your Open Source Project for Multi-Platform
49mWriting better code with help from Qt and the compiler
24mThe Once and Future COBOL
01h 04mMaking C++ and the STL Work in the Linux / Windows Kernels
01h 02m“What to Expect from a Next-Generation C++ Build System”
01h 25mPeeking Into Your Compiler
