Forcrat: Automatic I/O API Translation from C to Rust via Origin and Capability Analysis
Jaemin Hong, Sukyoung Ryu
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 internal indicators, while Rust std uses return values. To address these challenges, we propose two static analysis techniques, origin and capability analysis and error source analysis, and use their results to replace the I/O API. Our evaluation shows that the proposed approach is (1) correct, with all 32 programs that have test suites passing the tests after transformation, (2) efficient, analyzing and transforming 422k LOC in 14 seconds, and (3) widely applicable, replacing 82% of I/O API calls.
Ask Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
3 top-tier papers have cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- Project-Level C-to-Rust Translation via Pointer Knowledge Graphs cites Ownership Guided C to Rust Translation
- Project-Level C-to-Rust Translation via Pointer Knowledge Graphs cites Aliasing Limits on Translating C to Safe Rust
- Project-Level C-to-Rust Translation via Pointer Knowledge Graphs cites Don't Write, but Return: Replacing Output Parameters with Algebraic Data Types in C-to-Rust Translation
- Project-Level C-to-Rust Translation via Pointer Knowledge Graphs cites Translating C to safer Rust
- Ownership Guided C to Rust Translation cites Translating C to safer Rust
- Aliasing Limits on Translating C to Safe Rust cites Translating C to safer Rust
- Hayroll: A Modular Wrapper for Translating C Macros and Conditional Compilation to Rust cites Project-Level C-to-Rust Translation via Pointer Knowledge Graphs
- Hayroll: A Modular Wrapper for Translating C Macros and Conditional Compilation to Rust cites Ownership Guided C to Rust Translation
- Hayroll: A Modular Wrapper for Translating C Macros and Conditional Compilation to Rust cites Aliasing Limits on Translating C to Safe Rust
- Hayroll: A Modular Wrapper for Translating C Macros and Conditional Compilation to Rust cites Concrat: An Automatic C-to-Rust Lock API Translator for Concurrent Programs
- Hayroll: A Modular Wrapper for Translating C Macros and Conditional Compilation to Rust cites Don't Write, but Return: Replacing Output Parameters with Algebraic Data Types in C-to-Rust Translation
- Hayroll: A Modular Wrapper for Translating C Macros and Conditional Compilation to Rust cites Translating C to safer Rust
- Concrat: An Automatic C-to-Rust Lock API Translator for Concurrent Programs cites Translating C to safer Rust
- Rust’s Type Checker Implementation Is Unsound: An Empirical Study on Soundness Bugs in rustc cites Ownership Guided C to Rust Translation
- Rust’s Type Checker Implementation Is Unsound: An Empirical Study on Soundness Bugs in rustc cites Aliasing Limits on Translating C to Safe Rust
- Rust’s Type Checker Implementation Is Unsound: An Empirical Study on Soundness Bugs in rustc cites Concrat: An Automatic C-to-Rust Lock API Translator for Concurrent Programs
- Rust’s Type Checker Implementation Is Unsound: An Empirical Study on Soundness Bugs in rustc cites Don't Write, but Return: Replacing Output Parameters with Algebraic Data Types in C-to-Rust Translation
- Rust’s Type Checker Implementation Is Unsound: An Empirical Study on Soundness Bugs in rustc cites Translating C to safer Rust
Cited by top-tier papers3
- Hayroll: A Modular Wrapper for Translating C Macros and Conditional Compilation to RustHaoran Peng, Baris Kasikci, Gilbert Louis Bernstein, Michael D. ErnstPLDI 2026 · 1 citation
- Project-Level C-to-Rust Translation via Pointer Knowledge GraphsZhiqiang Yuan, Wenjun Mao, Zhuo Chen, Xiyue Shang et al.FSE 2026
- Rust’s Type Checker Implementation Is Unsound: An Empirical Study on Soundness Bugs in rustcYusung Sim, Sukyoung Ryu, Jaemin HongISSTA 2026
Builds on8
- Translating C to safer RustMehmet Emre, Ryan Schroeder, Kyle Dewey, Ben HardekopfOOPSLA 2021 · 60 citations
- Ownership Guided C to Rust TranslationHanliang Zhang, Cristina David, Yijun Yu, Meng WangCAV 2023 · 37 citations
- Aliasing Limits on Translating C to Safe RustMehmet Emre, Peter Boyland, Aesha Parekh, Ryan Schroeder et al.OOPSLA 2023 · 32 citations
- Concrat: An Automatic C-to-Rust Lock API Translator for Concurrent ProgramsJaemin Hong, Sukyoung RyuICSE 2023 · 17 citations
- Don't Write, but Return: Replacing Output Parameters with Algebraic Data Types in C-to-Rust TranslationJaemin Hong, Sukyoung RyuPLDI 2024 · 17 citations
Related papers
- To Tag, or Not to Tag: Translating C's Unions to Rust's Tagged UnionsJaemin Hong, Sukyoung RyuASE 2024 · 6 citations
- &inator: Correct, Precise C-to-Rust Interface TranslationVictor Chen, Ayden Coughlin, Michael D. BondPLDI 2026 · 1 citation
- Scylla: Translating an Applicative Subset of C to Safe RustAymeric Fromherz, Jonathan ProtzenkoOOPSLA 2026 · 6 citations
- GenC2Rust: Towards Generating Generic Rust Code from CXiafa Wu, Brian DemskyICSE 2025 · 4 citations
- Raw Pointer Rewriting with LLMs for Translating C to Safer RustYifei Gao, Chengpeng Wang, Pengxiang Huang, Xuwei Liu et al.ACL Findings 2026 · 3 citations
