According to bjorn3's article from a couple of years ago, this used to work. However, if you try compiling rustc with the following bootstrap.toml right now it fails to compile stage0 library artifacts. I saw this issue mentioned in a random rust PR but it seems like no one ever found a solution. Any ideas? I could also bring this up on GitHub if needed.
[build]
full-bootstrap = true
[rust]
codegen-backends = ["cranelift"]
python3 x.py build --stage 2
Building stage1 library artifacts (x86_64-unknown-linux-gnu)
Compiling compiler_builtins v0.1.158
Compiling core v0.0.0 (/root/rust/library/core)
Compiling libc v0.2.172
Compiling object v0.36.7
Compiling std v0.0.0 (/root/rust/library/std)
Compiling rustc-std-workspace-core v1.99.0 (/root/rust/library/rustc-std-workspace-core)
error: unsupported builtin codegen backend `llvm`
error: unsupported builtin codegen backend `llvm`
error: unsupported builtin codegen backend `llvm`
error: unsupported builtin codegen backend `llvm`
error: unsupported builtin codegen backend `llvm`
error: unsupported builtin codegen backend `llvm`
Compiling alloc v0.0.0 (/root/rust/library/alloc)
error: Failed to assemble `.globl __inline_asm_compiler_builtins__49d4216c53098d11_cgu__002_n0
.type __inline_asm_compiler_builtins__49d4216c53098d11_cgu__002_n0,@function
.section .text.__inline_asm_compiler_builtins__49d4216c53098d11_cgu__002_n0,"ax",@progbits
__inline_asm_compiler_builtins__49d4216c53098d11_cgu__002_n0:
.intel_syntax noprefix
push rbp
mov rbp,rsp
push rbx
mov rbx,rdi
movups xmm0, [rbx+0x0]
movups xmm1, [rbx+0x10]
movups xmm2, [rbx+0x20]
vfmadd213sd xmm0, xmm1, xmm2
movups [rbx+0x0], xmm0
pop rbx
pop rbp
ret
.att_syntax
.size __inline_asm_compiler_builtins__49d4216c53098d11_cgu__002_n0, .-__inline_asm_compiler_builtins__49d4216c53098d11_cgu__002_n0
.text
.......