@@ -82,7 +82,7 @@ impl Step for ToolBuild {
82
82
//
83
83
// Compiler tools should be linked in the same way as the compiler it's paired with,
84
84
// so it must be built with the previous stage compiler.
85
- self . compiler . stage -= 1
85
+ self . compiler . stage -= 1 ;
86
86
}
87
87
Mode :: ToolStd => builder. ensure ( compile:: Std :: new ( self . compiler , self . target ) ) ,
88
88
Mode :: ToolBootstrap => { }
@@ -578,107 +578,74 @@ impl Step for Rustdoc {
578
578
}
579
579
580
580
fn run ( self , builder : & Builder < ' _ > ) -> PathBuf {
581
- let target_compiler = self . compiler ;
582
- if target_compiler. stage == 0 {
583
- if !target_compiler. is_snapshot ( builder) {
581
+ let compiler = self . compiler ;
582
+ let target = compiler. host ;
583
+
584
+ if compiler. stage == 0 {
585
+ if !compiler. is_snapshot ( builder) {
584
586
panic ! ( "rustdoc in stage 0 must be snapshot rustdoc" ) ;
585
587
}
586
- return builder. initial_rustc . with_file_name ( exe ( "rustdoc" , target_compiler . host ) ) ;
588
+ return builder. initial_rustc . with_file_name ( exe ( "rustdoc" , compiler . host ) ) ;
587
589
}
588
- let target = target_compiler. host ;
589
590
590
591
let bin_rustdoc = || {
591
- let sysroot = builder. sysroot ( target_compiler ) ;
592
+ let sysroot = builder. sysroot ( compiler ) ;
592
593
let bindir = sysroot. join ( "bin" ) ;
593
594
t ! ( fs:: create_dir_all( & bindir) ) ;
594
- let bin_rustdoc = bindir. join ( exe ( "rustdoc" , target_compiler . host ) ) ;
595
+ let bin_rustdoc = bindir. join ( exe ( "rustdoc" , target ) ) ;
595
596
let _ = fs:: remove_file ( & bin_rustdoc) ;
596
597
bin_rustdoc
597
598
} ;
598
599
599
600
// If CI rustc is enabled and we haven't modified the rustdoc sources,
600
601
// use the precompiled rustdoc from CI rustc's sysroot to speed up bootstrapping.
601
602
if builder. download_rustc ( )
602
- && target_compiler . stage > 0
603
+ && compiler . stage > 0
603
604
&& builder. rust_info ( ) . is_managed_git_subrepository ( )
604
605
{
605
606
let files_to_track = & [ "src/librustdoc" , "src/tools/rustdoc" ] ;
606
607
607
608
// Check if unchanged
608
609
if builder. config . last_modified_commit ( files_to_track, "download-rustc" , true ) . is_some ( )
609
610
{
610
- let precompiled_rustdoc = builder
611
- . config
612
- . ci_rustc_dir ( )
613
- . join ( "bin" )
614
- . join ( exe ( "rustdoc" , target_compiler. host ) ) ;
611
+ let precompiled_rustdoc =
612
+ builder. config . ci_rustc_dir ( ) . join ( "bin" ) . join ( exe ( "rustdoc" , target) ) ;
615
613
616
614
let bin_rustdoc = bin_rustdoc ( ) ;
617
615
builder. copy_link ( & precompiled_rustdoc, & bin_rustdoc) ;
618
616
return bin_rustdoc;
619
617
}
620
618
}
621
619
622
- let build_compiler = if builder. download_rustc ( ) && target_compiler. stage == 1 {
623
- // We already have the stage 1 compiler, we don't need to cut the stage.
624
- builder. compiler ( target_compiler. stage , builder. config . build )
625
- } else {
626
- // Similar to `compile::Assemble`, build with the previous stage's compiler. Otherwise
627
- // we'd have stageN/bin/rustc and stageN/bin/rustdoc be effectively different stage
628
- // compilers, which isn't what we want. Rustdoc should be linked in the same way as the
629
- // rustc compiler it's paired with, so it must be built with the previous stage compiler.
630
- builder. compiler ( target_compiler. stage - 1 , builder. config . build )
631
- } ;
632
-
633
- // When using `download-rustc` and a stage0 build_compiler, copying rustc doesn't actually
634
- // build stage0 libstd (because the libstd in sysroot has the wrong ABI). Explicitly build
635
- // it.
636
- builder. ensure ( compile:: Std :: new ( build_compiler, target_compiler. host ) ) ;
637
- builder. ensure ( compile:: Rustc :: new ( build_compiler, target_compiler. host ) ) ;
638
-
639
620
// The presence of `target_compiler` ensures that the necessary libraries (codegen backends,
640
621
// compiler libraries, ...) are built. Rustdoc does not require the presence of any
641
622
// libraries within sysroot_libdir (i.e., rustlib), though doctests may want it (since
642
623
// they'll be linked to those libraries). As such, don't explicitly `ensure` any additional
643
624
// libraries here. The intuition here is that If we've built a compiler, we should be able
644
625
// to build rustdoc.
645
626
//
646
- let mut features = Vec :: new ( ) ;
627
+ let mut extra_features = Vec :: new ( ) ;
647
628
if builder. config . jemalloc {
648
- features . push ( "jemalloc" . to_string ( ) ) ;
629
+ extra_features . push ( "jemalloc" . to_string ( ) ) ;
649
630
}
650
631
651
- // NOTE: Never modify the rustflags here, it breaks the build cache for other tools!
652
- let cargo = prepare_tool_cargo (
653
- builder,
654
- build_compiler,
655
- Mode :: ToolRustc ,
632
+ let tool_rustdoc = builder. ensure ( ToolBuild {
633
+ compiler,
656
634
target,
657
- Kind :: Build ,
658
- "src/tools/rustdoc" ,
659
- SourceType :: InTree ,
660
- features. as_slice ( ) ,
661
- ) ;
662
-
663
- let _guard = builder. msg_tool (
664
- Kind :: Build ,
665
- Mode :: ToolRustc ,
666
- "rustdoc" ,
667
- build_compiler. stage ,
668
- & self . compiler . host ,
669
- & target,
670
- ) ;
671
- cargo. into_cmd ( ) . run ( builder) ;
672
-
673
635
// Cargo adds a number of paths to the dylib search path on windows, which results in
674
636
// the wrong rustdoc being executed. To avoid the conflicting rustdocs, we name the "tool"
675
637
// rustdoc a different name.
676
- let tool_rustdoc = builder
677
- . cargo_out ( build_compiler, Mode :: ToolRustc , target)
678
- . join ( exe ( "rustdoc_tool_binary" , target_compiler. host ) ) ;
638
+ tool : "rustdoc_tool_binary" ,
639
+ mode : Mode :: ToolRustc ,
640
+ path : "src/tools/rustdoc" ,
641
+ source_type : SourceType :: InTree ,
642
+ extra_features,
643
+ allow_features : "" ,
644
+ cargo_args : Vec :: new ( ) ,
645
+ } ) ;
679
646
680
647
// don't create a stage0-sysroot/bin directory.
681
- if target_compiler . stage > 0 {
648
+ if compiler . stage > 0 {
682
649
if builder. config . rust_debuginfo_level_tools == DebuginfoLevel :: None {
683
650
// Due to LTO a lot of debug info from C++ dependencies such as jemalloc can make it into
684
651
// our final binaries
@@ -903,50 +870,29 @@ impl Step for LlvmBitcodeLinker {
903
870
}
904
871
905
872
fn run ( self , builder : & Builder < ' _ > ) -> PathBuf {
906
- let bin_name = "llvm-bitcode-linker" ;
907
-
908
- // If enabled, use ci-rustc and skip building the in-tree compiler.
909
- if !builder. download_rustc ( ) {
910
- builder. ensure ( compile:: Std :: new ( self . compiler , self . compiler . host ) ) ;
911
- builder. ensure ( compile:: Rustc :: new ( self . compiler , self . target ) ) ;
912
- }
913
-
914
- let cargo = prepare_tool_cargo (
915
- builder,
916
- self . compiler ,
917
- Mode :: ToolRustc ,
918
- self . target ,
919
- Kind :: Build ,
920
- "src/tools/llvm-bitcode-linker" ,
921
- SourceType :: InTree ,
922
- & self . extra_features ,
923
- ) ;
924
-
925
- let _guard = builder. msg_tool (
926
- Kind :: Build ,
927
- Mode :: ToolRustc ,
928
- bin_name,
929
- self . compiler . stage ,
930
- & self . compiler . host ,
931
- & self . target ,
932
- ) ;
933
-
934
- cargo. into_cmd ( ) . run ( builder) ;
935
-
936
- let tool_out = builder
937
- . cargo_out ( self . compiler , Mode :: ToolRustc , self . target )
938
- . join ( exe ( bin_name, self . compiler . host ) ) ;
873
+ let bin_source = builder. ensure ( ToolBuild {
874
+ compiler : self . compiler ,
875
+ target : self . target ,
876
+ tool : "llvm-bitcode-linker" ,
877
+ mode : Mode :: ToolRustc ,
878
+ path : "src/tools/llvm-bitcode-linker" ,
879
+ source_type : SourceType :: InTree ,
880
+ extra_features : self . extra_features ,
881
+ allow_features : "" ,
882
+ cargo_args : Vec :: new ( ) ,
883
+ } ) ;
939
884
940
885
if self . compiler . stage > 0 {
941
886
let bindir_self_contained = builder
942
887
. sysroot ( self . compiler )
943
888
. join ( format ! ( "lib/rustlib/{}/bin/self-contained" , self . target. triple) ) ;
944
889
t ! ( fs:: create_dir_all( & bindir_self_contained) ) ;
945
- let bin_destination = bindir_self_contained. join ( exe ( bin_name, self . compiler . host ) ) ;
946
- builder. copy_link ( & tool_out, & bin_destination) ;
890
+ let bin_destination =
891
+ bindir_self_contained. join ( exe ( "llvm-bitcode-linker" , self . compiler . host ) ) ;
892
+ builder. copy_link ( & bin_source, & bin_destination) ;
947
893
bin_destination
948
894
} else {
949
- tool_out
895
+ bin_source
950
896
}
951
897
}
952
898
}
0 commit comments