Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 903cddb

Browse files
committedJan 19, 2025
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 <work@onurozkan.dev>
1 parent 8e59cf9 commit 903cddb

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
@@ -2873,21 +2873,26 @@ impl Config {
28732873
allowed_paths.push(":!library");
28742874
}
28752875

2876-
// Look for a version to compare to based on the current commit.
2877-
// Only commits merged by bors will have CI artifacts.
2878-
let commit = match self.last_modified_commit(&allowed_paths, "download-rustc", if_unchanged)
2879-
{
2880-
Some(commit) => commit,
2881-
None => {
2882-
if if_unchanged {
2883-
return None;
2876+
let commit = if self.rust_info.is_managed_git_subrepository() {
2877+
// Look for a version to compare to based on the current commit.
2878+
// Only commits merged by bors will have CI artifacts.
2879+
match self.last_modified_commit(&allowed_paths, "download-rustc", if_unchanged) {
2880+
Some(commit) => commit,
2881+
None => {
2882+
if if_unchanged {
2883+
return None;
2884+
}
2885+
println!("ERROR: could not find commit hash for downloading rustc");
2886+
println!("HELP: maybe your repository history is too shallow?");
2887+
println!("HELP: consider setting `rust.download-rustc=false` in config.toml");
2888+
println!("HELP: or fetch enough history to include one upstream commit");
2889+
crate::exit!(1);
28842890
}
2885-
println!("ERROR: could not find commit hash for downloading rustc");
2886-
println!("HELP: maybe your repository history is too shallow?");
2887-
println!("HELP: consider setting `rust.download-rustc=false` in config.toml");
2888-
println!("HELP: or fetch enough history to include one upstream commit");
2889-
crate::exit!(1);
28902891
}
2892+
} else {
2893+
channel::read_commit_info_file(&self.src)
2894+
.map(|info| info.sha.trim().to_owned())
2895+
.expect("git-commit-info is missing in the project root")
28912896
};
28922897

28932898
if CiEnv::is_ci() && {
@@ -2969,6 +2974,11 @@ impl Config {
29692974
option_name: &str,
29702975
if_unchanged: bool,
29712976
) -> Option<String> {
2977+
assert!(
2978+
self.rust_info.is_managed_git_subrepository(),
2979+
"Can't run `Config::last_modified_commit` on a non-git source."
2980+
);
2981+
29722982
// Look for a version to compare to based on the current commit.
29732983
// Only commits merged by bors will have CI artifacts.
29742984
let commit = get_closest_merge_commit(Some(&self.src), &self.git_config(), &[]).unwrap();

0 commit comments

Comments
 (0)
Failed to load comments.