X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fbootstrap%2Fnative.rs;h=781a738a81196877582a4b34daa4f43d109bdf8a;hb=752c0f57ea4c8d9acb61adec4bfdf4d0c8b81c6b;hp=4e503dfe864e2937eca0461125effb8147739ff1;hpb=8b3d0c4cf9f8a8b77805ee5b9bcd18d02c600f22;p=rust.git diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 4e503dfe864..781a738a811 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -63,13 +63,13 @@ fn push_all(&mut self, s: impl AsRef) { } } -// This returns whether we've already previously built LLVM. -// -// It's used to avoid busting caches during x.py check -- if we've already built -// LLVM, it's fine for us to not try to avoid doing so. -// -// This will return the llvm-config if it can get it (but it will not build it -// if not). +/// This returns whether we've already previously built LLVM. +/// +/// It's used to avoid busting caches during x.py check -- if we've already built +/// LLVM, it's fine for us to not try to avoid doing so. +/// +/// This will return the llvm-config if it can get it (but it will not build it +/// if not). pub fn prebuilt_llvm_config( builder: &Builder<'_>, target: TargetSelection, @@ -823,8 +823,21 @@ fn run(self, builder: &Builder<'_>) -> PathBuf { } let target = self.target; - let LlvmResult { llvm_config, llvm_cmake_dir } = - builder.ensure(Llvm { target: self.target }); + let LlvmResult { llvm_config, llvm_cmake_dir } = builder.ensure(Llvm { target }); + + // The `dist` step packages LLD next to LLVM's binaries for download-ci-llvm. The root path + // we usually expect here is `./build/$triple/ci-llvm/`, with the binaries in its `bin` + // subfolder. We check if that's the case, and if LLD's binary already exists there next to + // `llvm-config`: if so, we can use it instead of building LLVM/LLD from source. + let ci_llvm_bin = llvm_config.parent().unwrap(); + if ci_llvm_bin.is_dir() && ci_llvm_bin.file_name().unwrap() == "bin" { + let lld_path = ci_llvm_bin.join(exe("lld", target)); + if lld_path.exists() { + // The following steps copying `lld` as `rust-lld` to the sysroot, expect it in the + // `bin` subfolder of this step's out dir. + return ci_llvm_bin.parent().unwrap().to_path_buf(); + } + } let out_dir = builder.lld_out(target); let done_stamp = out_dir.join("lld-finished-building");