@@ -738,27 +738,28 @@ impl Config {
738738 ) ;
739739 }
740740
741+ let mut dwn_ctx = DownloadContext :: new (
742+ path_modification_cache. clone ( ) ,
743+ & src,
744+ rust_info. clone ( ) ,
745+ & submodules,
746+ download_rustc_commit. clone ( ) ,
747+ host_target,
748+ llvm_from_ci,
749+ target_config. clone ( ) ,
750+ out. clone ( ) ,
751+ patch_binaries_for_nix,
752+ & exec_ctx,
753+ & stage0_metadata,
754+ llvm_assertions,
755+ & bootstrap_cache_path,
756+ is_running_on_ci,
757+ ) ;
758+
741759 let initial_rustc = if let Some ( rustc) = build_rustc {
742760 rustc
743761 } else {
744- let dwn_ctx = DownloadContext :: new (
745- path_modification_cache. clone ( ) ,
746- & src,
747- & rust_info,
748- & submodules,
749- & download_rustc_commit,
750- host_target,
751- llvm_from_ci,
752- & target_config,
753- & out,
754- patch_binaries_for_nix,
755- & exec_ctx,
756- & stage0_metadata,
757- llvm_assertions,
758- & bootstrap_cache_path,
759- is_running_on_ci,
760- ) ;
761- download_beta_toolchain ( dwn_ctx) ;
762+ download_beta_toolchain ( & dwn_ctx) ;
762763 out. join ( host_target) . join ( "stage0" ) . join ( "bin" ) . join ( exe ( "rustc" , host_target) )
763764 } ;
764765
@@ -776,24 +777,7 @@ impl Config {
776777 let initial_cargo = if let Some ( cargo) = build_cargo {
777778 cargo
778779 } else {
779- let dwn_ctx = DownloadContext :: new (
780- path_modification_cache. clone ( ) ,
781- & src,
782- & rust_info,
783- & submodules,
784- & download_rustc_commit,
785- host_target,
786- llvm_from_ci,
787- & target_config,
788- & out,
789- patch_binaries_for_nix,
790- & exec_ctx,
791- & stage0_metadata,
792- llvm_assertions,
793- & bootstrap_cache_path,
794- is_running_on_ci,
795- ) ;
796- download_beta_toolchain ( dwn_ctx) ;
780+ download_beta_toolchain ( & dwn_ctx) ;
797781 initial_sysroot. join ( "bin" ) . join ( exe ( "cargo" , host_target) )
798782 } ;
799783
@@ -802,6 +786,7 @@ impl Config {
802786 let dir = out. join ( "tmp-dry-run" ) ;
803787 t ! ( fs:: create_dir_all( & dir) ) ;
804788 out = dir;
789+ dwn_ctx. out = out. clone ( ) ;
805790 }
806791
807792 let file_content = t ! ( fs:: read_to_string( src. join( "src/ci/channel" ) ) ) ;
@@ -822,6 +807,7 @@ impl Config {
822807 let omit_git_hash = rust_omit_git_hash. unwrap_or ( channel == "dev" ) ;
823808
824809 rust_info = git_info ( & exec_ctx, omit_git_hash, & src) ;
810+ dwn_ctx. rust_info = rust_info. clone ( ) ;
825811
826812 let vendor = build_vendor. unwrap_or (
827813 rust_info. is_from_tarball ( )
@@ -858,25 +844,9 @@ impl Config {
858844 ) ;
859845 }
860846
861- let dwn_ctx = DownloadContext :: new (
862- path_modification_cache. clone ( ) ,
863- & src,
864- & rust_info,
865- & submodules,
866- & download_rustc_commit,
867- host_target,
868- llvm_from_ci,
869- & target_config,
870- & out,
871- patch_binaries_for_nix,
872- & exec_ctx,
873- & stage0_metadata,
874- llvm_assertions,
875- & bootstrap_cache_path,
876- is_running_on_ci,
877- ) ;
878847 download_rustc_commit =
879- download_ci_rustc_commit ( dwn_ctx, rust_download_rustc, llvm_assertions) ;
848+ download_ci_rustc_commit ( & dwn_ctx, rust_download_rustc, llvm_assertions) ;
849+ dwn_ctx. download_rustc_commit = download_rustc_commit. clone ( ) ;
880850
881851 if debug_assertions_requested {
882852 eprintln ! (
@@ -885,6 +855,7 @@ impl Config {
885855 ) ;
886856 // We need to put this later down_ci_rustc_commit.
887857 download_rustc_commit = None ;
858+ dwn_ctx. download_rustc_commit = None ;
888859 }
889860
890861 if let Some ( t) = toml. target {
@@ -946,6 +917,7 @@ impl Config {
946917
947918 target_config. insert ( TargetSelection :: from_user ( & triple) , target) ;
948919 }
920+ dwn_ctx. target_config = target_config. clone ( ) ;
949921 }
950922
951923 // We make `x86_64-unknown-linux-gnu` use the self-contained linker by default, so we will
@@ -983,25 +955,9 @@ impl Config {
983955 "WARNING: `rust.download-rustc` is enabled. The `rust.channel` option will be overridden by the CI rustc's channel."
984956 ) ;
985957
986- let dwn_ctx = DownloadContext :: new (
987- path_modification_cache. clone ( ) ,
988- & src,
989- & rust_info,
990- & submodules,
991- & download_rustc_commit,
992- host_target,
993- llvm_from_ci,
994- & target_config,
995- & out,
996- patch_binaries_for_nix,
997- & exec_ctx,
998- & stage0_metadata,
999- llvm_assertions,
1000- & bootstrap_cache_path,
1001- is_running_on_ci,
1002- ) ;
1003- let channel_ =
1004- read_file_by_commit ( dwn_ctx, Path :: new ( "src/ci/channel" ) , commit) . trim ( ) . to_owned ( ) ;
958+ let channel_ = read_file_by_commit ( & dwn_ctx, Path :: new ( "src/ci/channel" ) , commit)
959+ . trim ( )
960+ . to_owned ( ) ;
1005961
1006962 channel = channel_;
1007963 }
@@ -1010,24 +966,8 @@ impl Config {
1010966 llvm_link_shared. set ( Some ( v) ) ;
1011967 }
1012968
1013- let dwn_ctx = DownloadContext :: new (
1014- path_modification_cache. clone ( ) ,
1015- & src,
1016- & rust_info,
1017- & submodules,
1018- & download_rustc_commit,
1019- host_target,
1020- llvm_from_ci,
1021- & target_config,
1022- & out,
1023- patch_binaries_for_nix,
1024- & exec_ctx,
1025- & stage0_metadata,
1026- llvm_assertions,
1027- & bootstrap_cache_path,
1028- is_running_on_ci,
1029- ) ;
1030- llvm_from_ci = parse_download_ci_llvm ( dwn_ctx, llvm_download_ci_llvm, llvm_assertions) ;
969+ llvm_from_ci = parse_download_ci_llvm ( & dwn_ctx, llvm_download_ci_llvm, llvm_assertions) ;
970+ dwn_ctx. llvm_from_ci = llvm_from_ci;
1031971
1032972 if llvm_from_ci {
1033973 let warn = |option : & str | {
@@ -1073,55 +1013,19 @@ impl Config {
10731013
10741014 if llvm_from_ci {
10751015 let triple = & host_target. triple ;
1076- let dwn_ctx = DownloadContext :: new (
1077- path_modification_cache. clone ( ) ,
1078- & src,
1079- & rust_info,
1080- & submodules,
1081- & download_rustc_commit,
1082- host_target,
1083- llvm_from_ci,
1084- & target_config,
1085- & out,
1086- patch_binaries_for_nix,
1087- & exec_ctx,
1088- & stage0_metadata,
1089- llvm_assertions,
1090- & bootstrap_cache_path,
1091- is_running_on_ci,
1092- ) ;
1093- let ci_llvm_bin = ci_llvm_root ( dwn_ctx) . join ( "bin" ) ;
1016+ let ci_llvm_bin = ci_llvm_root ( & dwn_ctx) . join ( "bin" ) ;
10941017 let build_target =
10951018 target_config. entry ( host_target) . or_insert_with ( || Target :: from_triple ( triple) ) ;
1019+ dwn_ctx. target_config . entry ( host_target) . or_insert_with ( || Target :: from_triple ( triple) ) ;
10961020
10971021 check_ci_llvm ! ( build_target. llvm_config) ;
10981022 check_ci_llvm ! ( build_target. llvm_filecheck) ;
10991023 build_target. llvm_config = Some ( ci_llvm_bin. join ( exe ( "llvm-config" , host_target) ) ) ;
11001024 build_target. llvm_filecheck = Some ( ci_llvm_bin. join ( exe ( "FileCheck" , host_target) ) ) ;
11011025 }
11021026
1103- let initial_rustfmt = if let Some ( r) = build_rustfmt {
1104- Some ( r)
1105- } else {
1106- let dwn_ctx = DownloadContext :: new (
1107- path_modification_cache. clone ( ) ,
1108- & src,
1109- & rust_info,
1110- & submodules,
1111- & download_rustc_commit,
1112- host_target,
1113- llvm_from_ci,
1114- & target_config,
1115- & out,
1116- patch_binaries_for_nix,
1117- & exec_ctx,
1118- & stage0_metadata,
1119- llvm_assertions,
1120- & bootstrap_cache_path,
1121- is_running_on_ci,
1122- ) ;
1123- maybe_download_rustfmt ( dwn_ctx)
1124- } ;
1027+ let initial_rustfmt =
1028+ if let Some ( r) = build_rustfmt { Some ( r) } else { maybe_download_rustfmt ( & dwn_ctx) } ;
11251029
11261030 if matches ! ( rust_lld_mode. unwrap_or_default( ) , LldMode :: SelfContained )
11271031 && !lld_enabled
@@ -1132,24 +1036,7 @@ impl Config {
11321036 ) ;
11331037 }
11341038
1135- let dwn_ctx = DownloadContext :: new (
1136- path_modification_cache. clone ( ) ,
1137- & src,
1138- & rust_info,
1139- & submodules,
1140- & download_rustc_commit,
1141- host_target,
1142- llvm_from_ci,
1143- & target_config,
1144- & out,
1145- patch_binaries_for_nix,
1146- & exec_ctx,
1147- & stage0_metadata,
1148- llvm_assertions,
1149- & bootstrap_cache_path,
1150- is_running_on_ci,
1151- ) ;
1152- if lld_enabled && is_system_llvm ( dwn_ctx, host_target) {
1039+ if lld_enabled && is_system_llvm ( & dwn_ctx, host_target) {
11531040 panic ! ( "Cannot enable LLD with `rust.lld = true` when using external llvm-config." ) ;
11541041 }
11551042
@@ -2365,7 +2252,7 @@ pub fn has_changes_from_upstream<'a>(
23652252) ]
23662253pub ( crate ) fn update_submodule < ' a > ( dwn_ctx : impl AsRef < DownloadContext < ' a > > , relative_path : & str ) {
23672254 let dwn_ctx = dwn_ctx. as_ref ( ) ;
2368- if dwn_ctx. rust_info . is_from_tarball ( ) || !submodules_ ( dwn_ctx. submodules , dwn_ctx. rust_info ) {
2255+ if dwn_ctx. rust_info . is_from_tarball ( ) || !submodules_ ( dwn_ctx. submodules , & dwn_ctx. rust_info ) {
23692256 return ;
23702257 }
23712258
0 commit comments