Automating C to Rust Porting with LLMs: A Surprisingly Effective Strategy
This post details the author's experience automating the porting of C code to Rust using large language models (LLMs). After experimenting with several approaches, a strategy based on topological ordering and fuzz testing proved highly effective. Symbols in the C code were topologically sorted, then the LLM generated Rust versions of each symbol along with fuzz tests. Output comparison verified correctness. This successfully ported the Zopfli compression library from C to Rust with identical results. While not fully automated, this dramatically reduced cost and effort, offering a new approach to large codebase maintenance and upgrades.
Read more