This is useful when changing code in rustc_codegen_cranelift as part of changing main Rust repository. This can happen, for example, when you are implementing a new compiler intrinsic.
Instruction below uses $RustCheckoutDir as substitute for any folder where you cloned Rust repository.
You need to do this steps to successfully compile and use the cranelift backend with your changes in rustc code:
cd $RustCheckoutDirpython x.py setup and choose option for compiler (b).python x.py build --stage=2 compiler library/std src/tools/rustdoc src/tools/rustfmtsrc/tools/cargo to previous command.cp $(rustup +nightly which cargo) ./build/host/stage2/bin/cargo. Note that you would need to do this every time you rebuilt rust repository.rustc to toolchain: rustup toolchain link stage2 ./build/host/stage2/.rustc +stage2 -O build_system/main.rs -o y.exe../y.sh (or y if you built build_system/main.rs as y) command by rustup run stage2 to make cg_clif use your local changes in rustc.rustup run stage2 ./y.sh preparerustup run stage2 ./y.sh buildrustup run stage2 ./y.sh test$RustCheckoutDir/compiler/rustc_codegen_cranelift/dist/cargo-clif build --release.You can also set rust-analyzer.rustc.source to your rust workspace to get rust-analyzer to understand your changes.