A Rust Compiler Written in Pure C Emerges from Years of Stealth Work 🔗
The project demonstrates a novel toolchain that translates Rust code into portable C for arbitrary targets, including self-hosting.
Why this leads today Translating rustc to C expands access to Rust’s performance and safety in constrained environments, enabling practical deployment where full Rust toolchains were previously impractical.
In a quiet corner of GitHub, a developer known as FractalFir has pushed a project that is turning heads in the systems programming community: crustc, a full translation of the Rust compiler rustc into 46 million lines of standard C code. This isn’t a wrapper or a fork—it’s the output of a multi-year effort to build a Rust-to-C compiler toolchain called cilly. The result is a functional rustc that can be built with nothing more than a C compiler (like GCC or Clang), make, and a link to LLVM, enabling developers to compile Rust code on platforms where a native Rust toolchain might be impractical or unavailable.
The significance lies not just in the novelty of a C-based Rust compiler, but in what it represents for the cilly toolchain itself. As described in the project’s README, cilly is both a Rust library for generating C code and a rustc backend plugin. Its core innovation is adaptability: rather than assuming a specific C compiler or platform, cilly generates “witness” programs—small C snippets that probe the target compiler’s capabilities, such as support for _Thread_local or the size of fundamental types. This allows the generated C code to be tailored to quirky or constrained environments, from embedded systems to obscure operating systems, making the Rust compiler far more portable than its standard distribution.
What makes this particularly compelling is the self-hosting demonstration. The crustc repository doesn’t just claim to work—it shows the translated compiler building Rust’s standard library (core, alloc, std) and even compiling itself. This bootstrap process validates that the C-generated code is not only correct but robust enough to handle the complexities of a modern compiler. For developers working on niche hardware, legacy systems, or platforms with strict toolchain constraints, this approach offers a path to run Rust without relying on pre-built binaries or complex cross-compilation setups.
The project’s rapid traction—357 stars in just six days—speaks to a latent demand for greater flexibility in how Rust is deployed. It challenges the assumption that Rust must always be compiled via its official toolchain and opens the door to Rust adoption in environments where the current toolchain is a barrier.
The catch: While the project proves the concept works for self-hosting and standard library compilation, it remains an early-stage demonstration; the generated C code is massive (46 million lines), build times are likely prohibitive for iterative development, and there’s no evidence yet that the toolchain scales to large, real-world applications beyond compiler bootstrapping.
Source: FractalFir/crustc — based on the project README.