@@ -1681,11 +1681,33 @@ 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
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"));
1689
1711
1690
1712
if let Some(rust) = toml.rust {
1691
1713
let Rust {
@@ -1708,14 +1730,14 @@ impl Config {
1708
1730
parallel_compiler,
1709
1731
randomize_layout,
1710
1732
default_linker,
1711
- channel,
1733
+ channel: _, // already handled above
1712
1734
description,
1713
1735
musl_root,
1714
1736
rpath,
1715
1737
verbose_tests,
1716
1738
optimize_tests,
1717
1739
codegen_tests,
1718
- omit_git_hash: omit_git_hash_toml,
1740
+ omit_git_hash: _, // already handled above
1719
1741
dist_src,
1720
1742
save_toolstates,
1721
1743
codegen_backends,
@@ -1745,9 +1767,6 @@ impl Config {
1745
1767
std_features: std_features_toml,
1746
1768
} = rust;
1747
1769
1748
- is_user_configured_rust_channel = channel.is_some();
1749
- set(&mut config.channel, channel.clone());
1750
-
1751
1770
config.download_rustc_commit =
1752
1771
config.download_ci_rustc_commit(download_rustc, config.llvm_assertions);
1753
1772
@@ -1766,7 +1785,6 @@ impl Config {
1766
1785
std_features = std_features_toml;
1767
1786
1768
1787
optimize = optimize_toml;
1769
- omit_git_hash = omit_git_hash_toml;
1770
1788
config.rust_new_symbol_mangling = new_symbol_mangling;
1771
1789
set(&mut config.rust_optimize_tests, optimize_tests);
1772
1790
set(&mut config.codegen_tests, codegen_tests);
@@ -1848,24 +1866,6 @@ impl Config {
1848
1866
1849
1867
config.reproducible_artifacts = flags.reproducible_artifact;
1850
1868
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
1869
// We need to override `rust.channel` if it's manually specified when using the CI rustc.
1870
1870
// This is because if the compiler uses a different channel than the one specified in config.toml,
1871
1871
// tests may fail due to using a different channel than the one used by the compiler during tests.
@@ -2782,9 +2782,19 @@ impl Config {
2782
2782
2783
2783
// If `download-rustc` is not set, default to rebuilding.
2784
2784
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,
2786
2787
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
+ }
2788
2798
Some(StringOrBool::String(other)) => {
2789
2799
panic!("unrecognized option for download-rustc: {other}")
2790
2800
}
0 commit comments