Canonical announced a collaborative project with the University of Bristol to develop tools for automatically translating C code to Rust. The project is focused on translating large C code repositories into a safe and easily maintainable representation in Rust. Canonical will fund the researchers’ work on the project for 3 years, with a specific focus on translating the AppArmor and snap-confine packages to test the method on real system components.
The toolkit will utilize a hybrid model combining machine learning-based technologies with traditional analysis, testing, and formal verification methods. It will divide large codebases into fragments that are independently translated without losing the necessary context for types, dependencies, and behavior. The AI toolkit will be trained on existing projects that have been successfully translated from C to Rust to ensure correct Rust abstractions in the resulting code.
Additionally, the project will provide tools for checking the translated code, including fuzzing testing, formal verification elements, debugging, and analysis tools for identifying and solving verification issues. This research project aims to develop new methods for handling undefined behavior in C code, pointers, and competing locks, moving away from the labor-intensive manual rewriting process from C to Rust.
The development of this project is motivated by the inefficiencies and limitations of manual rewriting, traditional translators creating unsafe Rust code, and the scalability challenges of AI models for large code repositories. The project seeks to overcome these barriers and establish a reliable and efficient automated translation process from C to Rust.