Hayroll: A Modular Wrapper for Translating C Macros and Conditional Compilation to Rust
Haoran Peng, Baris Kasikci, Gilbert Louis Bernstein, Michael D. Ernst
摘要
Previous C-to-Rust translators run the C preprocessor cpp on their input before translation. This discards configurability, and it loses programmer-defined abstractions expressed as C macros.
We present Hayroll, a modular wrapper that makes C-to-Rust translation preprocessor-aware without modifying the underlying translator. Hayroll consists of two cooperating layers. The conditional compilation translation layer uses symbolic execution to derive activation conditions for each line of the source code. It splits the program into a set of configuration-specific translation tasks that together cover every line of code. These tasks are then passed independently to the macro translation layer. The macro translation layer classifies macros, annotates macro-expanded nodes with tags, and sends the code through the underlying translator. It then reconstructs C macros as Rust functions or macros by retrieving these tags from the translator's output. Because the layers communicate only through task partitioning and source-code annotations, the underlying translator remains a black box; no invasive changes are required. Our implementation uses C2Rust, but the design is translator-agnostic.
We evaluated Hayroll on CRUST-Bench, LibmCS, and zlib. Hayroll successfully reconstructs most syntactical macros and avoids configuration explosion through symbolic execution. Hayroll's output passes the same tests as the underlying C-to-Rust transpiler. These results show that decoupled preprocessor analysis can restore configurability and abstraction to C-to-Rust translation in a practical and modular way.
问问这篇 Paper
智能体会读完全文。
Lune 把这篇 Paper 索引到了最后一个公式,引用它的顶会 Paper 也一样。你提问,回答直接引用原文。
它引用的顶会 Paper15
- Translating C to safer RustMehmet Emre, Ryan Schroeder, Kyle Dewey, Ben HardekopfOOPSLA 2021 · 被引用 60 次
- Ownership Guided C to Rust TranslationHanliang Zhang, Cristina David, Yijun Yu, Meng WangCAV 2023 · 被引用 37 次
- Aliasing Limits on Translating C to Safe RustMehmet Emre, Peter Boyland, Aesha Parekh, Ryan Schroeder 等OOPSLA 2023 · 被引用 32 次
- Concrat: An Automatic C-to-Rust Lock API Translator for Concurrent ProgramsJaemin Hong, Sukyoung RyuICSE 2023 · 被引用 17 次
- Don't Write, but Return: Replacing Output Parameters with Algebraic Data Types in C-to-Rust TranslationJaemin Hong, Sukyoung RyuPLDI 2024 · 被引用 17 次
相关 Paper
- &inator: Correct, Precise C-to-Rust Interface TranslationVictor Chen, Ayden Coughlin, Michael D. BondPLDI 2026 · 被引用 1 次
- Semantic Analysis of Macro Usage for PortabilityBrent Pappas, Paul GazzilloICSE 2024 · 被引用 2 次
- Scylla: Translating an Applicative Subset of C to Safe RustAymeric Fromherz, Jonathan ProtzenkoOOPSLA 2026 · 被引用 6 次
- SACTOR: LLM-Driven Correct and Idiomatic C to Rust Translation with Static Analysis and FFI-Based VerificationTianyang Zhou, Ziyi Zhang, Haowen Lin, Somesh Jha 等ACL 2026 · 被引用 8 次
- Cpp2Rust: Automatic Translation of C++ to Safe RustLucian Popescu, Francisco Gouveia, Henrique Preto, João Silveira 等PLDI 2026 · 被引用 1 次
