Skip to content

Assorted bootstrap LLVM refactors (part 3/N) - #161247

Merged
rust-bors[bot] merged 6 commits into
rust-lang:mainfrom
Kobzol:bootstrap-llvm-3
Aug 24, 2026
Merged

Assorted bootstrap LLVM refactors (part 3/N)#161247
rust-bors[bot] merged 6 commits into
rust-lang:mainfrom
Kobzol:bootstrap-llvm-3

Conversation

@Kobzol

@Kobzol Kobzol commented Aug 17, 2026

Copy link
Copy Markdown
Member

View all comments

Continuation of #160916.

This PR removes the llvm_out function, and makes it explicit when we need to build the host LLVM.

Before, bootstrap used to just arbitrarily run a llvm-config binary, even though it might not have been executable on the given host. Now, if we need to execute it, the host LLVM will always be explicitly built. It is possible that there are some cases where this will build LLVM where it didn't before, but that should only happen if you were on a target A, built LLVM for target B, and by sheer luck A could execute code for B (where A != B).
In any case, it is now explicit, so if we encounter such situation, we can fix it without depending on implicit assumptions (well, there are still thousands of other assumptions, but you get my point).

After this, I'll work on centralizing the sanity checking of downloading LLVM inside the LlvmFromCi step, which will allow us to log the exact reason why download-ci-llvm might not have been applied, and also enable downloading LLVM from CI for non-host targets.

r? jieyouxu

@rustbot

rustbot commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

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

@rustbot rustbot added 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) labels Aug 17, 2026
@rustbot

rustbot commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

jieyouxu is currently at their maximum review capacity.
They may take a while to respond.

Comment thread src/bootstrap/src/core/builder/mod.rs Outdated
@rust-log-analyzer

This comment has been minimized.

@jieyouxu jieyouxu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICT this generally looks good. One question on the test change.

View changes since this review

Comment thread src/bootstrap/src/core/builder/tests.rs Outdated
Comment thread src/bootstrap/src/core/build_steps/compile.rs

@jieyouxu jieyouxu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, r=me after pr ci green
@bors rollup=never note="bootstrap llvm rework just in case"

View changes since this review

@Kobzol

Kobzol commented Aug 18, 2026

Copy link
Copy Markdown
Member Author

@bors r=jieyouxu

@rust-bors

rust-bors Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 781ef03 has been approved by jieyouxu

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 18, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Member

@bors p=6 scheduling

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Aug 19, 2026
Assorted bootstrap LLVM refactors (part 3/N)

Continuation of #160916.

This PR removes the `llvm_out` function, and makes it explicit when we need to build the host LLVM.

Before, bootstrap used to just arbitrarily run a `llvm-config` binary, even though it might not have been executable on the given host. Now, if we need to execute it, the host LLVM will always be explicitly built. It is possible that there are some cases where this will build LLVM where it didn't before, but that should only happen if you were on a target A, built LLVM for target B, and by sheer luck A could execute code for B (where A != B).
In any case, it is now explicit, so if we encounter such situation, we can fix it without depending on implicit assumptions (well, there are still thousands of other assumptions, but you get my point).

After this, I'll work on centralizing the sanity checking of downloading LLVM inside the `LlvmFromCi` step, which will allow us to log the exact reason why `download-ci-llvm` might not have been applied, and also enable downloading LLVM from CI for non-host targets.

r? jieyouxu
@rust-log-analyzer

This comment has been minimized.

@rust-bors rust-bors Bot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 19, 2026
@rust-bors

rust-bors Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

💔 Test for 55e7b47 failed: CI. Failed job:

@rust-bors rust-bors Bot 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 Aug 20, 2026
@Kobzol

Kobzol commented Aug 20, 2026

Copy link
Copy Markdown
Member Author

@bors try jobs=dist-aarch64-freebsd

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Aug 20, 2026
Assorted bootstrap LLVM refactors (part 3/N)


try-job: dist-aarch64-freebsd
@rust-log-analyzer

This comment has been minimized.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 24, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Aug 24, 2026
Assorted bootstrap LLVM refactors (part 3/N)


try-job: dist-aarch64-freebsd
@rust-log-analyzer

This comment has been minimized.

@rust-bors rust-bors Bot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Aug 24, 2026
@rust-bors

rust-bors Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

💔 Test for ad9d7cd failed: CI. Failed job:

@rust-log-analyzer

This comment has been minimized.

@Kobzol

Kobzol commented Aug 24, 2026

Copy link
Copy Markdown
Member Author

@bors r-

@rust-bors rust-bors Bot removed the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Aug 24, 2026
@rust-bors

rust-bors Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

This pull request was unapproved.

View changes since this unapproval

@Kobzol

Kobzol commented Aug 24, 2026

Copy link
Copy Markdown
Member Author

@bors try jobs=dist-aarch64-freebsd

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Aug 24, 2026
Assorted bootstrap LLVM refactors (part 3/N)


try-job: dist-aarch64-freebsd
@rust-bors

rust-bors Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: cb0b8f1 (cb0b8f1324f425f453c52fbb5176c2b0bcde7103)
Base parent: 04a3cad (04a3cad16c522be4fd15ca76d3c119c14be68954)

@Kobzol

Kobzol commented Aug 24, 2026

Copy link
Copy Markdown
Member Author

@bors r=jieyouxu

@rust-bors

rust-bors Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 730b9d8 has been approved by jieyouxu

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 24, 2026
@rust-bors

This comment has been minimized.

@rust-bors rust-bors Bot added merged-by-bors This PR was explicitly merged by bors. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 24, 2026
@rust-bors

rust-bors Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

☀️ Test successful - CI
Approved by: jieyouxu
Duration: 3h 7m 36s
Pushing ac62df9 to main...

@rust-bors
rust-bors Bot merged commit ac62df9 into rust-lang:main Aug 24, 2026
15 checks passed
@rustbot rustbot added this to the 1.100.0 milestone Aug 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor
What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 347a1db (parent) -> ac62df9 (this PR)

Test differences

Show 4 test diffs

4 doctest diffs were found. These are ignored, as they are noisy.

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard ac62df9b49f9b9036af2a4957db70bf3850785e1 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-x86_64-llvm-mingw: 1h 14m -> 2h 10m (+74.1%)
  2. dist-i686-msvc: 1h 22m -> 2h 6m (+53.3%)
  3. i686-msvc-1: 2h 5m -> 3h 3m (+46.6%)
  4. x86_64-gnu-gcc-core-tests: 16m 31s -> 10m 29s (-36.5%)
  5. x86_64-gnu-stdlib-semver-check: 16m 34s -> 10m 36s (-36.0%)
  6. dist-x86_64-solaris: 1h 18m -> 1h 44m (+33.1%)
  7. i686-gnu-2: 1h 45m -> 1h 12m (-31.7%)
  8. dist-x86_64-netbsd: 1h 13m -> 1h 32m (+25.8%)
  9. dist-arm-linux-musl: 1h 48m -> 1h 21m (-25.3%)
  10. dist-powerpc64le-linux-musl: 1h 35m -> 1h 12m (-23.8%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@Kobzol
Kobzol deleted the bootstrap-llvm-3 branch August 24, 2026 14:01
@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (ac62df9): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This perf run didn't have relevant results for this metric.

Max RSS (memory usage)

This perf run didn't have relevant results for this metric.

Cycles

Results (primary 0.2%, secondary 3.4%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.2% [2.2%, 2.2%] 1
Regressions ❌
(secondary)
3.4% [3.4%, 3.4%] 1
Improvements ✅
(primary)
-1.8% [-1.8%, -1.8%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.2% [-1.8%, 2.2%] 2

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 468.927s -> 475.143s (1.33%)
Artifact size: 400.24 MiB -> 400.28 MiB (0.01%)

rust-bors Bot pushed a commit that referenced this pull request Sep 1, 2026
Assorted bootstrap LLVM refactors (part 4/N)



Continuation on #161247.

This PR completely removes handling of git changes or LLVM downloads from config parsing, and moves it into the `LlvmFromCi` step. Thanks to that, we now also allow downloading LLVM for non-host targets.

There is one annoyance related to that, and that is that `download-ci-llvm` now applies to all targets for which you try to build LLVM (d'uh), but that also means that if (for whatever reason) LLVM fails to be downloaded from CI, the build will fail. So if you build for target T2 from target T1:
- If you want to download T1, but build T2, that's not possible to express.
- If T2 fails to be downloaded, the build fails, even if it could be built locally.

I think that we mostly have four options how to deal with this:
1. Just ignore it and wait to see if someone complains.
2. Revert the change and always download only for the host target. Worked so far. However, downloading LLVM for non-host targets would be quite useful for further bootstrap improvements and refactorings, because the current logic around sysroots and libdirs is.. convoluted, to say the last, and making cross-compilation easier would help with that a lot.
3. Allow specifying `download-ci-llvm` *per target* in the target config section. So that you can say that you want to download for T1, but build for T2.
4. Make download failures non-fatal, and cause them to trigger a local build. This would also help with removing the hacky `is_ci_llvm_available_for_target` logic, which hard-codes a bunch of targets to "know" which ones offer LLVM and which don't. We could just try to download, and if the result is 404, then we print a warning and continue with building (but this is slightly orthogonal, we can do this even if we don't make LLVM build failures non-fatal).

I think that 3 or 4 would be the best solution, perhaps slightly opting for 4. If we get a 404, there's no way we can download, so we build instead. If we get a different error, we still make the failed download fail the build. And only if someone has a use-case for 3, we'd add the new config.

Already before this PR, we did this:
```
// If download-ci-llvm=true we also want to check that CI llvm is available
b && llvm::is_ci_llvm_available_for_target(&dwn_ctx.host_target, asserts)
```
so if LLVM wasn't available, we just silently reverted from `download-ci-llvm=true` to `download-ci-llvm=false`. The 4. proposal would just generalize that, to actually check whether the LLVM files are present on the CDN or not.

The problem with 4. is that you can't really set any custom build options for LLVM though, because if you also enable `download-ci-llvm`, the config sanity check will tell you to GTFO :( So we would probably need to make some changes there.

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

Labels

A-testsuite Area: The testsuite used to check the correctness of rustc merged-by-bors This PR was explicitly merged by bors. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants