Lune

PLDI2026顶会

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.

问 Lune

几分钟读透这篇 Paper,不用再花一下午。

Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。

可以从这些问题问起

Lune 可以查阅

全文 · 相关的 Paper

获取答案

免费开始,无需绑卡

脉络

  • Ownership Guided C to Rust Translation 引用了 Translating C to safer Rust
  • Aliasing Limits on Translating C to Safe Rust 引用了 Translating C to safer Rust
  • Concrat: An Automatic C-to-Rust Lock API Translator for Concurrent Programs 引用了 Translating C to safer Rust
它引用的引用它的从左到右按年份排列,引用越多,位置越高。

它引用的 Paper16

  1. Translating C to safer RustMehmet Emre, Ryan Schroeder, Kyle Dewey, Ben HardekopfOOPSLA 2021 · 60 次引用
  2. Ownership Guided C to Rust TranslationHanliang Zhang, Cristina David, Yijun Yu, Meng WangCAV 2023 · 37 次引用
  3. Aliasing Limits on Translating C to Safe RustMehmet Emre, Peter Boyland, Aesha Parekh, Ryan Schroeder 等OOPSLA 2023 · 32 次引用
  4. Concrat: An Automatic C-to-Rust Lock API Translator for Concurrent ProgramsJaemin Hong, Sukyoung RyuICSE 2023 · 17 次引用
  5. Don't Write, but Return: Replacing Output Parameters with Algebraic Data Types in C-to-Rust TranslationJaemin Hong, Sukyoung RyuPLDI 2024 · 17 次引用

相关 Paper

  1. &inator: Correct, Precise C-to-Rust Interface TranslationVictor Chen, Ayden Coughlin, Michael D. BondPLDI 2026 · 1 次引用
  2. Semantic Analysis of Macro Usage for PortabilityBrent Pappas, Paul GazzilloICSE 2024 · 2 次引用
  3. Scylla: Translating an Applicative Subset of C to Safe RustAymeric Fromherz, Jonathan ProtzenkoOOPSLA 2026 · 6 次引用
  4. 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 次引用
  5. Cpp2Rust: Automatic Translation of C++ to Safe RustLucian Popescu, Francisco Gouveia, Henrique Preto, João Silveira 等PLDI 2026 · 1 次引用
黄昏的海面,两侧是细线勾勒的悬崖