CRUST-Bench
收藏资源简介:
CRUST-Bench是一个用于评估C到安全Rust转译的数据集,包含100个C仓库,每个仓库都配有手动编写的安全Rust接口和测试用例。该数据集考虑了整个仓库而非孤立函数,能够捕捉跨多个文件的复杂项目转译的挑战。
CRUST-Bench is a dataset dedicated to evaluating the transpilation of C code to safe Rust. It includes 100 C repositories, each paired with manually written safe Rust interfaces and test cases. Unlike approaches that focus solely on isolated functions, this dataset considers entire repositories, allowing it to capture the challenges associated with transpiling complex projects spanning multiple files.
CRUST-Bench 数据集概述
基本信息
- 版本: 1.0.0
- 许可证: GNU GPL
- 最后更新: April 2025
- 论文: CRUST-Bench: A Comprehensive Benchmark for C-to-safe-Rust Transpilation
数据集简介
CRUST-Bench 是一个用于评估 C 代码转译为安全 Rust 代码的数据集,包含 100 个 C 仓库,每个仓库均配有手动编写的安全 Rust 接口和测试用例。
数据集结构
数据集包含两个主要文件夹:
-
CBench: 包含从 GitHub 收集的 C 项目。
CBench/ ├── Project_1/ │ ├── file1.c/ │ ├── file2.c/ │ └── ... └── ...
-
RBench: 包含手动注释的 Rust 接口和测试。
RBench/ ├── Project_1/ │ ├── interfaces/ │ │ ├── file1.rs │ │ ├── file2.rs │ │ └── ... │ ├── bin/ │ │ ├── test1.rs │ │ ├── test2.rs │ │ └── ... └── ...
使用说明
环境要求
- 依赖项: 运行
pip install -r requirements.txt - Rust: 需安装 rustup
加载数据集
数据集位于 datasets 文件夹中,解压后包含 CBench 和 RBench 文件夹。
脚本与工具
- 类型检查: 运行
python check_benchmarks/check_build.py - 数据集统计:
python src/dataset_stats/get_c_stats.py datasets/CBenchpython src/dataset_stats/get_interfaces_stats.py datasets/RBench
实验复现
需设置以下环境变量: bash export OPENAI_API_KEY=<OpenAI_API_KEY> export ANTHROPIC_API_KEY=<ANTHROPIC_API_KEY> export GOOGLE_CLOUD_PROJECT=<GOOGLE_CLOUD_PROJECT> export GOOGLE_CLOUD_REGION=<GOOGLE_CLOUD_REGION>
运行参数
主要参数包括:
--benchmark_dir: C 项目目录路径--rust_dir: Rust 项目目录路径--output_dir: 输出目录路径--prompt: 转译提示--mode: 转译模式(normal或multi_gen)--endpoint: 模型端点
引用
bibtex @misc{ khatry2025crustbenchcomprehensivebenchmarkctosaferust, title={CRUST-Bench: A Comprehensive Benchmark for C-to-safe-Rust Transpilation}, author={Anirudh Khatry and Robert Zhang and Jia Pan and Ziteng Wang and Qiaochu Chen and Greg Durrett and Isil Dillig}, year={2025}, eprint={2504.15254}, archivePrefix={arXiv}, primaryClass={cs.SE}, url={https://arxiv.org/abs/2504.15254}, }
联系方式
- 联系人: Anirudh Khatry
- 邮箱: akhatry@utexas.edu
- GitHub: @anirudhkhatry




