Skip to content

bootstrap: consider filtering compiler in the git log command for download-rustc #113250

Description

@jyn514

Right now, download-rustc picks a commit to download as follows:

  1. Choose the last commit authored by bors as the commit we are comparing to:

    rust/src/bootstrap/config.rs

    Lines 1921 to 1927 in 85c4ea0

    let merge_base = output(
    self.git()
    .arg("rev-list")
    .arg(format!("--author={}", self.stage0_metadata.config.git_merge_commit_email))
    .args(&["-n1", "--first-parent", "HEAD"]),
    );
    let commit = merge_base.trim_end();
  2. Check if there are changes to compiler/ since that commit:

    rust/src/bootstrap/config.rs

    Lines 1936 to 1941 in 85c4ea0

    // Warn if there were changes to the compiler or standard library since the ancestor commit.
    let has_changes = !t!(self
    .git()
    .args(&["diff-index", "--quiet", &commit, "--", &compiler, &library])
    .status())
    .success();

This is slightly different than how download-ci-llvm works:

  1. Choose the last commit author by bors that modified src/llvm-project:

    rust/src/bootstrap/llvm.rs

    Lines 130 to 144 in 68d458b

    let llvm_sha = if is_git {
    let mut rev_list = config.git();
    rev_list.args(&[
    PathBuf::from("rev-list"),
    format!("--author={}", config.stage0_metadata.config.git_merge_commit_email).into(),
    "-n1".into(),
    "--first-parent".into(),
    "HEAD".into(),
    "--".into(),
    config.src.join("src/llvm-project"),
    config.src.join("src/bootstrap/download-ci-llvm-stamp"),
    // the LLVM shared object file is named `LLVM-12-rust-{version}-nightly`
    config.src.join("src/version"),
    ]);
    output(&mut rev_list).trim().to_owned()

This results in some differences in the commit we pick. In particular, download-rustc always chooses the most recent commit authored by bors, even if that commit didn't modify compiler/:

; git log --author=bors -n1 --first-parent 2d0aa57684e10f7b3d3fe740ee18d431181583ad -c --stat --oneline
2d0aa57684e Auto merge of #112645 - Kobzol:ci-mingw-merge, r=pietroalbini

 .github/workflows/ci.yml     | 22 ++++------------------
 src/bootstrap/mk/Makefile.in | 14 ++++++--------
 src/ci/github-actions/ci.yml | 30 ++++--------------------------

So we download both more and less often than we need to: more often because we always download the latest bors commit, less often because we only consider compiler/ and library/, so if someone has modified the way bootstrap builds rustc locally, we won't notice.

In #112143 (comment) I tried this changing this approach, but it didn't actually work, because --author interacts strangely with -- compiler/ when used with rollups:

; git log -n1 --author=bors f217411bacbe943ead9dfca93a91dff0753c2a96 -c --stat --oneline
f217411bacb Auto merge of #112774 - compiler-errors:rollup-z8oof6r, r=compiler-errors

 compiler/rustc_hir_typeck/src/demand.rs                          |  7 +--
 compiler/rustc_hir_typeck/src/method/confirm.rs                  | 26 +++++++-
 compiler/rustc_hir_typeck/src/method/mod.rs                      | 21 +++++++
 compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs        | 85 ++++++++------------------
 compiler/rustc_resolve/src/imports.rs                            | 93 +++++++++++++----------------
 src/bootstrap/mk/Makefile.in                                     |  7 ++-
 src/bootstrap/test.rs                                            |  3 +-
 src/bootstrap/util.rs                                            |  2 -
 src/ci/docker/run.sh                                             |  2 -
 src/tools/build_helper/src/ci.rs                                 |  6 +-
 tests/ui/typeck/dont-record-adjustments-when-pointing-at-arg.rs  | 29 +++++++++
 .../typeck/dont-record-adjustments-when-pointing-at-arg.stderr   | 17 ++++++
 12 files changed, 167 insertions(+), 131 deletions(-)
; git log -n1 --author=bors f217411bacbe943ead9dfca93a91dff0753c2a96 -c --stat --oneline -- compiler/
939786223f2 Auto merge of #112636 - clubby789:no-capture-array-ref, r=cjgillot

 compiler/rustc_hir_typeck/src/expr_use_visitor.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

It would be nice to use the same approach for LLVM and ci-rustc, but we'd have to work around this git limitation somehow. Here is an idea i came up with that may or may not work

Details
        //   1. Find the last commit that modified compiler/: CHANGE
        //   2. Find the last commit authored by bors (if in CI, excluding the current commit): BORS
        //   3. Confirm that CHANGE is in the history of BORS

note that if we start doing this, we'll need to introduce a download-ci-rustc-stamp file (like download-ci-llvm-stamp) in case we change the way we build rustc; otherwise we might download artifacts that wouldn't match the artifacts you'd get if you build locally.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-download-rustcArea: The `rust.download-rustc` build option.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions