Skip to content

Commit 1837f6f

Browse files
committed
Reapply "Rollup merge of #132772 - onur-ozkan:download-rustc-default, r=jieyouxu"
This reverts commit c0cee4e.
1 parent 242f20d commit 1837f6f

File tree

5 files changed

+34
-31
lines changed

5 files changed

+34
-31
lines changed

Diff for: src/bootstrap/defaults/config.dist.toml

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ extended = true
1111
# Most users installing from source want to build all parts of the project from source.
1212
[llvm]
1313
download-ci-llvm = false
14+
1415
[rust]
1516
# We have several defaults in bootstrap that depend on whether the channel is `dev` (e.g. `omit-git-hash` and `download-ci-llvm`).
1617
# Make sure they don't get set when installing from source.

Diff for: src/bootstrap/defaults/config.library.toml

-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ bench-stage = 0
88
[rust]
99
# This greatly increases the speed of rebuilds, especially when there are only minor changes. However, it makes the initial build slightly slower.
1010
incremental = true
11-
# Download rustc from CI instead of building it from source.
12-
# For stage > 1 builds, this cuts compile times significantly when there are no changes on "compiler" tree.
13-
download-rustc = "if-unchanged"
1411
# Make the compiler and standard library faster to build, at the expense of a ~20% runtime slowdown.
1512
lto = "off"
1613

Diff for: src/bootstrap/defaults/config.tools.toml

-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
[rust]
44
# This greatly increases the speed of rebuilds, especially when there are only minor changes. However, it makes the initial build slightly slower.
55
incremental = true
6-
# Download rustc from CI instead of building it from source.
7-
# For stage > 1 builds, this cuts compile times significantly when there are no changes on "compiler" tree.
8-
# Using these defaults will download the stage2 compiler (see `download-rustc`
9-
# setting) and the stage2 toolchain should therefore be used for these defaults.
10-
download-rustc = "if-unchanged"
116

127
[build]
138
# Document with the in-tree rustdoc by default, since `download-rustc` makes it quick to compile.

Diff for: src/bootstrap/src/core/config/config.rs

+30-23
Original file line numberDiff line numberDiff line change
@@ -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
}

Diff for: src/bootstrap/src/core/config/tests.rs

+3
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ change-id = 0
135135
[rust]
136136
lto = "off"
137137
deny-warnings = true
138+
download-rustc=false
138139
139140
[build]
140141
gdb = "foo"
@@ -200,6 +201,8 @@ runner = "x86_64-runner"
200201
.collect(),
201202
"setting dictionary value"
202203
);
204+
assert!(!config.llvm_from_ci);
205+
assert!(!config.download_rustc());
203206
}
204207

205208
#[test]

0 commit comments

Comments
 (0)