From aec4b59385e6a2d5c4bee675691b369b30ad5700 Mon Sep 17 00:00:00 2001 From: ozkanonur Date: Mon, 7 Aug 2023 08:11:14 +0300 Subject: [PATCH] add the correct version of LLVM into the stage0 sysroot In some cases(see https://github.com/rust-lang/rust/issues/109314), when the stage0 compiler relies on more recent version of LLVM than the beta compiler, it may not be able to locate the correct LLVM in the sysroot. This situation typically occurs when we upgrade LLVM version while the beta compiler continues to use an older version. Signed-off-by: ozkanonur --- src/bootstrap/compile.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 2c63ec80c3e58..899ca2a2bb99a 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -1390,6 +1390,16 @@ impl Step for Sysroot { let _ = fs::remove_dir_all(&sysroot); t!(fs::create_dir_all(&sysroot)); + // In some cases(see https://github.com/rust-lang/rust/issues/109314), when the stage0 + // compiler relies on more recent version of LLVM than the beta compiler, it may not + // be able to locate the correct LLVM in the sysroot. This situation typically occurs + // when we upgrade LLVM version while the beta compiler continues to use an older version. + // + // Make sure to add the correct version of LLVM into the stage0 sysroot. + if compiler.stage == 0 { + dist::maybe_install_llvm_target(builder, compiler.host, &sysroot); + } + // If we're downloading a compiler from CI, we can use the same compiler for all stages other than 0. if builder.download_rustc() && compiler.stage != 0 { assert_eq!(