Dependency-Guided Repository-Level C-to-Rust Translation with Reinforcement Alignment

📅 2026-04-03
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
Automated migration from C to Rust faces significant challenges, including difficulties in modeling cross-file dependencies, scarcity of large-scale parallel corpora, and frequent generation of syntactically invalid or functionally inequivalent code. This work proposes DepTrans, a novel framework that integrates multi-task fine-tuning, feedback-driven reinforcement learning, and dependency-guided iterative refinement to explicitly model fine-grained cross-file dependencies, enabling high-quality, repository-level C-to-Rust translation for the first time. Evaluated on a newly curated dataset of 85k samples and 145 real-world repositories, DepTrans achieves a compilation success rate of 60.7% and a computational correctness rate of 43.5%, substantially outperforming existing baselines. Notably, it successfully migrates 7 out of 15 industrial C projects, demonstrating its practical viability.
📝 Abstract
Automating C-to-Rust migration is critical for improving software security without sacrificing performance. Traditional rule-based methods struggle with diverse C idioms, often producing rigid and unidiomatic Rust code. Large Language Models (LLMs), trained on massive code corpora, offer a promising alternative by leveraging cross-language generalization to generate more idiomatic and maintainable Rust code. However, several challenges remain. First, existing LLM-based approaches fail to handle cross-file dependencies effectively, either ignoring them or including entire files as context, which limits accurate dependency modeling. Second, complex dependencies and structured inputs and outputs make it difficult to verify syntactic correctness and functional equivalence at the repository level. Third, the lack of large-scale C-Rust parallel data constrains model performance. We propose DepTrans, a framework that combines model capability enhancement with structured inference. DepTrans introduces Reinforcement-Aligned Syntax Training to improve generation quality through multi-task fine-tuning and feedback-driven reinforcement learning. It further applies Dependency-Guided Iterative Refinement to capture fine-grained cross-file dependencies and iteratively refine generated Rust code. We construct a dataset of 85k training samples and a benchmark of 145 repository-level instances. Experiments show that DepTrans achieves a 60.7 percent compilation success rate and 43.5 percent computational accuracy, outperforming the strongest baseline by 22.8 and 17.3 percentage points. It also successfully builds 7 of 15 industrial C projects, demonstrating its practical potential.
Problem

Research questions and friction points this paper is trying to address.

C-to-Rust translation
cross-file dependencies
repository-level migration
functional equivalence
parallel data scarcity
Innovation

Methods, ideas, or system contributions that make the work stand out.

Reinforcement-Aligned Syntax Training
Dependency-Guided Iterative Refinement
Repository-Level Translation
C-to-Rust Migration
Cross-File Dependency Modeling
🔎 Similar Papers
No similar papers found.