有开发者提议为Rust创建一个新的外部函数接口规范 extern "fil-C",旨在通过Fil-C编译器实现跨语言的内存安全保证[1]。Fil-C是一款带有运行时检查和垃圾回收的C/C++编译器,能将内存安全违规转化为panic而非漏洞,从而使C库代码成为安全兼容路径而非高性能路径[1]。
该方案计划在初版中支持标量值、复制字符串和切片、不透明句柄,并自动生成安全的Rust包装器[1]。filnix已将Fil-C打包为Nix交叉编译平台,包含超过100个nixpkgs包的移植[1]。与此同时,Zig语言社区也在探索受Fil-C启发的可选fil ABI实现,以运行时内存安全编译Zig程序及其整个C/C++依赖树[1]。
作者呼吁Rust、Fil-C、Zig和Nix社区合作推进这一方案,并宣布将在兰萨罗特举办的OceanSprint上共同开发该解决方案[1]。filnix构建者Mikael Brockman已确认参加该活动[1]。
A developer has proposed creating a new external function interface for Rust, termed extern "fil-C", designed to enable memory-safe interoperability between Rust and C/C++ code through a specialized compiler approach [1]. The proposal leverages Fil-C, a C/C++ compiler that re-compiles existing code with runtime checks and concurrent garbage collection, converting memory safety violations into panics rather than exploitable vulnerabilities [1].
The initiative aims to reposition C library dependencies as safe but non-optimal code paths, motivating developers to gradually rewrite performance-critical sections in Rust [1]. The proposed Rust FFI specification would initially support scalar values, copyable strings and slices, and opaque handles while generating safe Rust wrapper functions [1]. Supporting this effort, filnix has already packaged Fil-C as a Nix cross-compilation platform with ports of over 100 nixpkgs packages [1]. The Zig language community is also exploring a complementary approach, developing an optional fil ABI implementation to compile Zig programs and their entire C/C++ dependency trees with runtime memory safety guarantees [1].
The proposal calls for collaboration across the Rust, Fil-C, Zig, and Nix communities to develop this solution [1]. Mikael Brockman, builder of the filnix platform, has confirmed participation in next year's OceanSprint, scheduled to take place in Lanzarote [1].