@@ -1681,10 +1681,26 @@ 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
1687+ let default = config. channel == "dev" ;
1688+ config. omit_git_hash = toml. rust . as_ref ( ) . and_then ( |r| r. omit_git_hash ) . unwrap_or ( default) ;
1689+
1690+ config. rust_info = GitInfo :: new ( config. omit_git_hash , & config. src ) ;
1691+ config. cargo_info = GitInfo :: new ( config. omit_git_hash , & config. src . join ( "src/tools/cargo" ) ) ;
1692+ config. rust_analyzer_info =
1693+ GitInfo :: new ( config. omit_git_hash , & config. src . join ( "src/tools/rust-analyzer" ) ) ;
1694+ config. clippy_info =
1695+ GitInfo :: new ( config. omit_git_hash , & config. src . join ( "src/tools/clippy" ) ) ;
1696+ config. miri_info = GitInfo :: new ( config. omit_git_hash , & config. src . join ( "src/tools/miri" ) ) ;
1697+ config. rustfmt_info =
1698+ GitInfo :: new ( config. omit_git_hash , & config. src . join ( "src/tools/rustfmt" ) ) ;
1699+ config. enzyme_info =
1700+ GitInfo :: new ( config. omit_git_hash , & config. src . join ( "src/tools/enzyme" ) ) ;
1701+ config. in_tree_llvm_info = GitInfo :: new ( false , & config. src . join ( "src/llvm-project" ) ) ;
1702+ config. in_tree_gcc_info = GitInfo :: new ( false , & config. src . join ( "src/gcc" ) ) ;
1703+
16881704 let mut is_user_configured_rust_channel = false ;
16891705
16901706 if let Some ( rust) = toml. rust {
@@ -1715,7 +1731,7 @@ impl Config {
17151731 verbose_tests,
17161732 optimize_tests,
17171733 codegen_tests,
1718- omit_git_hash : omit_git_hash_toml ,
1734+ omit_git_hash : _ , // already handled above
17191735 dist_src,
17201736 save_toolstates,
17211737 codegen_backends,
@@ -1766,7 +1782,6 @@ impl Config {
17661782 std_features = std_features_toml;
17671783
17681784 optimize = optimize_toml;
1769- omit_git_hash = omit_git_hash_toml;
17701785 config. rust_new_symbol_mangling = new_symbol_mangling;
17711786 set ( & mut config. rust_optimize_tests , optimize_tests) ;
17721787 set ( & mut config. codegen_tests , codegen_tests) ;
@@ -1848,24 +1863,6 @@ impl Config {
18481863
18491864 config. reproducible_artifacts = flags. reproducible_artifact ;
18501865
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-
18691866 // We need to override `rust.channel` if it's manually specified when using the CI rustc.
18701867 // This is because if the compiler uses a different channel than the one specified in config.toml,
18711868 // tests may fail due to using a different channel than the one used by the compiler during tests.
@@ -2782,9 +2779,19 @@ impl Config {
27822779
27832780 // If `download-rustc` is not set, default to rebuilding.
27842781 let if_unchanged = match download_rustc {
2785- None | Some ( StringOrBool :: Bool ( false ) ) => return None ,
2782+ None => self . rust_info . is_managed_git_subrepository ( ) ,
2783+ Some ( StringOrBool :: Bool ( false ) ) => return None ,
27862784 Some ( StringOrBool :: Bool ( true ) ) => false ,
2787- Some ( StringOrBool :: String ( s) ) if s == "if-unchanged" => true ,
2785+ Some ( StringOrBool :: String ( s) ) if s == "if-unchanged" => {
2786+ if !self . rust_info . is_managed_git_subrepository ( ) {
2787+ println ! (
2788+ "ERROR: `download-rustc=if-unchanged` is only compatible with Git managed sources."
2789+ ) ;
2790+ crate :: exit!( 1 ) ;
2791+ }
2792+
2793+ true
2794+ }
27882795 Some ( StringOrBool :: String ( other) ) => {
27892796 panic ! ( "unrecognized option for download-rustc: {other}" )
27902797 }
0 commit comments