@@ -239,9 +239,10 @@ pub struct Build {
239
239
hosts : Vec < Interned < String > > ,
240
240
targets : Vec < Interned < String > > ,
241
241
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
243
243
initial_rustc : PathBuf ,
244
244
initial_cargo : PathBuf ,
245
+ initial_lld : PathBuf ,
245
246
246
247
// Runtime state filled in later on
247
248
// C/C++ compilers and archiver for all targets
@@ -343,9 +344,18 @@ impl Build {
343
344
// we always try to use git for LLVM builds
344
345
let in_tree_llvm_info = channel:: GitInfo :: new ( false , & src. join ( "src/llvm-project" ) ) ;
345
346
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
+
346
355
let mut build = Build {
347
356
initial_rustc : config. initial_rustc . clone ( ) ,
348
357
initial_cargo : config. initial_cargo . clone ( ) ,
358
+ initial_lld,
349
359
local_rebuild : config. local_rebuild ,
350
360
fail_fast : config. cmd . fail_fast ( ) ,
351
361
doc_tests : config. cmd . doc_tests ( ) ,
@@ -810,7 +820,7 @@ impl Build {
810
820
}
811
821
812
822
/// 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 > {
814
824
if let Some ( linker) = self . config . target_config . get ( & target) . and_then ( |c| c. linker . as_ref ( ) )
815
825
{
816
826
Some ( linker)
@@ -819,6 +829,12 @@ impl Build {
819
829
&& !target. contains ( "msvc" )
820
830
{
821
831
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 )
822
838
} else {
823
839
None
824
840
}
0 commit comments