一位开发者在Hacker News上提议为Rust创建新的外部函数接口extern "fil-C",以实现与经过Fil-C重编译的C/C++库的安全交互[1]。Fil-C通过运行时检查和垃圾回收器为遗留C代码提供内存安全保证[1]。该提议者认为,这样的标准可以激励开发者逐步将性能关键路径从C迁移到Rust,同时保持向后兼容性[1]。
技术层面上,Fil-C与C源代码兼容但ABI不兼容,而Rust当前的extern "C"遵循Yolo-C ABI[1]。filnix已将Fil-C打包为Nix交叉编译平台,并移植了超过100个nixpkgs包[1]。与此同时,编程语言Zig也在从另一个方向研究类似问题,其创造者Andrew Kelley提议了一个受Fil-C启发的可选fil ABI[1]。
提议者呼吁Rust、Fil-C、Zig和Nix社区进行跨生态协作来实现这一方案,并邀请社区在OceanSprint活动中共同构建这一解决方案[1]。
A Rust developer has proposed creating a new external function interface standard called "extern fil-C" to enable safer interaction with C and C++ libraries that have been recompiled with Fil-C.[1] Fil-C enhances legacy C code with memory safety guarantees through runtime checks and garbage collection, and the proposal argues that this new interface could incentivize developers to gradually migrate performance-critical paths from C to Rust while maintaining backward compatibility.[1]
The initiative highlights a fundamental compatibility challenge: while Fil-C maintains source-code compatibility with C, it is not compatible at the application binary interface (ABI) level, whereas Rust's current "extern C" follows the Yolo-C ABI standard.[1] To advance this work, filnix has already packaged Fil-C as a Nix cross-compilation platform and ported over 100 nixpkgs packages.[1] Parallel efforts are underway in other language ecosystems—Zig is exploring similar solutions from a different angle, with Andrew Kelley proposing an optional fil ABI inspired by Fil-C.[1]
The proposal calls for cross-ecosystem collaboration among the Rust, Fil-C, Zig, and Nix communities to build this solution together at next year's OceanSprint event in Lanzarote.[1]