Skip to content

Commit f8306b0

Browse files
onur-ozkancuviper
authored andcommitted
make it possible to use ci-rustc on tarball sources
Previously, bootstrap was using `Config::last_modified_commit` unconditionally to figure the commit has to download precompiled rustc artifact from CI, which was leading builds to fail on tarball sources as `Config::last_modified_commit` requires `git` to be present in the project source. This change makes bootstrap to call `Config::last_modified_commit` only when it's running on git-managed source and read `git-commit-hash` file otherwise. Signed-off-by: onur-ozkan <[email protected]> (cherry picked from commit 903cddb)
1 parent e26749f commit f8306b0

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

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

+23-13
Original file line numberDiff line numberDiff line change
@@ -2815,21 +2815,26 @@ impl Config {
28152815
allowed_paths.push(":!library");
28162816
}
28172817

2818-
// Look for a version to compare to based on the current commit.
2819-
// Only commits merged by bors will have CI artifacts.
2820-
let commit = match self.last_modified_commit(&allowed_paths, "download-rustc", if_unchanged)
2821-
{
2822-
Some(commit) => commit,
2823-
None => {
2824-
if if_unchanged {
2825-
return None;
2818+
let commit = if self.rust_info.is_managed_git_subrepository() {
2819+
// Look for a version to compare to based on the current commit.
2820+
// Only commits merged by bors will have CI artifacts.
2821+
match self.last_modified_commit(&allowed_paths, "download-rustc", if_unchanged) {
2822+
Some(commit) => commit,
2823+
None => {
2824+
if if_unchanged {
2825+
return None;
2826+
}
2827+
println!("ERROR: could not find commit hash for downloading rustc");
2828+
println!("HELP: maybe your repository history is too shallow?");
2829+
println!("HELP: consider setting `rust.download-rustc=false` in config.toml");
2830+
println!("HELP: or fetch enough history to include one upstream commit");
2831+
crate::exit!(1);
28262832
}
2827-
println!("ERROR: could not find commit hash for downloading rustc");
2828-
println!("HELP: maybe your repository history is too shallow?");
2829-
println!("HELP: consider setting `rust.download-rustc=false` in config.toml");
2830-
println!("HELP: or fetch enough history to include one upstream commit");
2831-
crate::exit!(1);
28322833
}
2834+
} else {
2835+
channel::read_commit_info_file(&self.src)
2836+
.map(|info| info.sha.trim().to_owned())
2837+
.expect("git-commit-info is missing in the project root")
28332838
};
28342839

28352840
if CiEnv::is_ci() && {
@@ -2901,6 +2906,11 @@ impl Config {
29012906
option_name: &str,
29022907
if_unchanged: bool,
29032908
) -> Option<String> {
2909+
assert!(
2910+
self.rust_info.is_managed_git_subrepository(),
2911+
"Can't run `Config::last_modified_commit` on a non-git source."
2912+
);
2913+
29042914
// Look for a version to compare to based on the current commit.
29052915
// Only commits merged by bors will have CI artifacts.
29062916
let commit = get_closest_merge_commit(Some(&self.src), &self.git_config(), &[]).unwrap();

0 commit comments

Comments
 (0)