@@ -679,15 +679,11 @@ impl Config {
679
679
. unwrap_or_else ( || vec ! [ host_target] ) ;
680
680
681
681
let llvm_assertions = llvm_assertions_. unwrap_or ( false ) ;
682
-
683
682
let mut target_config = HashMap :: new ( ) ;
684
- let mut download_rustc_commit = None ;
685
- let mut llvm_from_ci = false ;
686
683
let mut channel = "dev" . to_string ( ) ;
687
684
let mut out = flags_build_dir
688
685
. or ( build_build_dir. map ( PathBuf :: from) )
689
686
. unwrap_or_else ( || PathBuf :: from ( "build" ) ) ;
690
- let mut rust_info = GitInfo :: Absent ;
691
687
692
688
if cfg ! ( test) {
693
689
// Use the build directory of the original x.py invocation, so that we can set `initial_rustc` properly.
@@ -730,16 +726,11 @@ impl Config {
730
726
) ;
731
727
}
732
728
733
- let mut dwn_ctx = DownloadContext {
729
+ let dwn_ctx = DownloadContext {
734
730
path_modification_cache : path_modification_cache. clone ( ) ,
735
731
src : & src,
736
- rust_info : rust_info. clone ( ) ,
737
732
submodules : & build_submodules,
738
- download_rustc_commit : download_rustc_commit. clone ( ) ,
739
733
host_target,
740
- llvm_from_ci,
741
- target_config : target_config. clone ( ) ,
742
- out : out. clone ( ) ,
743
734
patch_binaries_for_nix : build_patch_binaries_for_nix,
744
735
exec_ctx : & exec_ctx,
745
736
stage0_metadata : & stage0_metadata,
@@ -749,7 +740,7 @@ impl Config {
749
740
} ;
750
741
751
742
let initial_rustc = build_rustc. unwrap_or_else ( || {
752
- download_beta_toolchain ( & dwn_ctx) ;
743
+ download_beta_toolchain ( & dwn_ctx, & out ) ;
753
744
out. join ( host_target) . join ( "stage0" ) . join ( "bin" ) . join ( exe ( "rustc" , host_target) )
754
745
} ) ;
755
746
@@ -763,15 +754,14 @@ impl Config {
763
754
) ) ;
764
755
765
756
let initial_cargo = build_cargo. unwrap_or_else ( || {
766
- download_beta_toolchain ( & dwn_ctx) ;
757
+ download_beta_toolchain ( & dwn_ctx, & out ) ;
767
758
initial_sysroot. join ( "bin" ) . join ( exe ( "cargo" , host_target) )
768
759
} ) ;
769
760
770
761
// NOTE: it's important this comes *after* we set `initial_rustc` just above.
771
762
if exec_ctx. dry_run ( ) {
772
763
out = out. join ( "tmp-dry-run" ) ;
773
764
fs:: create_dir_all ( & out) . expect ( "Failed to create dry-run directory" ) ;
774
- dwn_ctx. out = out. clone ( ) ;
775
765
}
776
766
777
767
let file_content = t ! ( fs:: read_to_string( src. join( "src/ci/channel" ) ) ) ;
@@ -791,8 +781,7 @@ impl Config {
791
781
792
782
let omit_git_hash = rust_omit_git_hash. unwrap_or ( channel == "dev" ) ;
793
783
794
- rust_info = git_info ( & exec_ctx, omit_git_hash, & src) ;
795
- dwn_ctx. rust_info = rust_info. clone ( ) ;
784
+ let rust_info = git_info ( & exec_ctx, omit_git_hash, & src) ;
796
785
797
786
if !is_user_configured_rust_channel && rust_info. is_from_tarball ( ) {
798
787
channel = ci_channel. into ( ) ;
@@ -823,9 +812,8 @@ impl Config {
823
812
) ;
824
813
}
825
814
826
- download_rustc_commit =
827
- download_ci_rustc_commit ( & dwn_ctx, rust_download_rustc, llvm_assertions) ;
828
- dwn_ctx. download_rustc_commit = download_rustc_commit. clone ( ) ;
815
+ let mut download_rustc_commit =
816
+ download_ci_rustc_commit ( & dwn_ctx, & rust_info, rust_download_rustc, llvm_assertions) ;
829
817
830
818
if debug_assertions_requested && download_rustc_commit. is_some ( ) {
831
819
eprintln ! (
@@ -834,7 +822,6 @@ impl Config {
834
822
) ;
835
823
// We need to put this later down_ci_rustc_commit.
836
824
download_rustc_commit = None ;
837
- dwn_ctx. download_rustc_commit = None ;
838
825
}
839
826
840
827
// We need to override `rust.channel` if it's manually specified when using the CI rustc.
@@ -847,9 +834,10 @@ impl Config {
847
834
"WARNING: `rust.download-rustc` is enabled. The `rust.channel` option will be overridden by the CI rustc's channel."
848
835
) ;
849
836
850
- channel = read_file_by_commit ( & dwn_ctx, Path :: new ( "src/ci/channel" ) , commit)
851
- . trim ( )
852
- . to_owned ( ) ;
837
+ channel =
838
+ read_file_by_commit ( & dwn_ctx, & rust_info, Path :: new ( "src/ci/channel" ) , commit)
839
+ . trim ( )
840
+ . to_owned ( ) ;
853
841
}
854
842
855
843
if let Some ( t) = toml. target {
@@ -911,11 +899,15 @@ impl Config {
911
899
912
900
target_config. insert ( TargetSelection :: from_user ( & triple) , target) ;
913
901
}
914
- dwn_ctx. target_config = target_config. clone ( ) ;
915
902
}
916
903
917
- llvm_from_ci = parse_download_ci_llvm ( & dwn_ctx, llvm_download_ci_llvm, llvm_assertions) ;
918
- dwn_ctx. llvm_from_ci = llvm_from_ci;
904
+ let llvm_from_ci = parse_download_ci_llvm (
905
+ & dwn_ctx,
906
+ & rust_info,
907
+ & download_rustc_commit,
908
+ llvm_download_ci_llvm,
909
+ llvm_assertions,
910
+ ) ;
919
911
920
912
// We make `x86_64-unknown-linux-gnu` use the self-contained linker by default, so we will
921
913
// build our internal lld and use it as the default linker, by setting the `rust.lld` config
@@ -976,18 +968,16 @@ impl Config {
976
968
977
969
if llvm_from_ci {
978
970
let triple = & host_target. triple ;
979
- let ci_llvm_bin = ci_llvm_root ( & dwn_ctx) . join ( "bin" ) ;
971
+ let ci_llvm_bin = ci_llvm_root ( & dwn_ctx, llvm_from_ci , & out ) . join ( "bin" ) ;
980
972
let build_target =
981
973
target_config. entry ( host_target) . or_insert_with ( || Target :: from_triple ( triple) ) ;
982
- dwn_ctx. target_config . entry ( host_target) . or_insert_with ( || Target :: from_triple ( triple) ) ;
983
-
984
974
check_ci_llvm ! ( build_target. llvm_config) ;
985
975
check_ci_llvm ! ( build_target. llvm_filecheck) ;
986
976
build_target. llvm_config = Some ( ci_llvm_bin. join ( exe ( "llvm-config" , host_target) ) ) ;
987
977
build_target. llvm_filecheck = Some ( ci_llvm_bin. join ( exe ( "FileCheck" , host_target) ) ) ;
988
978
}
989
979
990
- let initial_rustfmt = build_rustfmt. or_else ( || maybe_download_rustfmt ( & dwn_ctx) ) ;
980
+ let initial_rustfmt = build_rustfmt. or_else ( || maybe_download_rustfmt ( & dwn_ctx, & out ) ) ;
991
981
992
982
if matches ! ( rust_lld_mode. unwrap_or_default( ) , LldMode :: SelfContained )
993
983
&& !lld_enabled
@@ -998,7 +988,7 @@ impl Config {
998
988
) ;
999
989
}
1000
990
1001
- if lld_enabled && is_system_llvm ( & dwn_ctx, host_target) {
991
+ if lld_enabled && is_system_llvm ( & dwn_ctx, & target_config , llvm_from_ci , host_target) {
1002
992
panic ! ( "Cannot enable LLD with `rust.lld = true` when using external llvm-config." ) ;
1003
993
}
1004
994
@@ -1392,7 +1382,7 @@ impl Config {
1392
1382
/// Returns the content of the given file at a specific commit.
1393
1383
pub ( crate ) fn read_file_by_commit ( & self , file : & Path , commit : & str ) -> String {
1394
1384
let dwn_ctx = DownloadContext :: from ( self ) ;
1395
- read_file_by_commit ( dwn_ctx, file, commit)
1385
+ read_file_by_commit ( dwn_ctx, & self . rust_info , file, commit)
1396
1386
}
1397
1387
1398
1388
/// Bootstrap embeds a version number into the name of shared libraries it uploads in CI.
@@ -1464,7 +1454,7 @@ impl Config {
1464
1454
/// The absolute path to the downloaded LLVM artifacts.
1465
1455
pub ( crate ) fn ci_llvm_root ( & self ) -> PathBuf {
1466
1456
let dwn_ctx = DownloadContext :: from ( self ) ;
1467
- ci_llvm_root ( dwn_ctx)
1457
+ ci_llvm_root ( dwn_ctx, self . llvm_from_ci , & self . out )
1468
1458
}
1469
1459
1470
1460
/// Directory where the extracted `rustc-dev` component is stored.
@@ -1628,7 +1618,7 @@ impl Config {
1628
1618
) ]
1629
1619
pub ( crate ) fn update_submodule ( & self , relative_path : & str ) {
1630
1620
let dwn_ctx = DownloadContext :: from ( self ) ;
1631
- update_submodule ( dwn_ctx, relative_path) ;
1621
+ update_submodule ( dwn_ctx, & self . rust_info , relative_path) ;
1632
1622
}
1633
1623
1634
1624
/// Returns true if any of the `paths` have been modified locally.
@@ -1744,7 +1734,7 @@ impl Config {
1744
1734
/// NOTE: this is not the same as `!is_rust_llvm` when `llvm_has_patches` is set.
1745
1735
pub fn is_system_llvm ( & self , target : TargetSelection ) -> bool {
1746
1736
let dwn_ctx = DownloadContext :: from ( self ) ;
1747
- is_system_llvm ( dwn_ctx, target)
1737
+ is_system_llvm ( dwn_ctx, & self . target_config , self . llvm_from_ci , target)
1748
1738
}
1749
1739
1750
1740
/// Returns `true` if this is our custom, patched, version of LLVM.
@@ -2038,6 +2028,7 @@ pub fn check_stage0_version(
2038
2028
2039
2029
pub fn download_ci_rustc_commit < ' a > (
2040
2030
dwn_ctx : impl AsRef < DownloadContext < ' a > > ,
2031
+ rust_info : & channel:: GitInfo ,
2041
2032
download_rustc : Option < StringOrBool > ,
2042
2033
llvm_assertions : bool ,
2043
2034
) -> Option < String > {
@@ -2057,7 +2048,7 @@ pub fn download_ci_rustc_commit<'a>(
2057
2048
None | Some ( StringOrBool :: Bool ( false ) ) => return None ,
2058
2049
Some ( StringOrBool :: Bool ( true ) ) => false ,
2059
2050
Some ( StringOrBool :: String ( s) ) if s == "if-unchanged" => {
2060
- if !dwn_ctx . rust_info . is_managed_git_subrepository ( ) {
2051
+ if !rust_info. is_managed_git_subrepository ( ) {
2061
2052
println ! (
2062
2053
"ERROR: `download-rustc=if-unchanged` is only compatible with Git managed sources."
2063
2054
) ;
@@ -2071,7 +2062,7 @@ pub fn download_ci_rustc_commit<'a>(
2071
2062
}
2072
2063
} ;
2073
2064
2074
- let commit = if dwn_ctx . rust_info . is_managed_git_subrepository ( ) {
2065
+ let commit = if rust_info. is_managed_git_subrepository ( ) {
2075
2066
// Look for a version to compare to based on the current commit.
2076
2067
// Only commits merged by bors will have CI artifacts.
2077
2068
let freshness = check_path_modifications_ ( dwn_ctx, RUSTC_IF_UNCHANGED_ALLOWED_PATHS ) ;
@@ -2145,6 +2136,8 @@ pub fn git_config(stage0_metadata: &build_helper::stage0_parser::Stage0) -> GitC
2145
2136
2146
2137
pub fn parse_download_ci_llvm < ' a > (
2147
2138
dwn_ctx : impl AsRef < DownloadContext < ' a > > ,
2139
+ rust_info : & channel:: GitInfo ,
2140
+ download_rustc_commit : & Option < String > ,
2148
2141
download_ci_llvm : Option < StringOrBool > ,
2149
2142
asserts : bool ,
2150
2143
) -> bool {
@@ -2160,15 +2153,15 @@ pub fn parse_download_ci_llvm<'a>(
2160
2153
let download_ci_llvm = download_ci_llvm. unwrap_or ( default) ;
2161
2154
2162
2155
let if_unchanged = || {
2163
- if dwn_ctx . rust_info . is_from_tarball ( ) {
2156
+ if rust_info. is_from_tarball ( ) {
2164
2157
// Git is needed for running "if-unchanged" logic.
2165
2158
println ! ( "ERROR: 'if-unchanged' is only compatible with Git managed sources." ) ;
2166
2159
crate :: exit!( 1 ) ;
2167
2160
}
2168
2161
2169
2162
// Fetching the LLVM submodule is unnecessary for self-tests.
2170
2163
#[ cfg( not( test) ) ]
2171
- update_submodule ( dwn_ctx, "src/llvm-project" ) ;
2164
+ update_submodule ( dwn_ctx, rust_info , "src/llvm-project" ) ;
2172
2165
2173
2166
// Check for untracked changes in `src/llvm-project` and other important places.
2174
2167
let has_changes = has_changes_from_upstream ( dwn_ctx, LLVM_INVALIDATION_PATHS ) ;
@@ -2183,7 +2176,7 @@ pub fn parse_download_ci_llvm<'a>(
2183
2176
2184
2177
match download_ci_llvm {
2185
2178
StringOrBool :: Bool ( b) => {
2186
- if !b && dwn_ctx . download_rustc_commit . is_some ( ) {
2179
+ if !b && download_rustc_commit. is_some ( ) {
2187
2180
panic ! (
2188
2181
"`llvm.download-ci-llvm` cannot be set to `false` if `rust.download-rustc` is set to `true` or `if-unchanged`."
2189
2182
) ;
@@ -2226,9 +2219,13 @@ pub fn has_changes_from_upstream<'a>(
2226
2219
fields( relative_path = ?relative_path) ,
2227
2220
) ,
2228
2221
) ]
2229
- pub ( crate ) fn update_submodule < ' a > ( dwn_ctx : impl AsRef < DownloadContext < ' a > > , relative_path : & str ) {
2222
+ pub ( crate ) fn update_submodule < ' a > (
2223
+ dwn_ctx : impl AsRef < DownloadContext < ' a > > ,
2224
+ rust_info : & channel:: GitInfo ,
2225
+ relative_path : & str ,
2226
+ ) {
2230
2227
let dwn_ctx = dwn_ctx. as_ref ( ) ;
2231
- if dwn_ctx . rust_info . is_from_tarball ( ) || !submodules_ ( dwn_ctx. submodules , & dwn_ctx . rust_info ) {
2228
+ if rust_info. is_from_tarball ( ) || !submodules_ ( dwn_ctx. submodules , rust_info) {
2232
2229
return ;
2233
2230
}
2234
2231
@@ -2357,12 +2354,14 @@ pub fn submodules_(submodules: &Option<bool>, rust_info: &channel::GitInfo) -> b
2357
2354
/// NOTE: this is not the same as `!is_rust_llvm` when `llvm_has_patches` is set.
2358
2355
pub fn is_system_llvm < ' a > (
2359
2356
dwn_ctx : impl AsRef < DownloadContext < ' a > > ,
2357
+ target_config : & HashMap < TargetSelection , Target > ,
2358
+ llvm_from_ci : bool ,
2360
2359
target : TargetSelection ,
2361
2360
) -> bool {
2362
2361
let dwn_ctx = dwn_ctx. as_ref ( ) ;
2363
- match dwn_ctx . target_config . get ( & target) {
2362
+ match target_config. get ( & target) {
2364
2363
Some ( Target { llvm_config : Some ( _) , .. } ) => {
2365
- let ci_llvm = dwn_ctx . llvm_from_ci && is_host_target ( & dwn_ctx. host_target , & target) ;
2364
+ let ci_llvm = llvm_from_ci && is_host_target ( & dwn_ctx. host_target , & target) ;
2366
2365
!ci_llvm
2367
2366
}
2368
2367
// We're building from the in-tree src/llvm-project sources.
@@ -2375,21 +2374,26 @@ pub fn is_host_target(host_target: &TargetSelection, target: &TargetSelection) -
2375
2374
host_target == target
2376
2375
}
2377
2376
2378
- pub ( crate ) fn ci_llvm_root < ' a > ( dwn_ctx : impl AsRef < DownloadContext < ' a > > ) -> PathBuf {
2377
+ pub ( crate ) fn ci_llvm_root < ' a > (
2378
+ dwn_ctx : impl AsRef < DownloadContext < ' a > > ,
2379
+ llvm_from_ci : bool ,
2380
+ out : & Path ,
2381
+ ) -> PathBuf {
2379
2382
let dwn_ctx = dwn_ctx. as_ref ( ) ;
2380
- assert ! ( dwn_ctx . llvm_from_ci) ;
2381
- dwn_ctx . out . join ( dwn_ctx. host_target ) . join ( "ci-llvm" )
2383
+ assert ! ( llvm_from_ci) ;
2384
+ out. join ( dwn_ctx. host_target ) . join ( "ci-llvm" )
2382
2385
}
2383
2386
2384
2387
/// Returns the content of the given file at a specific commit.
2385
2388
pub ( crate ) fn read_file_by_commit < ' a > (
2386
2389
dwn_ctx : impl AsRef < DownloadContext < ' a > > ,
2390
+ rust_info : & channel:: GitInfo ,
2387
2391
file : & Path ,
2388
2392
commit : & str ,
2389
2393
) -> String {
2390
2394
let dwn_ctx = dwn_ctx. as_ref ( ) ;
2391
2395
assert ! (
2392
- dwn_ctx . rust_info. is_managed_git_subrepository( ) ,
2396
+ rust_info. is_managed_git_subrepository( ) ,
2393
2397
"`Config::read_file_by_commit` is not supported in non-git sources."
2394
2398
) ;
2395
2399
0 commit comments