Summary Of How Fil-C Works (With Links)
Fil-C achieves memory safety for C and C++ code by transforming all unsafe operations in LLVM IR into code that does dynamic checking to catch all violations of Fil-C’s rules (
fil-c.org/compiler). Most of that is about transforming all operations involving `ptr` type to use InvisiCaps (
fil-c.org/invisicaps).
I’ve also written about InvisiCaps using examples of issues that this catches (
fil-c.org/invisicaps_by_exam…) and by doing a deep dive into the disassembly of a simple program (
fil-c.org/compiler_example).
InvisiCaps could work with a variety of memory management schemes, including sufficiently segregated malloc/free. However, they can produce the best guarantees with a GC. GC allows the `free()` operation to deterministically and atomically disable all pointers to the memory that was freed, so use after free, invalid free, and double free are all guaranteed to panic. (
fil-c.org/fugc).
All C implementations rely on a runtime that provides helper functions for those operations that are just heavy enough to warrant outlining. Fil-C differs in that its runtime is bigger and involves a different ABI from Yolo-C (
fil-c.org/runtime). The runtime’s job is also to provide a safepoint mechanism to support accurate GC and safe signal handling (
fil-c.org/safepoints).
Despite the fact that Fil-C’s implementation strategy differs from Yolo-C’s, it’s possible to compile most C and C++ programs with Fil-C and they will work great with zero or minimal changes (
fil-c.org/programs_that_work).
Because Fil-C is not ABI compatible with Yolo-C, installing Fil-C means installing a new ABI slice. Multiple approaches to this exist. The original approach I developed to get my own development bootstrapped is the pizfix (Pizlo’s prefix), which puts all Fil-C libraries into a local directory and the compiler knows to default to that directory for headers and libraries (
fil-c.org/pizfix). A much more comprehensive approach is to just recompile all of the Linux userland (
fil-c.org/pizlix). My favorite way to install Fil-C is the /opt/fil distribution. I’m currently working on making this include more programs and libraries. You should install this if you want to run a memory safe SSH server (
fil-c.org/optfil). Folks have started to contribute their own Fil-C distributions.
@meekaale created a Nix package of the Fil-C compiler, called Filnix (
github.com/mbrock/filnix).
@hashbreaker has a lot of notes about using Fil-C including scripts to set up Filian - Debian with a Fil-C variant (
cr.yp.to/2025/fil-c.html).
Finally, Fil-C exposes a lot of power that you won’t get in Yolo-C, like for introspecting pointer capabilities and using advanced GC features. That api is easy to include and well documented (
fil-c.org/stdfil).
Hope this helps you get started on your memory safe C and C++ journey!