Corrosive C - Compiling Rust to C to target new platforms
summary
Project compiles Rust MIR into C by replacing rustc’s backend and targets platforms that only have a C compiler, producing C that keeps local numbering and compiles Rust MIR to C back end. Generated C preserves debug info with line directives and uses workarounds for undefined behavior: replace signed ops with unsigned, add checks for shifts and float casts, and use memcpy for loads/stores to avoid strict aliasing. Tooling includes running rustc’s test suite (about 96% of core compiler tests pass), ~400–500 custom tests, and ~40k LOC of code while keeping symbol names via hashing.
AI-written summary · about
chapters (8)
- 0:00Introduction
- 3:12Compile Rust to C for platforms
- 8:52Rust compiler architecture
- 12:42Undefined behavior in C
- 25:45Translation challenges and solutions
- 30:00Testing generated C
- 33:53Project scope and future
- 37:27Q&A








