SpeC2Rust: Specification-Driven Repository-Level C-to-Rust Translation
Junjie Yao, Xiongzheng Guan, Jia Feng, Yujia Chen, Hongliang Tian, Cuiyun Gao
Key points
From the paper's conclusion- We propose SpeC2Rust, a specification-driven pipeline for repository-level C-to-Rust translation.
Abstract
Legacy C codebases remain central to system software and performance-critical infrastructure, but their weak memory safety imposes security and maintenance risks. Recent C-to-Rust translation systems, including LLM-based translators, make automated migration increasingly feasible, yet they still struggle to recover repository-level intent, avoid raw pointers and unsafe constructs, maintain cross-file interfaces, and repair compilation and validation failures efficiently. We propose SpeC2Rust, a specification-driven pipeline for repository-level C-to-Rust translation. It has three stages: (1) Project-Intent Structuring, which decomposes a C repository into semantically coherent modules and generates persistent repository- and module-level specifications; (2) Spec-Guided Generation, which translates each Rust module against these specifications with a live symbol registry to preserve cross-file consistency; and (3) Layered-Feedback Repair, which batches repairs and injects only failure-relevant diagnostics, specification context, and source evidence for efficient compilation and test-driven correction. We evaluate SpeC2Rust on eight repository-level C projects. It generates Rust projects that compile and pass the original end-to-end tests, with no raw-pointer declarations, raw-pointer dereferences, or unsafe lines. On projects shared with an LLM-based baseline, SpeC2Rust reduces cost by 66.1% and input-token usage by 84.7%.
Read the paper
Discussion
Science Skim's AI key points, plus readers' public thoughts
Readers' thoughts
No reader thoughts yet.
Related papers
- C2SaferRust: Transforming C Projects Into Safer Rust With NeuroSymbolic TechniquesIEEE Transactions on Software Engineering · 2025
- Beyond Source Code: Evaluating Natural Language Specifications for LLM-Based C-to-Rust TranslationarXiv · 2026
- Scylla: Translating an Applicative Subset of C to Safe RustProceedings of the ACM on Programming Languages · 2026
- Req2Rust: A Requirements-Guided Agent Harness for Project-Level C++-to-Rust MigrationarXiv · 2026
- Where Does the Performance Go? Understanding and Recovering Performance Regressions in C-to-Rust TranslationarXiv · 2026
- C-to-Rust Translation Validation at the LLVM IR Level via AI-Assisted Refinement ProofarXiv · 2026