Skip to content

Commit 08a7a57

Browse files
Rollup merge of #89655 - tlyu:find-non-merge-commits, r=jyn514
bootstrap: don't use `--merges` to look for commit hashes for downloading artifacts Shallow clones (and possibly worktrees, though I can't seem to reproduce the problem there) can cause `git rev-list --merges` to falsely return no results, even if a merge commit is present. Stop using the `--merges` option when looking for commit hashes that have build artifacts. `--first-parent` and `[email protected]` should be sufficient. Also exit with an error if the configuration asks for artifacts to be downloaded and we can't determine an appropriate commit hash to use to download artifacts. Fixes #87890. r? ``@jyn514`` ``@rustbot`` label +A-rustbuild +A-contributor-roadblock
2 parents 86d6d2b + 8e46742 commit 08a7a57

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/bootstrap/bootstrap.py

+15-3
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ def download_toolchain(self, stage0=True, rustc_channel=None):
460460
# LLVM more often than necessary.
461461
#
462462
# This git command finds that commit SHA, looking for bors-authored
463-
# merges that modified src/llvm-project or other relevant version
463+
# commits that modified src/llvm-project or other relevant version
464464
# stamp files.
465465
#
466466
# This works even in a repository that has not yet initialized
@@ -470,7 +470,7 @@ def download_toolchain(self, stage0=True, rustc_channel=None):
470470
]).decode(sys.getdefaultencoding()).strip()
471471
llvm_sha = subprocess.check_output([
472472
"git", "rev-list", "[email protected]", "-n1",
473-
"--merges", "--first-parent", "HEAD",
473+
"--first-parent", "HEAD",
474474
"--",
475475
"{}/src/llvm-project".format(top_level),
476476
"{}/src/bootstrap/download-ci-llvm-stamp".format(top_level),
@@ -540,6 +540,12 @@ def _download_component_helper(
540540
unpack(tarball, tarball_suffix, self.bin_root(stage0), match=pattern, verbose=self.verbose)
541541

542542
def _download_ci_llvm(self, llvm_sha, llvm_assertions):
543+
if not llvm_sha:
544+
print("error: could not find commit hash for downloading LLVM")
545+
print("help: maybe your repository history is too shallow?")
546+
print("help: consider disabling `download-ci-llvm`")
547+
print("help: or fetch enough history to include one upstream commit")
548+
exit(1)
543549
cache_prefix = "llvm-{}-{}".format(llvm_sha, llvm_assertions)
544550
cache_dst = os.path.join(self.build_dir, "cache")
545551
rustc_cache = os.path.join(cache_dst, cache_prefix)
@@ -685,9 +691,15 @@ def maybe_download_ci_toolchain(self):
685691
# Only commits merged by bors will have CI artifacts.
686692
merge_base = [
687693
"git", "rev-list", "[email protected]", "-n1",
688-
"--merges", "--first-parent", "HEAD"
694+
"--first-parent", "HEAD"
689695
]
690696
commit = subprocess.check_output(merge_base, universal_newlines=True).strip()
697+
if not commit:
698+
print("error: could not find commit hash for downloading rustc")
699+
print("help: maybe your repository history is too shallow?")
700+
print("help: consider disabling `download-rustc`")
701+
print("help: or fetch enough history to include one upstream commit")
702+
exit(1)
691703

692704
# Warn if there were changes to the compiler or standard library since the ancestor commit.
693705
status = subprocess.call(["git", "diff-index", "--quiet", commit, "--", compiler, library])

0 commit comments

Comments
 (0)