Samenvatting
Recent years have seen a clear transition from memory-unsafe languages such as C toward memory-safe alternatives like Rust. Automated translation from C to Rust offers a promising way to facilitate this transition, yet existing tools exhibit significant limitations. In particular, current C-to-Rust translators often disregard the readability of the original source code, which is undesirable when producing code intended for long-term maintenance.Preserving readability is challenging, primarily due to the complexity introduced by the C preprocessor. The preprocessor constitutes the first stage of compilation and must be invoked before the C code can be parsed. Consequently, translators typically preprocess the source code prior to translation, which causes a significant loss of metaprogramming information: the macro system, conditional compilation directives, and header include statements are all encoded as preprocessor directives.
Since macros are widely used to define constants and generic functions, their expansion has the most detrimental effect on readability. This thesis presents novel techniques to preserve macros in order to better retain the meaning of the original source code and improve the readability of the translated code.
We introduce Oxidize, a new C-to-Rust translation framework built on modern compiler engineering practices. We implement our macro-translation techniques into Oxidize, enabling the translation of complex macros that previous translators could not handle.
We evaluate Oxidize using an extensive test suite and a comparison with the state-of-the-art C2Rust translator. Our results show that Oxidize achieves comparable translation performance while significantly improving macro retention. In real-world programs such as DOOM and FIGlet, Oxidize preserves on average 92\% of macros compared to only 30\% for C2Rust. These results demonstrate that Oxidize is the first framework capable of retaining complex macros during C-to-Rust translation, and thus represents a practical step toward more maintainable automated Rust code generation.
| Datum prijs | 2025 |
|---|---|
| Originele taal | English |
| Begeleider | Antonio Paolillo (Promotor), Jim Bauwens (Jury), Theo D'Hondt (Jury), Geraint Wiggins (Jury) & Jan Tobias Mühlberg (Jury) |
Citeer dit
- Standard