Skip to content

Commit 4dffd4d

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 0ca702d commit 4dffd4d

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
@@ -2863,21 +2863,26 @@ impl Config {
28632863
allowed_paths.push(":!library");
28642864
}
28652865

2866-
// Look for a version to compare to based on the current commit.
2867-
// Only commits merged by bors will have CI artifacts.
2868-
let commit = match self.last_modified_commit(&allowed_paths, "download-rustc", if_unchanged)
2869-
{
2870-
Some(commit) => commit,
2871-
None => {
2872-
if if_unchanged {
2873-
return None;
2866+
let commit = if self.rust_info.is_managed_git_subrepository() {
2867+
// Look for a version to compare to based on the current commit.
2868+
// Only commits merged by bors will have CI artifacts.
2869+
match self.last_modified_commit(&allowed_paths, "download-rustc", if_unchanged) {
2870+
Some(commit) => commit,
2871+
None => {
2872+
if if_unchanged {
2873+
return None;
2874+
}
2875+
println!("ERROR: could not find commit hash for downloading rustc");
2876+
println!("HELP: maybe your repository history is too shallow?");
2877+
println!("HELP: consider setting `rust.download-rustc=false` in config.toml");
2878+
println!("HELP: or fetch enough history to include one upstream commit");
2879+
crate::exit!(1);
28742880
}
2875-
println!("ERROR: could not find commit hash for downloading rustc");
2876-
println!("HELP: maybe your repository history is too shallow?");
2877-
println!("HELP: consider setting `rust.download-rustc=false` in config.toml");
2878-
println!("HELP: or fetch enough history to include one upstream commit");
2879-
crate::exit!(1);
28802881
}
2882+
} else {
2883+
channel::read_commit_info_file(&self.src)
2884+
.map(|info| info.sha.trim().to_owned())
2885+
.expect("git-commit-info is missing in the project root")
28812886
};
28822887

28832888
if CiEnv::is_ci() && {
@@ -2957,6 +2962,11 @@ impl Config {
29572962
option_name: &str,
29582963
if_unchanged: bool,
29592964
) -> Option<String> {
2965+
assert!(
2966+
self.rust_info.is_managed_git_subrepository(),
2967+
"Can't run `Config::last_modified_commit` on a non-git source."
2968+
);
2969+
29602970
// Look for a version to compare to based on the current commit.
29612971
// Only commits merged by bors will have CI artifacts.
29622972
let commit = get_closest_merge_commit(Some(&self.src), &self.git_config(), &[]).unwrap();

0 commit comments

Comments
 (0)