Using cranelift to compile rustc

I've figured out how to use cranelift to compile regular cargo projects, but rustc itself has its own build system (bootstrap), so it's not quite so easy.

are there any existing resources on how to configure bootstrap to use cranelift?

I don't think that's a good idea; rustc is compiled twice for bootstrapping and compiling rustc with rustc built with cranelift will probably be very slow. rustc always build with optimizations for the same reason.

3 Likes

ehh, it's more complicated than that, rustc will be built anywhere between 0 and 3 times depending on several factors, such as what stage you're building [1], and whether download-rustc is enabled.

honestly i don't really want to build rustc with cranelift as much as i want to use it to build bootstrap, rustfmt, and various unit tests.


  1. most compiler devs just use stage1, stage2 is mostly for bors and distribution tarballs ↩︎

This is the config I use to test bootstrapping rustc using cg_clif: rustc_codegen_cranelift/scripts/setup_rust_fork.sh at 147ac7ad5dd30a68a23e7abc23abe5691b7897b9 · rust-lang/rustc_codegen_cranelift · GitHub Just be aware that rustc compiled using cg_clif is about 15x slower than rustc compiled using cg_llvm in release mode. This makes it significantly slower for stage1 to build stage2

9 Likes