@@ -1681,11 +1681,33 @@ impl Config {
16811681 let mut debuginfo_level_tools = None ;
16821682 let mut debuginfo_level_tests = None ;
16831683 let mut optimize = None ;
1684- let mut omit_git_hash = None ;
16851684 let mut lld_enabled = None ;
16861685 let mut std_features = None ;
16871686
1688- let mut is_user_configured_rust_channel = false ;
1687+ let is_user_configured_rust_channel =
1688+ if let Some ( channel) = toml. rust . as_ref ( ) . and_then ( |r| r. channel . clone ( ) ) {
1689+ config. channel = channel;
1690+ true
1691+ } else {
1692+ false
1693+ } ;
1694+
1695+ let default = config. channel == "dev" ;
1696+ config. omit_git_hash = toml. rust . as_ref ( ) . and_then ( |r| r. omit_git_hash ) . unwrap_or ( default) ;
1697+
1698+ config. rust_info = GitInfo :: new ( config. omit_git_hash , & config. src ) ;
1699+ config. cargo_info = GitInfo :: new ( config. omit_git_hash , & config. src . join ( "src/tools/cargo" ) ) ;
1700+ config. rust_analyzer_info =
1701+ GitInfo :: new ( config. omit_git_hash , & config. src . join ( "src/tools/rust-analyzer" ) ) ;
1702+ config. clippy_info =
1703+ GitInfo :: new ( config. omit_git_hash , & config. src . join ( "src/tools/clippy" ) ) ;
1704+ config. miri_info = GitInfo :: new ( config. omit_git_hash , & config. src . join ( "src/tools/miri" ) ) ;
1705+ config. rustfmt_info =
1706+ GitInfo :: new ( config. omit_git_hash , & config. src . join ( "src/tools/rustfmt" ) ) ;
1707+ config. enzyme_info =
1708+ GitInfo :: new ( config. omit_git_hash , & config. src . join ( "src/tools/enzyme" ) ) ;
1709+ config. in_tree_llvm_info = GitInfo :: new ( false , & config. src . join ( "src/llvm-project" ) ) ;
1710+ config. in_tree_gcc_info = GitInfo :: new ( false , & config. src . join ( "src/gcc" ) ) ;
16891711
16901712 if let Some ( rust) = toml. rust {
16911713 let Rust {
@@ -1708,14 +1730,14 @@ impl Config {
17081730 parallel_compiler,
17091731 randomize_layout,
17101732 default_linker,
1711- channel,
1733+ channel : _ , // already handled above
17121734 description,
17131735 musl_root,
17141736 rpath,
17151737 verbose_tests,
17161738 optimize_tests,
17171739 codegen_tests,
1718- omit_git_hash : omit_git_hash_toml ,
1740+ omit_git_hash : _ , // already handled above
17191741 dist_src,
17201742 save_toolstates,
17211743 codegen_backends,
@@ -1745,9 +1767,6 @@ impl Config {
17451767 std_features : std_features_toml,
17461768 } = rust;
17471769
1748- is_user_configured_rust_channel = channel. is_some ( ) ;
1749- set ( & mut config. channel , channel. clone ( ) ) ;
1750-
17511770 config. download_rustc_commit =
17521771 config. download_ci_rustc_commit ( download_rustc, config. llvm_assertions ) ;
17531772
@@ -1766,7 +1785,6 @@ impl Config {
17661785 std_features = std_features_toml;
17671786
17681787 optimize = optimize_toml;
1769- omit_git_hash = omit_git_hash_toml;
17701788 config. rust_new_symbol_mangling = new_symbol_mangling;
17711789 set ( & mut config. rust_optimize_tests , optimize_tests) ;
17721790 set ( & mut config. codegen_tests , codegen_tests) ;
@@ -1848,24 +1866,6 @@ impl Config {
18481866
18491867 config. reproducible_artifacts = flags. reproducible_artifact ;
18501868
1851- // rust_info must be set before is_ci_llvm_available() is called.
1852- let default = config. channel == "dev" ;
1853- config. omit_git_hash = omit_git_hash. unwrap_or ( default) ;
1854- config. rust_info = GitInfo :: new ( config. omit_git_hash , & config. src ) ;
1855-
1856- config. cargo_info = GitInfo :: new ( config. omit_git_hash , & config. src . join ( "src/tools/cargo" ) ) ;
1857- config. rust_analyzer_info =
1858- GitInfo :: new ( config. omit_git_hash , & config. src . join ( "src/tools/rust-analyzer" ) ) ;
1859- config. clippy_info =
1860- GitInfo :: new ( config. omit_git_hash , & config. src . join ( "src/tools/clippy" ) ) ;
1861- config. miri_info = GitInfo :: new ( config. omit_git_hash , & config. src . join ( "src/tools/miri" ) ) ;
1862- config. rustfmt_info =
1863- GitInfo :: new ( config. omit_git_hash , & config. src . join ( "src/tools/rustfmt" ) ) ;
1864- config. enzyme_info =
1865- GitInfo :: new ( config. omit_git_hash , & config. src . join ( "src/tools/enzyme" ) ) ;
1866- config. in_tree_llvm_info = GitInfo :: new ( false , & config. src . join ( "src/llvm-project" ) ) ;
1867- config. in_tree_gcc_info = GitInfo :: new ( false , & config. src . join ( "src/gcc" ) ) ;
1868-
18691869 // We need to override `rust.channel` if it's manually specified when using the CI rustc.
18701870 // This is because if the compiler uses a different channel than the one specified in config.toml,
18711871 // tests may fail due to using a different channel than the one used by the compiler during tests.
@@ -2782,9 +2782,19 @@ impl Config {
27822782
27832783 // If `download-rustc` is not set, default to rebuilding.
27842784 let if_unchanged = match download_rustc {
2785- None | Some ( StringOrBool :: Bool ( false ) ) => return None ,
2785+ None => self . rust_info . is_managed_git_subrepository ( ) ,
2786+ Some ( StringOrBool :: Bool ( false ) ) => return None ,
27862787 Some ( StringOrBool :: Bool ( true ) ) => false ,
2787- Some ( StringOrBool :: String ( s) ) if s == "if-unchanged" => true ,
2788+ Some ( StringOrBool :: String ( s) ) if s == "if-unchanged" => {
2789+ if !self . rust_info . is_managed_git_subrepository ( ) {
2790+ println ! (
2791+ "ERROR: `download-rustc=if-unchanged` is only compatible with Git managed sources."
2792+ ) ;
2793+ crate :: exit!( 1 ) ;
2794+ }
2795+
2796+ true
2797+ }
27882798 Some ( StringOrBool :: String ( other) ) => {
27892799 panic ! ( "unrecognized option for download-rustc: {other}" )
27902800 }
0 commit comments