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

Canonical is funding research into automated C-to-Rust translation, with AppArmor and snap-confine serving as real-world case studies.

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.

Finally, just to add that the initiative also fits into Canonical’s broader adoption of Rust within Ubuntu. The company points to projects such as uutils coreutils and sudo-rs as examples of Rust implementations that have earned a place in the distribution.

For additional details, see the post on Ubuntu’s Discourse channels.

Bobby Borisov

Bobby Borisov

Bobby, an editor-in-chief at Linuxiac, is a Linux professional with over 20 years of experience. With a strong focus on Linux and open-source software, he has worked as a Senior Linux System Administrator, Software Developer, and DevOps Engineer for small and large multinational companies.

Leave a Reply

Your email address will not be published. Required fields are marked *