Bootstrapping Rust with GCC If you know one thing about me, it is that I love working on the Rust compiler. Some people kayak, travel or play guitar - and I stare at assembly, trying to figure out what I broke. This summer, I am taking on quite a large task: bootstrapping the Rust compiler using `cg_gcc` What does that mean? "bootstrapping" is simply a name given to the Rust compiler build process. So, what I am really trying to do is build a Rust compiler, without using LLVM - and using GCC instead. The bootstrap process is quite complex, and split into 3 stages. Stage 1 First, we use a pre-existing, LLVM-based Rust compiler to build rustc, and the GCC-based codegen. Stage 2 Then, we take that GCC-based codegen, and rebuild the Rust compiler using GCC. Stage 3 As a sanity check, we built the compiler *again*, this time using stage2. The idea here is quite simple: if stage1 and stage2 produce identical executables, then they behave identically, which means the rust compiler build with GCC is (more or less) equivalent to the one built with LLVM. Of course, a lot of this is a gross oversimplification, but you should get the gist. Getting to the stage3 is a big milestone - and the goal of my GSoC project. The 3 little buglets You may be asking: what is preventing us from building a working stage 3 build right now? Usually, I would answer this question with something akin to "If knew what bugs we had, I would have fixed them already". However, this is a rare case, where I knew exactly what bugs I needed to fix. How could I know that? Via the advanced debugging technique I dubbed "Giving the compiler a lobotomy". Lobotomizing ferris Some of the bugs I presented had some pretty clear symptoms: libgcccjit(the library we use to interface with GCC) would show errors, complaining about some sort of IR issue. It would then abort the build, and give me the name of the problematic crate. Compiling rustix v0.38.44 libgccjit.so: error: : gcc_jit_block_add_assignment: mismatching t...
First seen: 2025-07-06 22:25
Last seen: 2025-07-07 16:27