Skip to content
Tech News
← Back to articles

Canonical Backs New Project to Translate Large C Codebases into Safe Rust

read original more articles
Why This Matters

This initiative is significant because it aims to automate the complex process of migrating large, mature C codebases to Rust, enhancing software safety, reliability, and maintainability across the industry. By leveraging advanced translation techniques, it could reduce costs and risks associated with manual rewrites, accelerating the adoption of safer programming practices in critical software systems.

Key Takeaways

Canonical is supporting a new three-year research project to make it practical to automatically move large, mature software projects from C to Rust. The project is a partnership between Canonical and the University of Bristol in the UK, and the work is set to start later in 2026.

The main goal is to build a complete platform that can translate large code repositories, sometimes with hundreds of thousands of lines of C, into safe, reliable, and maintainable Rust.

However, the bigger challenge is the huge amount of mature C software already in use. Manually rewriting these projects is costly and risky, since their code often includes years of fixes, compatibility updates, performance tweaks, and hidden knowledge.

Current source-to-source translators only address part of the problem. Canonical says these tools can handle a lot of code, but they often copy C structures too closely. This leads to Rust code that still relies on unsafe features, keeps C-style patterns, and needs a lot of cleanup before Rust developers would want to maintain it.

LLMs face a different challenge. They can often create good, idiomatic Rust for small, clear pieces of code, but managing the context of a whole repository is much harder. Also, code that looks right may not always work the same way as the original C version.

To address these challenges, the new project will use a hybrid, or ‘neurosymbolic,’ approach. This combines machine learning with traditional program analysis, testing, and formal methods.

According to Canonical, large code repositories will first be split into smaller parts that can be translated separately while preserving key details about types, dependencies, and how the program works.

The translation will use language models trained on known C-to-Rust examples, aiming to produce Rust code that uses proper Rust features instead of just copying C syntax. After translation, the new code will be checked to see if it behaves like the original C version.

For Ubuntu users, it’s important to note that the research will go beyond small academic examples. Canonical plans to use AppArmor and snap-confine as real-world case studies.

However, Canonical makes it clear that AppArmor and snap-confine are not being rewritten in Rust right now. These projects are only being used as case studies to test the technology, and there is no plan to replace their current versions with the research results.

... continue reading