Skip to content

Commit 65b3877

Browse files
committed
Auto merge of #132872 - onur-ozkan:reapply-132772, r=jieyouxu
Reland #132772: use `download-rustc="if-unchanged"` as a global default Relands #132772 with the fix. r? jieyouxu (knows the context).
2 parents ec239b8 + db12ccd commit 65b3877

File tree

6 files changed

+44
-36
lines changed

6 files changed

+44
-36
lines changed

src/bootstrap/defaults/config.compiler.toml

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ lto = "off"
1919
# Forces frame pointers to be used with `-Cforce-frame-pointers`.
2020
# This can be helpful for profiling at a small performance cost.
2121
frame-pointers = true
22+
download-rustc = false
2223

2324
[llvm]
2425
# Having this set to true disrupts compiler development workflows for people who use `llvm.download-ci-llvm = true`

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.

src/bootstrap/defaults/config.library.toml

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@ 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"
13+
download-rustc = false
1614

1715
[llvm]
1816
# Will download LLVM from CI if available on your platform.

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.

src/bootstrap/src/core/config/config.rs

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

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)