arrow
Return

MinsC2Rust: LLM-driven project-level code migration from C to safe Rust

delete2026-06-22
delete0
PRE
AI
Z
Zhehao Kang
Q
Qianyu Zhu
W
Wenrui Mou
B
Bang Wang *
X
Xiaogang Zhang
H
Haojun Huang
DOI:10.1007/s10664-026-10905-4delete
deleteOriginal
deleteOriginal request for help
deleteShare
deleteSave
Abstract

Abstract

En 中文
C and C++ dominate systems programming but suffer from inherent memory safety issues. Rust offers a promising alternative due to its safety guarantees and performance, yet migrating legacy C/C++ code remains challenging. Existing automated transpilation approaches are either rule-based–yielding non-idiomatic, unsafe Rust–or LLM-based, which improve safety and style but struggle with scalability, context limitations, and preserving the original project structure. To address these challenges, we propose MinsC2Rust, an LLM-driven framework for automated C-to-Rust project code migration. It follows a divide-transpile-reconstruct paradigm that enables scalable, context-aware transpilation. MinsC2Rust (1) analyzes function dependencies to schedule transpilation, (2) decomposes projects into self-contained units, (3) iteratively transpiles using LLMs with dependency context and compilation error feedback, and (4) reconstructs the complete Rust project while maintaining the original project’s code structure (including file organization and inter-function call relations). Evaluations on C-Algorithm and Crown benchmarks show that MinsC2Rust achieves 98.4% compilation success and 42.6% execution correctness. It also produces highly safe code, with 100% safe lines of code coverage and 95.8% safe reference ratio, outperforming four representative methods across rule-based and LLM-based transpilation paradigms. These results demonstrate that MinsC2Rust offers a practical and scalable solution for migrating C codebases to Rust.
Keywords:
C-to-Rust transpilation
LLM-driven transpilation
Project-level transpilation
Safe rust transpilation

Journal

Empirical Software Engineering cover
Empirical Software Engineering
IF:
3.6
Papers:
2.0K
Citations:
5.3K

Organization

S
School of Electronic Information and Communications
Scholars:
25
Papers: 10
Citations: 0
Cited Papers

Cited Papers

Aliasing Limits on Translating C to Safe Rust
err2023-04-06
err0
errOAAI
errMehmet Emre; Peter Boyland; Aesha Parekh; Ryan Schroeder; Kyle Dewey; Ben Hardekopf
errShare
errSave
errShare
errSave