Skip to content

Ensure lld is supported with download-ci-llvm #104748

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2067,6 +2067,9 @@ impl Step for RustDev {

builder.ensure(crate::native::Llvm { target });

// We want to package `lld` to use it with `download-ci-llvm`.
builder.ensure(crate::native::Lld { target });

let src_bindir = builder.llvm_out(target).join("bin");
// If updating this list, you likely want to change
// src/bootstrap/download-ci-llvm-stamp as well, otherwise local users
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/download-ci-llvm-stamp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Change this file to make users of the `download-ci-llvm` configuration download
a new version of LLVM from CI, even if the LLVM submodule hasn’t changed.

Last change is for: https://github.com/rust-lang/rust/pull/102790
Last change is for: https://github.com/rust-lang/rust/pull/104748
31 changes: 22 additions & 9 deletions src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ impl LdFlags {
}
}

// 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,
Expand Down Expand Up @@ -823,8 +823,21 @@ impl Step for Lld {
}
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");
Expand Down