Cpp2Rust: Automatic Translation of C++ to Safe Rust
summary
Cpp2Rust automatically translates arbitrary C++ into memory-safe Rust by representing locals as Rc<RefCell<T>>-backed values and pointers as weak PTR handles that perform runtime ownership and mutability checks; it then runs source-to-source passes that eliminate RC/RefCell/Option eliminations when safe. The open-source tool translates 13k LOC (WOFF2 and Brunsli) instantaneously and without adding bugs, and after optimizations achieves 2% compression slowdown on WOFF2 and ~6× slowdown on Brunsli versus C++.
AI-written summary · about
chapters (12)
- 0:00Cpp2Rust project
- 1:05Switching from C++ to Rust
- 2:50C to Rust translation limits
- 3:53Cpp2Rust: value and PTR types
- 5:59Performance versus safety
- 7:06Mechanical translation
- 8:49Source-to-source optimizations
- 10:36Benchmarking translated apps
- 13:47WOFF2 performance results
- 14:29Brotli performance results
- 15:31Summary and future work
- 15:55Q&A
related talks
28mC2Rust: Migrating Legacy Code to Rust
15mTranslating C to Safer Rust
41mC++ Migration Strategies
06mHow We Replace Common C and C++ Libraries
53mC++/Rust Interop: A Practical Guide to Bridging the Gap Between C++ and Rust
25mRust and C++
01h 29mA Friendly Introduction to Rust for C++ Developers
18mAliasing Limits on Translating C to Safe Rust
