@@ -239,9 +239,10 @@ pub struct Build {
239239 hosts : Vec < Interned < String > > ,
240240 targets : Vec < Interned < String > > ,
241241
242- // Stage 0 (downloaded) compiler and cargo or their local rust equivalents
242+ // Stage 0 (downloaded) compiler, lld and cargo or their local rust equivalents
243243 initial_rustc : PathBuf ,
244244 initial_cargo : PathBuf ,
245+ initial_lld : PathBuf ,
245246
246247 // Runtime state filled in later on
247248 // C/C++ compilers and archiver for all targets
@@ -343,9 +344,18 @@ impl Build {
343344 // we always try to use git for LLVM builds
344345 let in_tree_llvm_info = channel:: GitInfo :: new ( false , & src. join ( "src/llvm-project" ) ) ;
345346
347+ let initial_sysroot = config. initial_rustc . parent ( ) . unwrap ( ) . parent ( ) . unwrap ( ) ;
348+ let initial_lld = initial_sysroot
349+ . join ( "lib" )
350+ . join ( "rustlib" )
351+ . join ( config. build )
352+ . join ( "bin" )
353+ . join ( "rust-lld" ) ;
354+
346355 let mut build = Build {
347356 initial_rustc : config. initial_rustc . clone ( ) ,
348357 initial_cargo : config. initial_cargo . clone ( ) ,
358+ initial_lld,
349359 local_rebuild : config. local_rebuild ,
350360 fail_fast : config. cmd . fail_fast ( ) ,
351361 doc_tests : config. cmd . doc_tests ( ) ,
@@ -810,7 +820,7 @@ impl Build {
810820 }
811821
812822 /// Returns the path to the linker for the given target if it needs to be overridden.
813- fn linker ( & self , target : Interned < String > ) -> Option < & Path > {
823+ fn linker ( & self , target : Interned < String > , can_use_lld : bool ) -> Option < & Path > {
814824 if let Some ( linker) = self . config . target_config . get ( & target) . and_then ( |c| c. linker . as_ref ( ) )
815825 {
816826 Some ( linker)
@@ -819,6 +829,12 @@ impl Build {
819829 && !target. contains ( "msvc" )
820830 {
821831 Some ( self . cc ( target) )
832+ } else if can_use_lld
833+ && self . config . use_lld
834+ && target. contains ( "pc-windows-msvc" )
835+ && self . build == target
836+ {
837+ Some ( & self . initial_lld )
822838 } else {
823839 None
824840 }
0 commit comments