about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2021-12-09 05:08:34 +0100
committerGitHub <noreply@github.com>2021-12-09 05:08:34 +0100
commitab92eca61248f89cd1355690f49e32fcb1708d80 (patch)
treeda8890b541689eb48a50771a02bd4407340eaca5
parent8c94b2c375d89d55787d3f97e6080c9d164e8414 (diff)
parent9bcbc58eba8563e6b829941d65c42a24476e7048 (diff)
downloadrust-ab92eca61248f89cd1355690f49e32fcb1708d80.tar.gz
rust-ab92eca61248f89cd1355690f49e32fcb1708d80.zip
Rollup merge of #91685 - Aaron1011:install-llvm-tools, r=Mark-Simulacrum
Install llvm tools to sysroot when assembling local toolchain

Some projects (e.g. the `bootimage` crate) may require the
user to install the `llvm-tools-preview` rustup component.
However, this cannot be easily done with a locally built toolchain.

To allow a local toolchain to be used a drop-in replacement for
a normal rustup toolchain in more cases, this PR copies the built
LLVM tools to the sysoot. From the perspective a tool looking
at the sysroot, this is equivalent to installing `llvm-tools-preview`.
-rw-r--r--src/bootstrap/compile.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
index 007ca9f7f5a..186b5e92d33 100644
--- a/src/bootstrap/compile.rs
+++ b/src/bootstrap/compile.rs
@@ -28,6 +28,7 @@ use crate::dist;
 use crate::native;
 use crate::tool::SourceType;
 use crate::util::{exe, is_debug_info, is_dylib, symlink_dir};
+use crate::LLVM_TOOLS;
 use crate::{Compiler, DependencyType, GitRepo, Mode};
 
 #[derive(Debug, PartialOrd, Ord, Copy, Clone, PartialEq, Eq, Hash)]
@@ -1164,6 +1165,16 @@ impl Step for Assemble {
                 let llvm_bin_dir = output(Command::new(llvm_config_bin).arg("--bindir"));
                 let llvm_bin_dir = Path::new(llvm_bin_dir.trim());
                 builder.copy(&llvm_bin_dir.join(&src_exe), &libdir_bin.join(&dst_exe));
+
+                // Since we've already built the LLVM tools, install them to the sysroot.
+                // This is the equivalent of installing the `llvm-tools-preview` component via
+                // rustup, and lets developers use a locally built toolchain to
+                // build projects that expect llvm tools to be present in the sysroot
+                // (e.g. the `bootimage` crate).
+                for tool in LLVM_TOOLS {
+                    let tool_exe = exe(tool, target_compiler.host);
+                    builder.copy(&llvm_bin_dir.join(&tool_exe), &libdir_bin.join(&tool_exe));
+                }
             }
         }