Forcrat: Automatic I/O API Translation from C to Rust via Origin and Capability Analysis
Jaemin Hong, Sukyoung Ryu

TL;DR
This paper presents Forcrat, an automated approach to translate C I/O API calls to Rust by analyzing origins, capabilities, and error sources, improving translation correctness and efficiency.
Contribution
It introduces origin, capability, and error source analysis techniques to accurately replace C I/O library calls with Rust std equivalents in automated translation.
Findings
All 32 test programs passed after transformation.
Analyzed and transformed 422,000 lines of code in 14 seconds.
Replaced 82% of I/O API calls in the evaluated programs.
Abstract
Translating C to Rust is a promising way to enhance the reliability of legacy system programs. Although the industry has developed an automatic C-to-Rust translator, C2Rust, its translation remains unsatisfactory. One major reason is that C2Rust retains C standard library (libc) function calls instead of replacing them with functions from the Rust standard library (Rust std). However, little work has been done on replacing library functions in C2Rust-generated code. In this work, we focus on replacing the I/O API, an important subset of library functions. This poses challenges due to the semantically different designs of I/O APIs in libc and Rust std. First, the two APIs offer different sets of types that represent the origins (e.g., standard input, files) and capabilities (e.g., read, write) of streams used for I/O. Second, they use different error-checking mechanisms: libc uses…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsRobotics and Automated Systems · Web Data Mining and Analysis · Power Systems and Technologies
