CRUST-Bench: C言語から安全なRustへのトランスパイリングのための包括的ベンチマーク
CRUST-Bench: A Comprehensive Benchmark for C-to-safe-Rust Transpilation
April 21, 2025
著者: Anirudh Khatry, Robert Zhang, Jia Pan, Ziteng Wang, Qiaochu Chen, Greg Durrett, Isil Dillig
cs.AI
要旨
CからRustへのトランスパイルは、レガシーCコードの近代化と、現代のRustエコシステムとの安全性と相互運用性の向上に不可欠です。しかし、Cを安全なRustにトランスパイルし、一連のテストケースを通過できるかどうかを評価するためのデータセットは現在存在しません。本論文では、CRUST-Benchを紹介します。これは100のCリポジトリからなるデータセットで、各リポジトリには手動で記述された安全なRustのインターフェースと、トランスパイルの正しさを検証するためのテストケースがペアになっています。単体の関数ではなくリポジトリ全体を考慮することで、CRUST-Benchは複数のファイルにまたがる依存関係を持つ複雑なプロジェクトの翻訳における課題を捉えています。提供されるRustインターフェースは、慣用的でメモリ安全なRustパターンに準拠することを保証する明示的な仕様を提供し、付随するテストケースは機能的な正しさを強制します。我々は、最先端の大規模言語モデル(LLM)をこのタスクで評価し、安全で慣用的なRustの生成が、様々な最先端の手法や技術にとって依然として難しい問題であることを明らかにしました。また、LLMがCから安全なRustへのコードトランスパイルで通常犯すエラーについての洞察も提供します。最高のパフォーマンスを示したモデルであるOpenAI o1でさえ、シングルショット設定では15のタスクしか解決できませんでした。CRUST-Benchの改善は、複雑なシナリオを推論し、レガシーコードベースをCからメモリ安全性を保証するRustのような言語に移行するのに役立つ、より優れたトランスパイルシステムの開発につながるでしょう。データセットとコードはhttps://github.com/anirudhkhatry/CRUST-benchで見つけることができます。
English
C-to-Rust transpilation is essential for modernizing legacy C code while
enhancing safety and interoperability with modern Rust ecosystems. However, no
dataset currently exists for evaluating whether a system can transpile C into
safe Rust that passes a set of test cases. We introduce CRUST-Bench, a dataset
of 100 C repositories, each paired with manually-written interfaces in safe
Rust as well as test cases that can be used to validate correctness of the
transpilation. By considering entire repositories rather than isolated
functions, CRUST-Bench captures the challenges of translating complex projects
with dependencies across multiple files. The provided Rust interfaces provide
explicit specifications that ensure adherence to idiomatic, memory-safe Rust
patterns, while the accompanying test cases enforce functional correctness. 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 for
various state-of-the-art methods and techniques. We also provide insights into
the errors LLMs usually make in transpiling code from C to safe Rust. The best
performing model, OpenAI o1, is able to solve only 15 tasks in a single-shot
setting. Improvements on CRUST-Bench would lead to improved transpilation
systems that can reason about complex scenarios and help in migrating legacy
codebases from C into languages like Rust that ensure memory safety. You can
find the dataset and code at https://github.com/anirudhkhatry/CRUST-bench.Summary
AI-Generated Summary