Skip to content

Commit

Permalink
Rollup merge of #132267 - onur-ozkan:rustc-if-unchanged-force-library…
Browse files Browse the repository at this point in the history
…, 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).
  • Loading branch information
workingjubilee authored Oct 30, 2024
2 parents 847b6fe + 7e064e7 commit f90abe7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 20 deletions.
9 changes: 5 additions & 4 deletions config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -497,11 +497,12 @@
#debug = false

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

# Number of codegen units to use for each compiler invocation. A value of 0
Expand Down
1 change: 0 additions & 1 deletion src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ impl Step for Std {
// NOTE: the beta compiler may generate different artifacts than the downloaded compiler, so
// its artifacts can't be reused.
&& compiler.stage != 0
// This check is specific to testing std itself; see `test::Std` for more details.
&& !self.force_recompile
{
let sysroot = builder.ensure(Sysroot { compiler, force_recompile: false });
Expand Down
37 changes: 22 additions & 15 deletions src/bootstrap/src/core/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2767,25 +2767,32 @@ impl Config {
}
};

let files_to_track =
&["compiler", "library", "src/version", "src/stage0", "src/ci/channel"];
let mut files_to_track = vec!["compiler", "src/version", "src/stage0", "src/ci/channel"];

// In CI, disable ci-rustc if there are changes in the library tree. But for non-CI, ignore
// these changes to speed up the build process for library developers. This provides consistent
// functionality for library developers between `download-rustc=true` and `download-rustc="if-unchanged"`
// options.
if CiEnv::is_ci() {
files_to_track.push("library");
}

// Look for a version to compare to based on the current commit.
// Only commits merged by bors will have CI artifacts.
let commit = match self.last_modified_commit(files_to_track, "download-rustc", if_unchanged)
{
Some(commit) => commit,
None => {
if if_unchanged {
return None;
let commit =
match self.last_modified_commit(&files_to_track, "download-rustc", if_unchanged) {
Some(commit) => commit,
None => {
if if_unchanged {
return None;
}
println!("ERROR: could not find commit hash for downloading rustc");
println!("HELP: maybe your repository history is too shallow?");
println!("HELP: consider disabling `download-rustc`");
println!("HELP: or fetch enough history to include one upstream commit");
crate::exit!(1);
}
println!("ERROR: could not find commit hash for downloading rustc");
println!("HELP: maybe your repository history is too shallow?");
println!("HELP: consider disabling `download-rustc`");
println!("HELP: or fetch enough history to include one upstream commit");
crate::exit!(1);
}
};
};

if CiEnv::is_ci() && {
let head_sha =
Expand Down

0 comments on commit f90abe7

Please sign in to comment.