Skip to content

Commit f90abe7

Browse files
Rollup merge of #132267 - onur-ozkan:rustc-if-unchanged-force-library, r=Kobzol
force-recompile library changes on download-rustc="if-unchanged" This makes the download-rustc="if-unchanged" option more functional and useful for library developers. Implements the second item from [this tracking issue](#131744).
2 parents 847b6fe + 7e064e7 commit f90abe7

File tree

3 files changed

+27
-20
lines changed

3 files changed

+27
-20
lines changed

config.example.toml

+5-4
Original file line numberDiff line numberDiff line change
@@ -497,11 +497,12 @@
497497
#debug = false
498498

499499
# Whether to download the stage 1 and 2 compilers from CI.
500-
# This is mostly useful for tools; if you have changes to `compiler/` or `library/` they will be ignored.
500+
# This is useful if you are working on tools, doc-comments, or library (you will be able to build
501+
# the standard library without needing to build the compiler).
501502
#
502-
# Set this to "if-unchanged" to only download if the compiler and standard library have not been modified.
503-
# Set this to `true` to download unconditionally. This is useful if you are working on tools, doc-comments,
504-
# or library (you will be able to build the standard library without needing to build the compiler).
503+
# Set this to "if-unchanged" to only download if the compiler (and library if running on CI) have
504+
# not been modified.
505+
# Set this to `true` to download unconditionally.
505506
#download-rustc = false
506507

507508
# Number of codegen units to use for each compiler invocation. A value of 0

src/bootstrap/src/core/build_steps/compile.rs

-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ impl Step for Std {
153153
// NOTE: the beta compiler may generate different artifacts than the downloaded compiler, so
154154
// its artifacts can't be reused.
155155
&& compiler.stage != 0
156-
// This check is specific to testing std itself; see `test::Std` for more details.
157156
&& !self.force_recompile
158157
{
159158
let sysroot = builder.ensure(Sysroot { compiler, force_recompile: false });

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

+22-15
Original file line numberDiff line numberDiff line change
@@ -2767,25 +2767,32 @@ impl Config {
27672767
}
27682768
};
27692769

2770-
let files_to_track =
2771-
&["compiler", "library", "src/version", "src/stage0", "src/ci/channel"];
2770+
let mut files_to_track = vec!["compiler", "src/version", "src/stage0", "src/ci/channel"];
2771+
2772+
// In CI, disable ci-rustc if there are changes in the library tree. But for non-CI, ignore
2773+
// these changes to speed up the build process for library developers. This provides consistent
2774+
// functionality for library developers between `download-rustc=true` and `download-rustc="if-unchanged"`
2775+
// options.
2776+
if CiEnv::is_ci() {
2777+
files_to_track.push("library");
2778+
}
27722779

27732780
// Look for a version to compare to based on the current commit.
27742781
// Only commits merged by bors will have CI artifacts.
2775-
let commit = match self.last_modified_commit(files_to_track, "download-rustc", if_unchanged)
2776-
{
2777-
Some(commit) => commit,
2778-
None => {
2779-
if if_unchanged {
2780-
return None;
2782+
let commit =
2783+
match self.last_modified_commit(&files_to_track, "download-rustc", if_unchanged) {
2784+
Some(commit) => commit,
2785+
None => {
2786+
if if_unchanged {
2787+
return None;
2788+
}
2789+
println!("ERROR: could not find commit hash for downloading rustc");
2790+
println!("HELP: maybe your repository history is too shallow?");
2791+
println!("HELP: consider disabling `download-rustc`");
2792+
println!("HELP: or fetch enough history to include one upstream commit");
2793+
crate::exit!(1);
27812794
}
2782-
println!("ERROR: could not find commit hash for downloading rustc");
2783-
println!("HELP: maybe your repository history is too shallow?");
2784-
println!("HELP: consider disabling `download-rustc`");
2785-
println!("HELP: or fetch enough history to include one upstream commit");
2786-
crate::exit!(1);
2787-
}
2788-
};
2795+
};
27892796

27902797
if CiEnv::is_ci() && {
27912798
let head_sha =

0 commit comments

Comments
 (0)