From f8b3c566cc9b27816efa17a21365d36dd55cd71f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Tue, 12 Aug 2025 11:47:26 +0200 Subject: [PATCH] Refactor and document the `DebuggerScripts` dist step --- src/bootstrap/src/core/build_steps/dist.rs | 23 +++++++++++----------- src/bootstrap/src/core/build_steps/test.rs | 2 +- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index 78154b62f16a..29e4a608c3ae 100644 --- a/src/bootstrap/src/core/build_steps/dist.rs +++ b/src/bootstrap/src/core/build_steps/dist.rs @@ -458,7 +458,7 @@ impl Step for Rustc { return tarball.generate(); fn prepare_image(builder: &Builder<'_>, target_compiler: Compiler, image: &Path) { - let host = target_compiler.host; + let target = target_compiler.host; let src = builder.sysroot(target_compiler); // Copy rustc binary @@ -517,14 +517,14 @@ impl Step for Rustc { // components like the llvm tools and LLD. LLD is included below and // tools/LLDB come later, so let's just throw it in the rustc // component for now. - maybe_install_llvm_runtime(builder, host, image); + maybe_install_llvm_runtime(builder, target, image); - let dst_dir = image.join("lib/rustlib").join(host).join("bin"); + let dst_dir = image.join("lib/rustlib").join(target).join("bin"); t!(fs::create_dir_all(&dst_dir)); // Copy over lld if it's there if builder.config.lld_enabled { - let src_dir = builder.sysroot_target_bindir(target_compiler, host); + let src_dir = builder.sysroot_target_bindir(target_compiler, target); let rust_lld = exe("rust-lld", target_compiler.host); builder.copy_link( &src_dir.join(&rust_lld), @@ -547,7 +547,7 @@ impl Step for Rustc { if builder.config.llvm_enabled(target_compiler.host) && builder.config.llvm_tools_enabled { - let src_dir = builder.sysroot_target_bindir(target_compiler, host); + let src_dir = builder.sysroot_target_bindir(target_compiler, target); let llvm_objcopy = exe("llvm-objcopy", target_compiler.host); let rust_objcopy = exe("rust-objcopy", target_compiler.host); builder.copy_link( @@ -558,7 +558,7 @@ impl Step for Rustc { } if builder.tool_enabled("wasm-component-ld") { - let src_dir = builder.sysroot_target_bindir(target_compiler, host); + let src_dir = builder.sysroot_target_bindir(target_compiler, target); let ld = exe("wasm-component-ld", target_compiler.host); builder.copy_link(&src_dir.join(&ld), &dst_dir.join(&ld), FileType::Executable); } @@ -580,7 +580,7 @@ impl Step for Rustc { } // Debugger scripts - builder.ensure(DebuggerScripts { sysroot: image.to_owned(), host }); + builder.ensure(DebuggerScripts { sysroot: image.to_owned(), target }); // HTML copyright files let file_list = builder.ensure(super::run::GenerateCopyright); @@ -610,10 +610,12 @@ impl Step for Rustc { } } +/// Copies debugger scripts for `target` into the given compiler `sysroot`. #[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct DebuggerScripts { + /// Sysroot of a compiler into which will the debugger scripts be copied to. pub sysroot: PathBuf, - pub host: TargetSelection, + pub target: TargetSelection, } impl Step for DebuggerScripts { @@ -623,16 +625,15 @@ impl Step for DebuggerScripts { run.never() } - /// Copies debugger scripts for `target` into the `sysroot` specified. fn run(self, builder: &Builder<'_>) { - let host = self.host; + let target = self.target; let sysroot = self.sysroot; let dst = sysroot.join("lib/rustlib/etc"); t!(fs::create_dir_all(&dst)); let cp_debugger_script = |file: &str| { builder.install(&builder.src.join("src/etc/").join(file), &dst, FileType::Regular); }; - if host.contains("windows-msvc") { + if target.contains("windows-msvc") { // windbg debugger scripts builder.install( &builder.src.join("src/etc/rust-windbg.cmd"), diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index ef7bdbbcddc9..318287df08a2 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -1719,7 +1719,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the if suite == "debuginfo" { builder.ensure(dist::DebuggerScripts { sysroot: builder.sysroot(compiler).to_path_buf(), - host: target, + target, }); } if suite == "run-make" {