Skip to content

Commit 835b58d

Browse files
committed
make the native::LLD step able to use an already built lld
Makes the lld step avoid building it from source when possible: when dist has packaged it along the other LLVM binaries for the rust-dev component.
1 parent 6eb205d commit 835b58d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/bootstrap/native.rs

+14
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,20 @@ impl Step for Lld {
826826
let LlvmResult { llvm_config, llvm_cmake_dir } =
827827
builder.ensure(Llvm { target: self.target });
828828

829+
// The `dist` step packages LLD next to LLVM's binaries for download-ci-llvm. The root path
830+
// we usually expect here is `./build/$triple/ci-llvm/`, with the binaries in its `bin`
831+
// subfolder. We check if that's the case, and if LLD's binary already exists there next to
832+
// `llvm-config`: if so, we can use it instead of building LLVM/LLD from source.
833+
let ci_llvm_bin = llvm_config.parent().unwrap();
834+
if ci_llvm_bin.is_dir() && ci_llvm_bin.file_name().unwrap() == "bin" {
835+
let lld_path = ci_llvm_bin.join(exe("lld", target));
836+
if lld_path.exists() {
837+
// The following steps copying `lld` as `rust-lld` to the sysroot, expect it in the
838+
// `bin` subfolder of this step's out dir.
839+
return ci_llvm_bin.parent().unwrap().to_path_buf();
840+
}
841+
}
842+
829843
let out_dir = builder.lld_out(target);
830844
let done_stamp = out_dir.join("lld-finished-building");
831845
if done_stamp.exists() {

0 commit comments

Comments
 (0)