Skip to content

Commit 6cab15c

Browse files
committed
Auto merge of #140932 - onur-ozkan:llvm-tools, r=Kobzol
update llvm-tools logic for `dist` and `install` steps First commit aligns `build_steps::compile` and `build_steps::dist` logics for copying llvm-tools, and the second commit adds the correct `should_run` condition for `LlvmTools` step as the previous one was clearly incorrect. Fixes #140913
2 parents 28174fc + 475e743 commit 6cab15c

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

src/bootstrap/src/core/build_steps/compile.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1984,17 +1984,20 @@ impl Step for Assemble {
19841984
trace!("installing `{tool}`");
19851985
let tool_exe = exe(tool, target_compiler.host);
19861986
let src_path = llvm_bin_dir.join(&tool_exe);
1987-
// When using `download-ci-llvm`, some of the tools
1988-
// may not exist, so skip trying to copy them.
1989-
if src_path.exists() {
1990-
// There is a chance that these tools are being installed from an external LLVM.
1991-
// Use `Builder::resolve_symlink_and_copy` instead of `Builder::copy_link` to ensure
1992-
// we are copying the original file not the symlinked path, which causes issues for
1993-
// tarball distribution.
1994-
//
1995-
// See https://github.com/rust-lang/rust/issues/135554.
1996-
builder.resolve_symlink_and_copy(&src_path, &libdir_bin.join(&tool_exe));
1987+
1988+
// When using `download-ci-llvm`, some of the tools may not exist, so skip trying to copy them.
1989+
if !src_path.exists() && builder.config.llvm_from_ci {
1990+
eprintln!("{} does not exist; skipping copy", src_path.display());
1991+
continue;
19971992
}
1993+
1994+
// There is a chance that these tools are being installed from an external LLVM.
1995+
// Use `Builder::resolve_symlink_and_copy` instead of `Builder::copy_link` to ensure
1996+
// we are copying the original file not the symlinked path, which causes issues for
1997+
// tarball distribution.
1998+
//
1999+
// See https://github.com/rust-lang/rust/issues/135554.
2000+
builder.resolve_symlink_and_copy(&src_path, &libdir_bin.join(&tool_exe));
19982001
}
19992002
}
20002003
}

src/bootstrap/src/core/build_steps/dist.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2274,9 +2274,9 @@ impl Step for LlvmTools {
22742274

22752275
let target = self.target;
22762276

2277-
/* run only if llvm-config isn't used */
2277+
// Run only if a custom llvm-config is not used
22782278
if let Some(config) = builder.config.target_config.get(&target) {
2279-
if let Some(ref _s) = config.llvm_config {
2279+
if !builder.config.llvm_from_ci && config.llvm_config.is_some() {
22802280
builder.info(&format!("Skipping LlvmTools ({target}): external LLVM"));
22812281
return None;
22822282
}
@@ -2294,6 +2294,12 @@ impl Step for LlvmTools {
22942294
let dst_bindir = format!("lib/rustlib/{}/bin", target.triple);
22952295
for tool in tools_to_install(&builder.paths) {
22962296
let exe = src_bindir.join(exe(tool, target));
2297+
// When using `download-ci-llvm`, some of the tools may not exist, so skip trying to copy them.
2298+
if !exe.exists() && builder.config.llvm_from_ci {
2299+
eprintln!("{} does not exist; skipping copy", exe.display());
2300+
continue;
2301+
}
2302+
22972303
tarball.add_file(&exe, &dst_bindir, FileType::Executable);
22982304
}
22992305
}

src/bootstrap/src/core/build_steps/install.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ install!((self, builder, _config),
244244
);
245245
}
246246
};
247-
LlvmTools, alias = "llvm-tools", Self::should_build(_config), only_hosts: true, {
247+
LlvmTools, alias = "llvm-tools", _config.llvm_tools_enabled && _config.llvm_enabled(_config.build), only_hosts: true, {
248248
if let Some(tarball) = builder.ensure(dist::LlvmTools { target: self.target }) {
249249
install_sh(builder, "llvm-tools", self.compiler.stage, Some(self.target), &tarball);
250250
} else {

0 commit comments

Comments
 (0)