Copy the page URI to the clipboard
Cai, Xuemeng; Liu, Jiakun; Liu, Cunyang; Bao, Lingfeng; Yu, Yijun and Jiang, Lingxiao
(2026).
DOI: https://doi.org/10.1145/3795532
Abstract
Rust has become increasingly popular in recent years due to its safety and high performance. Despite these advantages, Rust projects rarely start from scratch in practice, and many Rust-based systems instead use hybrid programming, where Rust interoperates with existing C/C++ code. To reduce the manual effort involved in this interoperation (interop) process, several interop tools have been proposed to facilitate hybrid programming between Rust and C/C++. However, the challenges and limitations of these tools remain largely unexplored, leaving developers unclear about the future directions and users unclear about the appropriate usage scenarios. To fill the gap, we mined 320 bugs in the popular interop tools, i.e., Bindgen, Cbindgen, and CXX. We observe that the main obstacle is not tool crashes or performance issues, but the inability to generate correct and functional code. The leading types of the failures are generating code that is unfaithful to the original code’s intent and generating incomplete code. Memory layout mismatch is the most common cause with Bindgen. Input with complex struct is the biggest challenge across tools, followed by the usage with specific tool configuration options for customized binding generation. Even input with primitive data types can be problematic. We also observe a common fix pattern that updates the control flow and condition. Based on our findings, we propose a series of suggestions to developers, users, and future researchers. For example, we suggest the developers validate configuration combinations, provide clearer documentation, and implement default-safe mechanisms to prevent failures related to unexpected tool configuration options.
Plain Language Summary
Interop between C++ and Rust requires automated tools to bridge their gaps. However, three existing tools `bindgen`, `cbindgen` and `cxx` cannot yet meet all the needs of such automation. After reviewing these deficiencies, this study provides some practical recommendations to the community to methodologically address these problems safely.

CORE (COnnecting REpositories)
CORE (COnnecting REpositories)