Skip to content

Commit 14d50bf

Browse files
committed
Allow some tools to be run without first building LLVM.
Conservatively only disable LLVM for rust-installer. This should shave 5 minutes from the x86_64-gnu-distcheck job by not building LLVM twice.
1 parent 61d8831 commit 14d50bf

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

src/bootstrap/tool.rs

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ pub fn prepare_tool_cargo(
254254
}
255255

256256
macro_rules! tool {
257-
($($name:ident, $path:expr, $tool_name:expr, $mode:expr;)+) => {
257+
($($name:ident, $path:expr, $tool_name:expr, $mode:expr $(,llvm_tools = $llvm:expr)*;)+) => {
258258
#[derive(Copy, Clone)]
259259
pub enum Tool {
260260
$(
@@ -269,6 +269,13 @@ macro_rules! tool {
269269
};
270270
mode
271271
}
272+
273+
/// Whether this tool requires LLVM to run
274+
pub fn uses_llvm_tools(&self) -> bool {
275+
match self {
276+
$(Tool::$name => true $(&& $llvm)*,)+
277+
}
278+
}
272279
}
273280

274281
impl<'a> Builder<'a> {
@@ -343,7 +350,7 @@ tool!(
343350
Compiletest, "src/tools/compiletest", "compiletest", Mode::ToolTest;
344351
BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::ToolStd;
345352
RemoteTestClient, "src/tools/remote-test-client", "remote-test-client", Mode::ToolStd;
346-
RustInstaller, "src/tools/rust-installer", "fabricate", Mode::ToolStd;
353+
RustInstaller, "src/tools/rust-installer", "fabricate", Mode::ToolStd, llvm_tools = false;
347354
RustdocTheme, "src/tools/rustdoc-themes", "rustdoc-themes", Mode::ToolStd;
348355
);
349356

@@ -586,19 +593,19 @@ impl<'a> Builder<'a> {
586593
pub fn tool_cmd(&self, tool: Tool) -> Command {
587594
let mut cmd = Command::new(self.tool_exe(tool));
588595
let compiler = self.compiler(self.tool_default_stage(tool), self.config.build);
589-
self.prepare_tool_cmd(compiler, tool.get_mode(), &mut cmd);
596+
self.prepare_tool_cmd(compiler, tool, &mut cmd);
590597
cmd
591598
}
592599

593600
/// Prepares the `cmd` provided to be able to run the `compiler` provided.
594601
///
595602
/// Notably this munges the dynamic library lookup path to point to the
596603
/// right location to run `compiler`.
597-
fn prepare_tool_cmd(&self, compiler: Compiler, mode: Mode, cmd: &mut Command) {
604+
fn prepare_tool_cmd(&self, compiler: Compiler, tool: Tool, cmd: &mut Command) {
598605
let host = &compiler.host;
599606
let mut lib_paths: Vec<PathBuf> = vec![
600607
PathBuf::from(&self.sysroot_libdir(compiler, compiler.host)),
601-
self.cargo_out(compiler, mode, *host).join("deps"),
608+
self.cargo_out(compiler, tool.get_mode(), *host).join("deps"),
602609
];
603610

604611
// On MSVC a tool may invoke a C compiler (e.g. compiletest in run-make
@@ -621,17 +628,19 @@ impl<'a> Builder<'a> {
621628

622629
// Add the llvm/bin directory to PATH since it contains lots of
623630
// useful, platform-independent tools
624-
if let Some(llvm_bin_path) = self.llvm_bin_path() {
625-
if host.contains("windows") {
626-
// On Windows, PATH and the dynamic library path are the same,
627-
// so we just add the LLVM bin path to lib_path
628-
lib_paths.push(llvm_bin_path);
629-
} else {
630-
let old_path = env::var_os("PATH").unwrap_or_default();
631-
let new_path = env::join_paths(iter::once(llvm_bin_path)
632-
.chain(env::split_paths(&old_path)))
633-
.expect("Could not add LLVM bin path to PATH");
634-
cmd.env("PATH", new_path);
631+
if tool.uses_llvm_tools() {
632+
if let Some(llvm_bin_path) = self.llvm_bin_path() {
633+
if host.contains("windows") {
634+
// On Windows, PATH and the dynamic library path are the same,
635+
// so we just add the LLVM bin path to lib_path
636+
lib_paths.push(llvm_bin_path);
637+
} else {
638+
let old_path = env::var_os("PATH").unwrap_or_default();
639+
let new_path = env::join_paths(iter::once(llvm_bin_path)
640+
.chain(env::split_paths(&old_path)))
641+
.expect("Could not add LLVM bin path to PATH");
642+
cmd.env("PATH", new_path);
643+
}
635644
}
636645
}
637646

0 commit comments

Comments
 (0)