paperbot · PL 论文追踪

全部论文 待读 收藏

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

依赖引导的仓库级 C 到 Rust 翻译与强化对齐
FSE Proceedings of the 34th ACM International Conference on the Foundations of Software Engineering2026匹配度 4/10 · 该论文是 LLM 用于仓库级 C-to-Rust 代码翻译,属于 AI+PL 的宽泛交叉,并包含依赖引导、工业级 benchmark 等与用户兴趣部分重合的元素;但用户核心方向是静态分析/形式化验证与 LLM 的相互增强、浮点程序分析、贝叶斯程序分析及 Agentic 程序分析,本文并不直接涉及这些主题。引用 0 inbox
Jia Feng, Wenjie Gan, Cuiyun Gao, Chaozheng Wang, Feng Luo, Xin Xia, Ge Li, Kui Liu
crossref: 2026-09-12dblp: 2026-09-12arxiv: 2026-09-12

AI 速览

一句话:提出 DepTrans,用强化对齐训练与依赖引导迭代精化实现仓库级 C 到 Rust 翻译。

将 C 代码迁移到 Rust 对提升软件安全性且不牺牲性能至关重要。规则方法难以应对多样的 C 惯用法,生成的 Rust 代码不地道且僵化;基于 LLM 的方法虽有跨语言泛化优势,却难以处理跨文件引用、仓库级翻译的语法正确性与功能等价性验证,且缺乏大规模 C-Rust 平行数据。为此,论文提出 DepTrans,将模型能力增强与结构化推理框架相结合:首先通过强化对齐语法训练,利用多任务微调与反馈驱动的强化学习提升模型内在生成能力;再基于增强后的基础模型,用依赖引导迭代精化模块识别细粒度跨文件依赖作为丰富上下文,并迭代精化生成的 Rust 代码以保证语法正确与功能等价。为支持训练与评估,作者构建了 85k 训练样本和 145 个仓库级实例的基准。实验表明,DepTrans 编译成功率达 60.7%,计算准确率达 43.5%,分别超出最强基线 22.8% 和 17.3%;并在华为内部 15 个工业级 C 项目中成功构建 7 个,展示了企业级迁移潜力。

问题
现有规则方法难以处理多样的 C 惯用法,而基于 LLM 的 C-to-Rust 迁移方法未能充分处理跨文件依赖,且难以验证仓库级翻译的语法正确性与功能等价性,同时缺乏大规模平行数据。
方法
DepTrans 结合强化对齐语法训练(多任务微调与反馈驱动强化学习)与依赖引导迭代精化(识别细粒度跨文件依赖作为上下文并迭代修正 Rust 代码)。
评估
构建 85k 训练样本与 145 个仓库级实例基准,以编译成功率和计算准确率为指标,并与最强基线对比;还在华为内部 15 个工业级 C 项目上验证构建成功率。
原文摘要(Abstract)

Automating C-to-Rust migration is critical for enhancing software security without compromising performance. Traditional rule-based methods often struggle with diverse C idioms, yielding unidiomatic and rigid Rust translations. In contrast, Large Language Models (LLMs), enriched by massive code corpora, offer a superior alternative due to their cross-language generalization, enabling the generation of idiomatic and maintainable Rust code. However, applying LLMs to C-to-Rust migration still poses several challenges. First, existing LLM-based approaches fail to adequately handle cross-file references. They either overlook the dependencies or incorporate entire files as context, thereby hindering the model's ability to accurately capture dependency information for translation. Second, the complex dependencies and structured inputs/outputs make it difficult to validate the syntactic correctness and functional equivalence of repository-level translations. Furthermore, the scarcity of large-scale C-Rust parallel data constrains the inherent generation capabilities of LLMs, resulting in limited performance. To address these challenges, we propose DepTrans, which synergizes model-level capability enhancement with a structured inference framework. DepTrans first employs the Reinforcement-Aligned Syntax Training module to bolster the model's intrinsic generation capabilities through multi-task fine-tuning and feedback-driven reinforcement learning. Building upon this enhanced foundation model, the Dependency-Guided Iterative Refinement module identifies the fine-grained cross-file dependencies as enriched context for the initial translation, and further iteratively refines the generated Rust code to ensure the syntactic correctness and functional equivalence. To facilitate the model training and repository-level evaluation, we construct a large-scale corpus of 85k training samples and a specialized benchmark of 145 repository-level instances. Experimental results show that DepTrans achieves a compilation success rate of 60.7% and a computational accuracy of 43.5%, outperforming the strongest baseline by 22.8% and 17.3%, respectively. Moreover, DepTrans successfully builds 7 out of 15 industrial-scale C projects from Huawei's internal codebase, demonstrating its potential in enterprise-level C-to-Rust migration.

链接与引用

DOI 原文 · arXiv · PDF(开放获取) · DBLP

BibTeX
@inproceedings{abs-2604-02852,
  title = {Dependency-Guided Repository-Level C-to-Rust Translation with Reinforcement Alignment},
  author = {Jia Feng and Wenjie Gan and Cuiyun Gao and Chaozheng Wang and Feng Luo and Xin Xia and Ge Li and Kui Liu},
  booktitle = {FSE},
  year = {2026},
  doi = {10.1145/3803437.3805266}
}