@@ -254,7 +254,7 @@ pub fn prepare_tool_cargo(
254
254
}
255
255
256
256
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 ) * ; ) +) => {
258
258
#[ derive( Copy , Clone ) ]
259
259
pub enum Tool {
260
260
$(
@@ -269,6 +269,13 @@ macro_rules! tool {
269
269
} ;
270
270
mode
271
271
}
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
+ }
272
279
}
273
280
274
281
impl <' a> Builder <' a> {
@@ -333,6 +340,9 @@ macro_rules! tool {
333
340
}
334
341
}
335
342
343
+ // FIXME(#51459): We have only checked that RustInstaller does not require
344
+ // the LLVM binaries when running. We should go through all tools to determine
345
+ // if they really need LLVM binaries, and make `llvm_tools` a required argument.
336
346
tool ! (
337
347
Rustbook , "src/tools/rustbook" , "rustbook" , Mode :: ToolRustc ;
338
348
ErrorIndex , "src/tools/error_index_generator" , "error_index_generator" , Mode :: ToolRustc ;
@@ -343,7 +353,7 @@ tool!(
343
353
Compiletest , "src/tools/compiletest" , "compiletest" , Mode :: ToolTest ;
344
354
BuildManifest , "src/tools/build-manifest" , "build-manifest" , Mode :: ToolStd ;
345
355
RemoteTestClient , "src/tools/remote-test-client" , "remote-test-client" , Mode :: ToolStd ;
346
- RustInstaller , "src/tools/rust-installer" , "fabricate" , Mode :: ToolStd ;
356
+ RustInstaller , "src/tools/rust-installer" , "fabricate" , Mode :: ToolStd , llvm_tools = false ;
347
357
RustdocTheme , "src/tools/rustdoc-themes" , "rustdoc-themes" , Mode :: ToolStd ;
348
358
) ;
349
359
@@ -586,19 +596,19 @@ impl<'a> Builder<'a> {
586
596
pub fn tool_cmd ( & self , tool : Tool ) -> Command {
587
597
let mut cmd = Command :: new ( self . tool_exe ( tool) ) ;
588
598
let compiler = self . compiler ( self . tool_default_stage ( tool) , self . config . build ) ;
589
- self . prepare_tool_cmd ( compiler, tool. get_mode ( ) , & mut cmd) ;
599
+ self . prepare_tool_cmd ( compiler, tool, & mut cmd) ;
590
600
cmd
591
601
}
592
602
593
603
/// Prepares the `cmd` provided to be able to run the `compiler` provided.
594
604
///
595
605
/// Notably this munges the dynamic library lookup path to point to the
596
606
/// right location to run `compiler`.
597
- fn prepare_tool_cmd ( & self , compiler : Compiler , mode : Mode , cmd : & mut Command ) {
607
+ fn prepare_tool_cmd ( & self , compiler : Compiler , tool : Tool , cmd : & mut Command ) {
598
608
let host = & compiler. host ;
599
609
let mut lib_paths: Vec < PathBuf > = vec ! [
600
610
PathBuf :: from( & self . sysroot_libdir( compiler, compiler. host) ) ,
601
- self . cargo_out( compiler, mode , * host) . join( "deps" ) ,
611
+ self . cargo_out( compiler, tool . get_mode ( ) , * host) . join( "deps" ) ,
602
612
] ;
603
613
604
614
// On MSVC a tool may invoke a C compiler (e.g. compiletest in run-make
@@ -621,17 +631,19 @@ impl<'a> Builder<'a> {
621
631
622
632
// Add the llvm/bin directory to PATH since it contains lots of
623
633
// 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) ;
634
+ if tool. uses_llvm_tools ( ) {
635
+ if let Some ( llvm_bin_path) = self . llvm_bin_path ( ) {
636
+ if host. contains ( "windows" ) {
637
+ // On Windows, PATH and the dynamic library path are the same,
638
+ // so we just add the LLVM bin path to lib_path
639
+ lib_paths. push ( llvm_bin_path) ;
640
+ } else {
641
+ let old_path = env:: var_os ( "PATH" ) . unwrap_or_default ( ) ;
642
+ let new_path = env:: join_paths ( iter:: once ( llvm_bin_path)
643
+ . chain ( env:: split_paths ( & old_path) ) )
644
+ . expect ( "Could not add LLVM bin path to PATH" ) ;
645
+ cmd. env ( "PATH" , new_path) ;
646
+ }
635
647
}
636
648
}
637
649
0 commit comments