Dependency-Guided Repository-Level C-to-Rust Translation with Reinforcement Alignment
- URL: http://arxiv.org/abs/2604.02852v1
- Date: Fri, 03 Apr 2026 08:13:42 GMT
- Title: Dependency-Guided Repository-Level C-to-Rust Translation with Reinforcement Alignment
- Abstract summary: C-to-Rust migration is critical for improving software security without sacrificing performance.<n>Large Language Models (LLMs), trained on massive code corpora, offer a promising alternative.<n>We propose DepTrans, a framework that combines model capability enhancement with structured inference.
- Score: 26.296349203732138
- License: http://creativecommons.org/licenses/by/4.0/
- 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.
Related papers
- RepoReasoner: Evaluating Repository-Level Code Reasoning Ability of Long-Context Language Models [54.53236295237077]
We introduce RepoReasoner, a benchmark for evaluating repository-level code reasoning.<n> Output Prediction measures fine-grained, stateful execution reasoning across files.<n>Call Chain Prediction evaluates high-level architectural dependency understanding under noisy context.
arXiv Detail & Related papers (2026-07-28T17:12:41Z) - Towards Reliable C-to-Rust Translation with Rule-Guided Reasoning and Reinforcement Learning [21.45219780181232]
Leveraging large language models for automated C-to-Rust translation has emerged as a promising direction.<n>We propose a Translation fRAmework Via rule-guided reasoning and rEinforcement Learning, namely TRAVEL, consisting of two modules.<n>The first module employs Monte Carlo Tree Search (MCTS)-based reasoning path construction guided by Rust-specific rules.<n>The second module introduces reinforcement learning that couples execution feedback with reasoning-quality signals, encouraging the model to construct reasoning paths that accurately capture program semantics.
arXiv Detail & Related papers (2026-07-22T09:50:01Z) - ORBIT: Guided Agentic Orchestration for Autonomous C-to-Rust Transpilation [5.3011925761003775]
We present ORBIT, an autonomous agentic framework for project-level C-to-Rust translation.<n>It combines dynamic context collection with dependency-guided orchestration and iterative verification.<n>It substantially outperforms C2Rust and CRUST-Bench, while reducing unsafe Rust code blocks to nearly zero.
arXiv Detail & Related papers (2026-04-13T20:40:34Z) - C2RustXW: Program-Structure-Aware C-to-Rust Translation via Program Analysis and LLM [16.098065606505983]
tool is a program-structure-aware C-to-Rust translation approach that integrates program analysis with Large Language Models (LLMs)<n>tool achieves 100% syntactic correctness on CodeNet and 97.78% on GitHub, while significantly reducing code size (up to 43.70%) and unsafe usage (to 5.75%)<n>At the project level, tool achieves perfect syntactic correctness and an average semantic correctness of 78.87%, demonstrating its effectiveness for practical and scalable C-to-Rust migration.
arXiv Detail & Related papers (2026-03-30T17:07:11Z) - His2Trans: A Skeleton First Framework for Self Evolving C to Rust Translation with Historical Retrieval [45.246293154277886]
His2Trans is a framework that combines a deterministic, build-aware skeleton with self-evolving knowledge extraction to support stable, incremental migration.<n> Experiments on industrial OpenHarmony modules show that His2Trans reaches a 99.75% incremental compilation pass rate.
arXiv Detail & Related papers (2026-03-03T05:42:08Z) - Architecture-Aware Multi-Design Generation for Repository-Level Feature Addition [53.50448142467294]
RAIM is a multi-design and architecture-aware framework for repository-level feature addition.<n>It shifts away from linear patching by generating multiple diverse implementation designs.<n>Experiments on the NoCode-bench Verified dataset demonstrate that RAIM establishes a new state-of-the-art performance.
arXiv Detail & Related papers (2026-03-02T12:50:40Z) - Do Not Treat Code as Natural Language: Implications for Repository-Level Code Generation and Beyond [13.550121154853715]
We present Hydra, a repository-level code generation framework that treats code as structured code rather than natural language.<n>We show that Hydra achieves state-of-the-art performance across open- and closed-source CodeLLMs.
arXiv Detail & Related papers (2026-02-12T07:44:00Z) - EvoC2Rust: A Skeleton-guided Framework for Project-Level C-to-Rust Translation [17.560908544319094]
EvoC2Rust is an automated framework for converting complete C projects to equivalent Rust ones.<n>It employs a skeleton-guided translation strategy for project-level translation.
arXiv Detail & Related papers (2025-08-06T10:31:23Z) - Turning the Tide: Repository-based Code Reflection [52.13709676656648]
We introduce LiveRepoReflection, a benchmark for evaluating code understanding and generation in multi-file repository contexts.<n>1,888 rigorously filtered test cases across $6$ programming languages to ensure diversity, correctness, and high difficulty.<n>We also create RepoReflection-Instruct, a large-scale, quality-filtered instruction-tuning dataset derived from diverse sources.
arXiv Detail & Related papers (2025-07-14T02:36:27Z) - CRUST-Bench: A Comprehensive Benchmark for C-to-safe-Rust Transpilation [51.18863297461463]
CRUST-Bench is a dataset of 100 C repositories, each paired with manually-written interfaces in safe Rust as well as test cases.<n>We evaluate state-of-the-art large language models (LLMs) on this task and find that safe and idiomatic Rust generation is still a challenging problem.<n>The best performing model, OpenAI o1, is able to solve only 15 tasks in a single-shot setting.
arXiv Detail & Related papers (2025-04-21T17:33:33Z) - RustRepoTrans: Repository-level Code Translation Benchmark Targeting Rust [50.65321080814249]
RustRepoTrans is the first repository-level context code translation benchmark targeting incremental translation.<n>We evaluate seven representative LLMs, analyzing their errors to assess limitations in complex translation scenarios.
arXiv Detail & Related papers (2024-11-21T10:00:52Z) - COrAL: Order-Agnostic Language Modeling for Efficient Iterative Refinement [80.18490952057125]
Iterative refinement has emerged as an effective paradigm for enhancing the capabilities of large language models (LLMs) on complex tasks.
We propose Context-Wise Order-Agnostic Language Modeling (COrAL) to overcome these challenges.
Our approach models multiple token dependencies within manageable context windows, enabling the model to perform iterative refinement internally.
arXiv Detail & Related papers (2024-10-12T23:56:19Z)
This list is automatically generated from the titles and abstracts of the papers in this site.
This site does not guarantee the quality of this site (including all information) and is not responsible for any consequences.