Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[do not merge] beta test for git change detection (#138591) #138597

Draft
wants to merge 30 commits into
base: beta
Choose a base branch
from

Conversation

Kobzol
Copy link
Contributor

@Kobzol Kobzol commented Mar 17, 2025

Opening to test CI/bootstrap changes from #138591.

r? @ghost

try-job: x86_64-gnu-aux

@rustbot rustbot added A-compiletest Area: The compiletest test runner A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. labels Mar 17, 2025
@rustbot
Copy link
Collaborator

rustbot commented Mar 17, 2025

This PR changes how GCC is built. Consider updating src/bootstrap/download-ci-gcc-stamp.

Some changes occurred in src/tools/compiletest

cc @jieyouxu

This PR modifies src/bootstrap/src/core/config.

If appropriate, please update CONFIG_CHANGE_HISTORY in src/bootstrap/src/utils/change_tracker.rs.

This PR changes how LLVM is built. Consider updating src/bootstrap/download-ci-llvm-stamp.

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

@Kobzol
Copy link
Contributor Author

Kobzol commented Mar 17, 2025

@bors try

@bors
Copy link
Contributor

bors commented Mar 17, 2025

⌛ Trying commit 3775e26 with merge 2033bd4...

bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 17, 2025
[do not merge] beta test for git change detection (rust-lang#138591)

Opening to test CI/bootstrap changes.

r? `@ghost`

try-job: x86_64-gnu-stable
try-job: x86_64-gnu
try-job: x86_64-gnu-llvm-19-1
try-job: dist-x86_64-linux
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Mar 17, 2025

💔 Test failed - checks-actions

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 17, 2025
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Mar 17, 2025

💔 Test failed - checks-actions

@rust-log-analyzer

This comment has been minimized.

@Kobzol Kobzol marked this pull request as draft March 17, 2025 13:20
@onur-ozkan
Copy link
Member

onur-ozkan commented Mar 17, 2025

Can you make sure it doesn't break when CI rustc is in use? You can add bootstrap to allowed paths for if-unchanged logic.

@Kobzol
Copy link
Contributor Author

Kobzol commented Mar 17, 2025

I'm not fully sure what are you asking, tbh 😅 It's not trivial to make this PR green, because I selectively cherry picked only a few commits, we are in the middle of the beta cycle, so getting a beta PR green is kind of difficult. I only added a log of the detected SHAs, and that's it :)

The logic should work the same way for GCC, LLVM and rustc, the only difference is the set of modified paths, otherwise the logic is now unified.

@Kobzol
Copy link
Contributor Author

Kobzol commented Mar 17, 2025

Ah, you want me to test a builder that should trigger download-ci-rustc where it actually tries to download rustc from CI, and since this PR only modifies bootstrap, I can just temporarily allow list it. Did I get it right? :)

@onur-ozkan
Copy link
Member

Ah, you want me to test a builder that should trigger download-ci-rustc where it actually tries to download rustc from CI, and since this PR only modifies bootstrap, I can just temporarily allow list it. Did I get it right? :)

Yes, that's right :)

@Kobzol
Copy link
Contributor Author

Kobzol commented Mar 18, 2025

Hmm, I realized that there are way more changes in this PR than just bootstrap though, but anyway, I'll allowlist all.

@rust-log-analyzer

This comment has been minimized.

@Kobzol
Copy link
Contributor Author

Kobzol commented Mar 18, 2025

@bors try

@bors
Copy link
Contributor

bors commented Mar 18, 2025

⌛ Trying commit 506d23d with merge 3e10e1f...

bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 18, 2025
[do not merge] beta test for git change detection (rust-lang#138591)

Opening to test CI/bootstrap changes from rust-lang#138591.

r? `@ghost`

try-job: x86_64-gnu-aux
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Mar 18, 2025

💔 Test failed - checks-actions

@Kobzol
Copy link
Contributor Author

Kobzol commented Mar 18, 2025

@bors try

@bors
Copy link
Contributor

bors commented Mar 18, 2025

⌛ Trying commit bbe2d72 with merge 392c200...

bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 18, 2025
[do not merge] beta test for git change detection (rust-lang#138591)

Opening to test CI/bootstrap changes from rust-lang#138591.

r? `@ghost`

try-job: x86_64-gnu-aux
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-tools failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
   Compiling build_helper v0.1.0 (/checkout/src/build_helper)
    Finished `dev` profile [unoptimized] target(s) in 15.79s
##[endgroup]
WARN: currently no CI rustc builds have rustc debug assertions enabled. Please either set `rust.debug-assertions` to `false` if you want to use download CI rustc or set `rust.download-rustc` to `false`.
DOWNLOAD_CI_RUSTC freshness: HasLocalModifications { upstream: "8c7969a3ae4a292789a415618fd3ebd35bee38e9" }

thread 'main' panicked at src/bootstrap/src/core/config/config.rs:1915:13:
DOWNLOAD_CI_RUSTC: None
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Build completed unsuccessfully in 0:00:25
make: *** [Makefile:98: prepare] Error 1
Command failed. Attempt 2/5:
##[group]Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.05s
##[endgroup]
WARN: currently no CI rustc builds have rustc debug assertions enabled. Please either set `rust.debug-assertions` to `false` if you want to use download CI rustc or set `rust.download-rustc` to `false`.
DOWNLOAD_CI_RUSTC freshness: HasLocalModifications { upstream: "8c7969a3ae4a292789a415618fd3ebd35bee38e9" }

thread 'main' panicked at src/bootstrap/src/core/config/config.rs:1915:13:
DOWNLOAD_CI_RUSTC: None
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Build completed unsuccessfully in 0:00:00
make: *** [Makefile:98: prepare] Error 1
Command failed. Attempt 3/5:
##[group]Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.05s
##[endgroup]
WARN: currently no CI rustc builds have rustc debug assertions enabled. Please either set `rust.debug-assertions` to `false` if you want to use download CI rustc or set `rust.download-rustc` to `false`.
DOWNLOAD_CI_RUSTC freshness: HasLocalModifications { upstream: "8c7969a3ae4a292789a415618fd3ebd35bee38e9" }

thread 'main' panicked at src/bootstrap/src/core/config/config.rs:1915:13:
DOWNLOAD_CI_RUSTC: None
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Build completed unsuccessfully in 0:00:00
make: *** [Makefile:98: prepare] Error 1
Command failed. Attempt 4/5:
##[group]Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.05s
##[endgroup]
WARN: currently no CI rustc builds have rustc debug assertions enabled. Please either set `rust.debug-assertions` to `false` if you want to use download CI rustc or set `rust.download-rustc` to `false`.
DOWNLOAD_CI_RUSTC freshness: HasLocalModifications { upstream: "8c7969a3ae4a292789a415618fd3ebd35bee38e9" }

thread 'main' panicked at src/bootstrap/src/core/config/config.rs:1915:13:
DOWNLOAD_CI_RUSTC: None
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Build completed unsuccessfully in 0:00:00
make: *** [Makefile:98: prepare] Error 1
Command failed. Attempt 5/5:
##[group]Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.05s
##[endgroup]
WARN: currently no CI rustc builds have rustc debug assertions enabled. Please either set `rust.debug-assertions` to `false` if you want to use download CI rustc or set `rust.download-rustc` to `false`.
DOWNLOAD_CI_RUSTC freshness: HasLocalModifications { upstream: "8c7969a3ae4a292789a415618fd3ebd35bee38e9" }

thread 'main' panicked at src/bootstrap/src/core/config/config.rs:1915:13:
DOWNLOAD_CI_RUSTC: None
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Build completed unsuccessfully in 0:00:00

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-aux failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
file:.git/config remote.origin.url=https://github.com/rust-lang-ci/rust
file:.git/config remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
file:.git/config gc.auto=0
file:.git/config http.https://github.com/.extraheader=AUTHORIZATION: basic ***
file:.git/config branch.try.remote=origin
file:.git/config branch.try.merge=refs/heads/try
file:.git/config submodule.library/backtrace.active=true
file:.git/config submodule.library/backtrace.url=https://github.com/rust-lang/backtrace-rs.git
file:.git/config submodule.library/stdarch.active=true
file:.git/config submodule.library/stdarch.url=https://github.com/rust-lang/stdarch.git
file:.git/config submodule.src/doc/book.active=true
---
   Compiling termcolor v1.4.1
   Compiling home v0.5.9
    Finished `dev` profile [unoptimized] target(s) in 27.96s
##[endgroup]
DOWNLOAD_CI_RUSTC freshness: HasLocalModifications { upstream: "8c7969a3ae4a292789a415618fd3ebd35bee38e9" }

thread 'main' panicked at src/bootstrap/src/core/config/config.rs:1915:13:
DOWNLOAD_CI_RUSTC: None
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Build completed unsuccessfully in 0:00:38
make: *** [Makefile:98: prepare] Error 1
Command failed. Attempt 2/5:
##[group]Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.05s
##[endgroup]
DOWNLOAD_CI_RUSTC freshness: HasLocalModifications { upstream: "8c7969a3ae4a292789a415618fd3ebd35bee38e9" }

thread 'main' panicked at src/bootstrap/src/core/config/config.rs:1915:13:
DOWNLOAD_CI_RUSTC: None
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Build completed unsuccessfully in 0:00:00
make: *** [Makefile:98: prepare] Error 1
Command failed. Attempt 3/5:
##[group]Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.05s
##[endgroup]
DOWNLOAD_CI_RUSTC freshness: HasLocalModifications { upstream: "8c7969a3ae4a292789a415618fd3ebd35bee38e9" }

thread 'main' panicked at src/bootstrap/src/core/config/config.rs:1915:13:
DOWNLOAD_CI_RUSTC: None
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Build completed unsuccessfully in 0:00:00
make: *** [Makefile:98: prepare] Error 1
Command failed. Attempt 4/5:
##[group]Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.05s
##[endgroup]
DOWNLOAD_CI_RUSTC freshness: HasLocalModifications { upstream: "8c7969a3ae4a292789a415618fd3ebd35bee38e9" }

thread 'main' panicked at src/bootstrap/src/core/config/config.rs:1915:13:
DOWNLOAD_CI_RUSTC: None
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Build completed unsuccessfully in 0:00:00
make: *** [Makefile:98: prepare] Error 1
Command failed. Attempt 5/5:
##[group]Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.05s
##[endgroup]
DOWNLOAD_CI_RUSTC freshness: HasLocalModifications { upstream: "8c7969a3ae4a292789a415618fd3ebd35bee38e9" }

thread 'main' panicked at src/bootstrap/src/core/config/config.rs:1915:13:
DOWNLOAD_CI_RUSTC: None
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Build completed unsuccessfully in 0:00:00

@bors
Copy link
Contributor

bors commented Mar 18, 2025

💔 Test failed - checks-actions

@Kobzol
Copy link
Contributor Author

Kobzol commented Mar 18, 2025

bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 18, 2025
Refactor git change detection in bootstrap

While working on rust-lang#138395, I finally found the courage to delve into the insides of git path change detection in bootstrap, which is used (amongst other things) to detect if we should rebuilt od download `[llvm|rustc|gcc]`. I found it a bit hard to understand, and given that this code was historically quite fragile, I thought that it would be better to rebuild it from scratch.

The previous approach had a bunch of limitations:
- It separated the computation of "are there local changes?" and "what upstream SHA should we use?" even though these two things are intertwined.
- It used hacks to work around what happens on CI.
- It had special cases for CI scattered throughout the codebase, rather than centralized in one place.
- It wasn't documented enough and didn't have tests for the git behavior.

The current approach should hopefully resolve all of that. I implemented a single entrypoint called `check_path_modifications` (naming bikeshed pending, half of the time I spend on this PR was thinking about names, as it's quite tricky here..) that explicitly receives a mode of operation (in CI or outside CI), and accordingly figures out that upstream SHA that we should use for downloading artifacts and it also figures out if there are any local changes. Users of this function can then use this unified output to implement `download-ci-X` and other functionality.

I also added a bunch of integration tests that literally spawn a git repository on disk and then check that the function can deal with various situations (PR CI, auto/try CI, local builds). The tests are super fast and run in parallel, as they are currently in `build_helper` and not in `bootstrap`.

After I built this inner layer, I used it for downloading GCC, LLVM and rustc. The latter two (and especially rustc) were using the `last_modified_commit` function before, but in all cases but one this function was actually only used to check if there are any local changes, which was IMO confusing. The LLVM handling would deserve a bit of refactoring, but that's a larger change that can be done as a follow-up.

In the future we could cache the results of `check_path_modifications` to reduce the number of git invocations, but I don't think that it should be excessive even now.

I hope that the implementation is now clear and easy to understand, so that in combination with the tests we can have more confidence that it does what we want. I tried to include a lot of documentation in the code, so I won't be repeating the actual implementation details here, if there are any questions, I'll add the answers to the documentation too :)

The new approach explicitly supports three scenarios:
- Running on PR CI, where we have one upstream bors parent commit and one PR merge commit made by GitHub.
- Running on try/auto CI, where we have one upstream bors parent commit and one PR merge commit made by bors.
- Running locally, where we assume that we have at least one upstream bors parent commit in our git history.

I removed the handling of upstreams on CI, as I think that it shouldn't be needed and I considered it to be a hack. However, it's possible that there are other use-cases that I haven't considered, so I want to ask around if people have other situations than the three use-cases described above. If there are other such use-cases, I would like to include them in the new centralized implementation and add them to the git test suite, rather than going back to the old ways :)

In particular, the code before relied on `git merge-base`, but I don't see why we can't just lookup the most recent bors commit and assume that is a merge commit that is also upstream? I might be running into Chesterton's Fence here :)

CC `@pietroalbini` To make sure that this won't break downstream users of Rust's CI.

Best reviewed commit by commit.

Companion PRs:
- For testing beta: rust-lang#138597

r? `@onur-ozkan`

try-job: x86_64-gnu-aux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-compiletest Area: The compiletest test runner A-meta Area: Issues & PRs about the rust-lang/rust repository itself A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) A-run-make Area: port run-make Makefiles to rmake.rs A-rustc-dev-guide Area: rustc-dev-guide A-rustdoc-json Area: Rustdoc JSON backend A-rustdoc-search Area: Rustdoc's search feature A-testsuite Area: The testsuite used to check the correctness of rustc A-tidy Area: The tidy tool A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic O-apple Operating system: Apple (macOS, iOS, tvOS, visionOS, watchOS) O-hermit Operating System: Hermit O-itron Operating System: ITRON O-SGX Target: SGX O-solid Operating System: SOLID O-unix Operating system: Unix-like O-wasi Operating system: Wasi, Webassembly System Interface O-wasm Target: WASM (WebAssembly), http://webassembly.org/ O-windows Operating system: Windows PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. T-release Relevant to the release subteam, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants