The C2Rust project is being developed by Galois and Immunant. This tool is able to translate most C modules into semantically equivalent Rust code. These modules are intended to be compiled in isolation in order to produce compatible object files. We are developing several tools that help transform the initial Rust sources into idiomatic Rust.
The translator focuses on supporting the C99 standard. C source code is parsed and typechecked using clang before being translated by our tool.
This project is available under the BSD-3 license.
Source code and instructions are available in our git repository.
The C2Rust manual is available online and is our comprehensive documentation for using and developing C2Rust.
More information about installing c2rust from crates.io is availble in this introductory blog post:
Per Larsen recently presented a talk on C2Rust at RustConf detailing both our approach to translation as well as our cross-checking approach to testing the resulting translations.
RustConf 2018 - C2Rust: Migrating Legacy Code to Rust
Eric Mertens wrote a blog post describing some of the challenges we encountered during translation of C to Rust and how C2Rust tackles them.
- Host environment
- The translator is running on Ubuntu 16.04.4 LTS with x86_64 architecture. With this approach to translation details of the host system's libraries can be embedded in the translation. The generated C code might not link correctly on other platforms.
- Rust environment
- The generated code is currently targeting:
- Why isn't my type definition translated?
- Types that aren't used to generate code are pruned away. Try using your type in a function declaration.
- Why isn't printf available?
- You'll need to include headers to use functions from external libraries.
- Why was my function omitted?
- When the translator can't handle a translating a function for some reason it omits the implementation and prints the reason. This is configurable and visible when you're running the tool locally. Currently this web interface doesn't show warning messages generated during translation.
- What are the known limitations?
- We've captured many of the features we don't support on the Known Limitations of Translation wiki page.
To report issues with the translation, please use our Issue Tracker.
The development team can be reached by email at email@example.com.