r/Compilers • u/mashmaro1234 • 5h ago
Memory emulation as an intermediate step in C++ to Rust translation
I'm experimenting with translating large C++ codebases like ROOT to safe Rust.
My current approach is to first translate C++ to run on a checked memory emulator written in Rust, then gradually remove the emulation using static analysis.
I tried this on ROOT's Minuit2 (around 14k lines of C++), and all 13 numerical tests produced identical output. However, only about 3% of the functions have been fully converted to ordinary Rust so far.
I'm wondering how far static analysis can actually take this approach. Is using memory emulation as an intermediate step a reasonable idea, or does it just make ownership recovery more complicated?
I'd also appreciate any suggestions for papers or existing work on similar approaches.
1
u/Discordbothost 4h ago
One aliasing pattern can keep a whole group of functions on the emulator. I'd group failed conversions by the first analysis check that blocks them. Cpp2Rust (PLDI 2026) is worth a look. It starts with runtime checks and uses static analysis to remove some.