@@ -1681,10 +1681,26 @@ impl Config {
1681
1681
let mut debuginfo_level_tools = None ;
1682
1682
let mut debuginfo_level_tests = None ;
1683
1683
let mut optimize = None ;
1684
- let mut omit_git_hash = None ;
1685
1684
let mut lld_enabled = None ;
1686
1685
let mut std_features = None ;
1687
1686
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
+
1688
1704
let mut is_user_configured_rust_channel = false ;
1689
1705
1690
1706
if let Some ( rust) = toml. rust {
@@ -1715,7 +1731,7 @@ impl Config {
1715
1731
verbose_tests,
1716
1732
optimize_tests,
1717
1733
codegen_tests,
1718
- omit_git_hash : omit_git_hash_toml ,
1734
+ omit_git_hash : _ , // already handled above
1719
1735
dist_src,
1720
1736
save_toolstates,
1721
1737
codegen_backends,
@@ -1766,7 +1782,6 @@ impl Config {
1766
1782
std_features = std_features_toml;
1767
1783
1768
1784
optimize = optimize_toml;
1769
- omit_git_hash = omit_git_hash_toml;
1770
1785
config. rust_new_symbol_mangling = new_symbol_mangling;
1771
1786
set ( & mut config. rust_optimize_tests , optimize_tests) ;
1772
1787
set ( & mut config. codegen_tests , codegen_tests) ;
@@ -1848,24 +1863,6 @@ impl Config {
1848
1863
1849
1864
config. reproducible_artifacts = flags. reproducible_artifact ;
1850
1865
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
-
1869
1866
// We need to override `rust.channel` if it's manually specified when using the CI rustc.
1870
1867
// This is because if the compiler uses a different channel than the one specified in config.toml,
1871
1868
// tests may fail due to using a different channel than the one used by the compiler during tests.
@@ -2782,9 +2779,19 @@ impl Config {
2782
2779
2783
2780
// If `download-rustc` is not set, default to rebuilding.
2784
2781
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 ,
2786
2784
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
+ }
2788
2795
Some ( StringOrBool :: String ( other) ) => {
2789
2796
panic ! ( "unrecognized option for download-rustc: {other}" )
2790
2797
}
0 commit comments