EVOC2RUST: 프로젝트 수준 C-to-Rust 변환을 위한 스켈레톤 기반 프레임워크
EVOC2RUST: A Skeleton-guided Framework for Project-Level C-to-Rust Translation
August 6, 2025
저자: Chaofan Wang, Tingrui Yu, Jie Wang, Dong Chen, Wenrui Zhang, Yuling Shi, Xiaodong Gu, Beijun Shen
cs.AI
초록
Rust의 컴파일 타임 안전성 보장은 안전이 중요한 시스템에 이상적이며, 이로 인해 레거시 C 코드베이스를 Rust로 변환하는 수요가 증가하고 있습니다. 이 작업을 위해 다양한 접근 방식이 등장했지만, 이들은 본질적인 트레이드오프에 직면해 있습니다: 규칙 기반 솔루션은 코드 안전성과 관용성 요구 사항을 충족하는 데 어려움을 겪는 반면, LLM 기반 솔루션은 전체 코드베이스에 걸친 모듈 간의 강력한 의존성으로 인해 의미적으로 동등한 Rust 코드를 생성하는 데 종종 실패합니다. 최근 연구에 따르면, 두 솔루션 모두 소규모 프로그램에만 제한적으로 적용 가능한 것으로 나타났습니다. 본 논문에서는 전체 C 프로젝트를 동등한 Rust 프로젝트로 변환하기 위한 자동화된 프레임워크인 EvoC2Rust를 제안합니다. EvoC2Rust는 프로젝트 수준의 변환을 위해 스켈레톤 가이드 변환 전략을 사용합니다. 이 파이프라인은 세 가지 진화 단계로 구성됩니다: 1) 먼저 C 프로젝트를 기능적 모듈로 분해하고, 기능 매핑이 강화된 LLM을 사용하여 정의와 매크로를 변환하며, 타입 검사된 함수 스텁을 생성하여 컴파일 가능한 Rust 스켈레톤을 형성합니다; 2) 그런 다음 함수를 점진적으로 변환하여 해당 스텁 플레이스홀더를 대체합니다; 3) 마지막으로, LLM과 정적 분석을 통합하여 컴파일 오류를 수정합니다. 진화적 증강을 통해 EvoC2Rust는 규칙 기반과 LLM 기반 솔루션의 장점을 결합합니다. 오픈소스 벤치마크와 6개의 산업 프로젝트에 대한 평가를 통해 EvoC2Rust가 프로젝트 수준의 C-to-Rust 변환에서 우수한 성능을 보임을 입증했습니다. 평균적으로, EvoC2Rust는 LLM 기반 접근 방식에 비해 구문 및 의미 정확도에서 각각 17.24%와 14.32%의 개선을 달성했으며, 규칙 기반 도구에 비해 코드 안전성 비율이 96.79% 더 높았습니다. 모듈 수준에서는, EvoC2Rust가 산업 프로젝트에서 복잡한 코드베이스와 긴 함수에도 불구하고 92.25%의 컴파일 성공률과 89.53%의 테스트 통과률을 기록했습니다.
English
Rust's compile-time safety guarantees make it ideal for safety-critical
systems, creating demand for translating legacy C codebases to Rust. While
various approaches have emerged for this task, they face inherent trade-offs:
rule-based solutions face challenges in meeting code safety and idiomaticity
requirements, while LLM-based solutions often fail to generate semantically
equivalent Rust code, due to the heavy dependencies of modules across the
entire codebase. Recent studies have revealed that both solutions are limited
to small-scale programs. In this paper, we propose EvoC2Rust, an automated
framework for converting entire C projects to equivalent Rust ones. EvoC2Rust
employs a skeleton-guided translation strategy for project-level translation.
The pipeline consists of three evolutionary stages: 1) it first decomposes the
C project into functional modules, employs a feature-mapping-enhanced LLM to
transform definitions and macros and generates type-checked function stubs,
which form a compilable Rust skeleton; 2) it then incrementally translates the
function, replacing the corresponding stub placeholder; 3) finally, it repairs
compilation errors by integrating LLM and static analysis. Through evolutionary
augmentation, EvoC2Rust combines the advantages of both rule-based and
LLM-based solutions. Our evaluation on open-source benchmarks and six
industrial projects demonstrates EvoC2Rust's superior performance in
project-level C-to-Rust translation. On average, it achieves 17.24% and 14.32%
improvements in syntax and semantic accuracy over the LLM-based approaches,
along with a 96.79% higher code safety rate than the rule-based tools. At the
module level, EvoC2Rust reaches 92.25% compilation and 89.53% test pass rates
on industrial projects, even for complex codebases and long functions.