Skip to content

Conversation

@adamgemmell
Copy link
Contributor

This creates a new "dist" profile in the standard library which contains configuration for the distributed std artifacts previously contained in bootstrap, in order for a future build-std implementation to use. bootstrap.toml settings continue to override these defaults, as would any RUSTFLAGS provided. I've left some cargo features driven by bootstrap for a future patch.

Unfortunately, profiles aren't expressive enough to express per-target overrides, so this risc-v example was not able to be moved across. This could go in its own profile which Cargo would have to know to use, and then the panic-abort rustflags overrides would need duplicating again. Doesn't seem like a sustainable solution as a couple similar overrides would explode the number of lines here.

We could use a cargo config in the library workspace for this, but this then would have to be respected by Cargo's build-std implementation and I'm not yet sure about the tradeoffs there.

This patch also introduces a build probe to deal with the test crate's stability which is obviously not ideal, I'm open to other solutions here or can back that change out for now if anyone prefers.

cc @Mark-Simulacrum rust-lang/rfcs#3874

@rustbot rustbot added A-CI Area: Our Github Actions CI 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. labels Dec 1, 2025
@rustbot
Copy link
Collaborator

rustbot commented Dec 1, 2025

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added 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-libs Relevant to the library team, which will review and decide on the PR/issue. labels Dec 1, 2025
@Kobzol
Copy link
Member

Kobzol commented Dec 13, 2025

Unfortunately, profiles aren't expressive enough to express per-target overrides, so this risc-v example was not able to be moved across. This could go in its own profile which Cargo would have to know to use, and then the panic-abort rustflags overrides would need duplicating again. Doesn't seem like a sustainable solution as a couple similar overrides would explode the number of lines here.

Doesn't rustc default to -Cforce-unwind-tables=yes since 1.92.0 (https://blog.rust-lang.org/2025/12/11/Rust-1.92.0/#emit-unwind-tables-even-when-cpanic-abort-is-enabled-on-linux)? Or is this not relevant for the standard library? In that case the special case to enable -Cforce-unwind-tables=yes for RISC-V stdlib could be removed. CC @saethlin if you perhaps know.

Copy link
Member

@Kobzol Kobzol left a comment

Choose a reason for hiding this comment

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

Left some comments.

In general the changes made so far look relatively minimal and simple. However, currently just moving things to the stdlib's Cargo.toml doesn't change the fact that bootstrap can arbitrarily override them (and likely it does override a bunch of them), in CI dist jobs that can have arbitrary bootstrap configuration enabled.

If we wanted to ensure that this won't happen, we should have some sanity check that will simply deny configuring any cargo overrides and rustflags for the stdlib when we are doing a dist build on CI.

View changes since this review

@Mark-Simulacrum Mark-Simulacrum 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 Dec 28, 2025
@saethlin
Copy link
Member

CC @saethlin if you perhaps know.

I don't know. Also somehow this mention of me never subscribed me to this PR, which is weird.

@adamgemmell
Copy link
Contributor Author

Doesn't rustc default to -Cforce-unwind-tables=yes since 1.92.0 (https://blog.rust-lang.org/2025/12/11/Rust-1.92.0/#emit-unwind-tables-even-when-cpanic-abort-is-enabled-on-linux)? Or is this not relevant for the standard library? In that case the special case to enable -Cforce-unwind-tables=yes for RISC-V stdlib could be removed. CC saethlin if you perhaps know.

The best I can tell this is only for linux, and any riscv target that isn't based on linux will default to no uwtables if the panic strategy isn't unwind.

What we could do is enable uwtables by default for all riscv targets in the target spec, which would 1. always build rustc on riscv hosts with uwtables (which would only change something for targets with host tools and panic abort and I suspect there aren't any) and 2. always build user code with uwtables by default, which can be overridden with -Cforce-unwind-tables=no.

I don't know if that's desirable and don't really want to force the change while we don't have to - my point that profiles aren't expressive enough still stands as we might want to do a per-target override like this in the future. We might have to read the library workspace's cargo config and I don't know how reasonable that is yet.

@adamgemmell
Copy link
Contributor Author

In general the changes made so far look relatively minimal and simple. However, currently just moving things to the stdlib's Cargo.toml doesn't change the fact that bootstrap can arbitrarily override them (and likely it does override a bunch of them), in CI dist jobs that can have arbitrary bootstrap configuration enabled.

If we wanted to ensure that this won't happen, we should have some sanity check that will simply deny configuring any cargo overrides and rustflags for the stdlib when we are doing a dist build on CI.

Thanks - yes, I think I still need to do a proper scan of the dist jobs to minimise what's set there. I'm not sure how to implement a sanity check given that bootstrap will always have to pass some configuration that can't be expressed in profiles. Is it enough to check that no CARGO_PROFILE* env vars are set?

@adamgemmell adamgemmell force-pushed the dev/adagem01/bootstrap-to-library branch from 0bae09c to 1e439c3 Compare January 9, 2026 18:10
@rustbot

This comment has been minimized.

@Kobzol
Copy link
Member

Kobzol commented Jan 9, 2026

I think that we don't have to deal with that in this PR; moving as much stuff as possible to the library workspace is already an improvement. Adding sanity checks that ensure that bootstrap doesn't do anything extra (which Cargo couldn't replicate) can be one of follow-up steps.

@adamgemmell adamgemmell force-pushed the dev/adagem01/bootstrap-to-library branch from 1e439c3 to ffce9ca Compare January 20, 2026 13:58
@rustbot

This comment has been minimized.

@adamgemmell
Copy link
Contributor Author

I think that we don't have to deal with that in this PR; moving as much stuff as possible to the library workspace is already an improvement. Adding sanity checks that ensure that bootstrap doesn't do anything extra (which Cargo couldn't replicate) can be one of follow-up steps.

Looks like there's two ways to do this - a bit of a hack, which disables setting profile values (and maybe some rustflags) with an if Mode::Std && is_running_on_ci check on every bit of configuration, or some sweeping changes to bootstrap that let config values default to nothing, which then uses the library workspace (which is a bit complicated when it comes to stuff like rust.debuglevel-std which inherits from rust.debug like bjorn3 mentioned above). I'll leave it to a future PR. For now I think this is functionally consistent even if some profile configuration is unconditionally overridden.

@Kobzol
Copy link
Member

Kobzol commented Jan 20, 2026

We definitely don't want to do any CI-specific checks in bootstrap, unless it's the only way to solve something. It's tricky, because I assume that some people will want to build their own std with bootstrap, with overridden settings, without the "build-std-compatibility" mode. I almost wonder if this "build-std-compatible" stdlib should be a separate bootstrap step or Mode, to avoid mushing those two things together. In any case, that's for follow-up PRs.

@Kobzol
Copy link
Member

Kobzol commented Jan 20, 2026

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot pushed a commit that referenced this pull request Jan 20, 2026
…, r=<try>

Move bootstrap configuration to library workspace
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 20, 2026
Copy link
Member

@Kobzol Kobzol left a comment

Choose a reason for hiding this comment

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

Left some comments and kicked off a try build, so that we can test perf. and also if -Zbuild-std still works.

View changes since this review

…l based on the default values of rust.debug[...] keys
@adamgemmell adamgemmell force-pushed the dev/adagem01/bootstrap-to-library branch from ffce9ca to 368504e Compare January 20, 2026 16:53
@rustbot
Copy link
Collaborator

rustbot commented Jan 20, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 20, 2026

☀️ Try build successful (CI)
Build commit: ef62af0 (ef62af0fa83fabd80c8d32eb103a24c01e546b57, parent: fffc4fcf96b30bc838551de5104d74f82400b35b)

@rust-timer

This comment has been minimized.

@Kobzol
Copy link
Member

Kobzol commented Jan 20, 2026

rustup-toolchain-install-master ef62af0fa83fabd80c8d32eb103a24c01e546b57 --component rust-src
cargo new foo
cd foo
cargo +ef62af0fa83fabd80c8d32eb103a24c01e546b57 build -Zbuild-std

Seems to work 👍

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (ef62af0): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results (primary -3.3%, secondary -2.4%)

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

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-3.3% [-3.3%, -3.3%] 1
Improvements ✅
(secondary)
-2.4% [-2.6%, -2.2%] 2
All ❌✅ (primary) -3.3% [-3.3%, -3.3%] 1

Cycles

Results (primary 3.5%, secondary -4.8%)

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

mean range count
Regressions ❌
(primary)
3.5% [3.5%, 3.5%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.8% [-4.8%, -4.8%] 1
All ❌✅ (primary) 3.5% [3.5%, 3.5%] 1

Binary size

Results (primary -0.0%, secondary -0.0%)

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

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.0% [-0.0%, -0.0%] 14
Improvements ✅
(secondary)
-0.0% [-0.1%, -0.0%] 6
All ❌✅ (primary) -0.0% [-0.0%, -0.0%] 14

Bootstrap: 475.617s -> 475.457s (-0.03%)
Artifact size: 383.32 MiB -> 383.29 MiB (-0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 20, 2026
@adamgemmell
Copy link
Contributor Author

adamgemmell commented Jan 21, 2026

rustup-toolchain-install-master ef62af0fa83fabd80c8d32eb103a24c01e546b57 --component rust-src
cargo new foo
cd foo
cargo +ef62af0fa83fabd80c8d32eb103a24c01e546b57 build -Zbuild-std

Seems to work 👍

Hopefully the only noticeable change would be from the test crate build probe as -Zbuild-std right now as it doesn't respect any configuration in the library workspace.

@Kobzol
Copy link
Member

Kobzol commented Jan 21, 2026

I thought about the probe a bit and it seems to me that on nightly it should work the same as before, so hopefully it still works :)

@adamgemmell
Copy link
Contributor Author

Oh, true, the fix only changes things after stabilisation, perhaps a bit premature 😂

Those max RSS/cycle count changes seem quite high, though only for a couple benchmarks. Is that within expectations?

@Kobzol
Copy link
Member

Kobzol commented Jan 21, 2026

That's almost certainly noise. The binary size results looked more "interesting", but it's possible that PGO/BOLT perturbations change the size of the stdlib, which in turn changes the sizes of the benchmarks. To be sure, it would be useful to check the libstd before/after (fffc4fcf96b30bc838551de5104d74f82400b35b -> ef62af0fa83fabd80c8d32eb103a24c01e546b57) using diffoscope or something, to see what are the specified changes in the stdlib object file.

@adamgemmell
Copy link
Contributor Author

I think it's ok: https://try.diffoscope.org/gbbssutugsab.html

The online version of the tool doesn't show whole diffs, but I've checked with readelf locally and for all debug sections an equal amount of lines were added vs removed.

@Kobzol
Copy link
Member

Kobzol commented Jan 21, 2026

Ok, good, thanks. One thing that this changes is that it is not really possible anymore to build stdlib without optimizations, but I don't know if anyone actually used that.

Let's see what happens on nightly.

@bors r+ rollup=never

@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 21, 2026

📌 Commit 368504e has been approved by Kobzol

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 Jan 21, 2026
@adamgemmell
Copy link
Contributor Author

Will make a note to fix that, thanks

@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 Jan 21, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 21, 2026

☀️ Test successful - CI
Approved by: Kobzol
Duration: 3h 26m 1s
Pushing eda76d9 to main...

@rust-bors rust-bors bot merged commit eda76d9 into rust-lang:main Jan 21, 2026
12 checks passed
@rustbot rustbot added this to the 1.95.0 milestone Jan 21, 2026
@github-actions
Copy link
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 daa90b9 (parent) -> eda76d9 (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 eda76d9d1d133effbf7facb28168fd78d75fd434 --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. x86_64-rust-for-linux: 3131.6s -> 2740.1s (-12.5%)
  2. i686-gnu-2: 5948.4s -> 5228.0s (-12.1%)
  3. test-various: 7553.7s -> 6677.2s (-11.6%)
  4. x86_64-gnu-debug: 7278.7s -> 6442.1s (-11.5%)
  5. x86_64-gnu-miri: 5009.8s -> 4444.1s (-11.3%)
  6. x86_64-gnu-tools: 3786.9s -> 3367.6s (-11.1%)
  7. i686-gnu-1: 8285.9s -> 7422.3s (-10.4%)
  8. x86_64-gnu-distcheck: 8200.2s -> 7381.9s (-10.0%)
  9. pr-check-1: 1863.2s -> 1684.9s (-9.6%)
  10. aarch64-gnu-debug: 4550.8s -> 4129.9s (-9.2%)
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.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (eda76d9): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results (primary 2.2%, secondary -3.9%)

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)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.9% [-5.5%, -2.1%] 5
All ❌✅ (primary) 2.2% [2.2%, 2.2%] 1

Cycles

Results (primary 0.6%)

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

mean range count
Regressions ❌
(primary)
0.6% [0.6%, 0.6%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.6% [0.6%, 0.6%] 1

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 470.203s -> 471.204s (0.21%)
Artifact size: 383.19 MiB -> 383.19 MiB (-0.00%)

weihanglo added a commit to weihanglo/cargo that referenced this pull request Jan 22, 2026
rust-lang/rust#149514 added a build.rs to libtest,
which affected how Cargo print status message
(build.rs built first so Cargo printed `Compiling` first)
github-merge-queue bot pushed a commit to rust-lang/cargo that referenced this pull request Jan 22, 2026
### What does this PR try to resolve?

rust-lang/rust#149514 added a build.rs to libtest,
which affected how Cargo print status message
(build.rs was scheduled first because it has one dependent)

### How to test and review this PR?

See
<https://github.com/rust-lang/cargo/actions/runs/21232930264/job/61094884597?pr=16506>

```
thread 'basic' (9963) panicked at tests/build-std/main.rs:179:10:

---- expected: tests/build-std/main.rs:167:27
++++ actual:   stderr
   1    1 | [COMPILING] [..]
   2      - ...
   3      - [COMPILING] test v0.0.0 ([..])
        2 + [COMPILING] rustc-std-workspace-std v1.99.0 (/home/runner/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/src/rust/library/rustc-std-workspace-std)
        3 + [COMPILING] getopts v0.2.24
   4    4 | [COMPILING] foo v0.0.1 ([ROOT]/foo)
   5    5 | [FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
   6    6 | [RUNNING] unittests src/lib.rs (target/[HOST_TARGET]/debug/deps/foo-[HASH])
   7    7 | [RUNNING] unittests src/main.rs (target/[HOST_TARGET]/debug/deps/foo-[HASH])
   8    8 | [RUNNING] tests/smoke.rs (target/[HOST_TARGET]/debug/deps/smoke-[HASH])
   9    9 | [DOCTEST] foo

```
github-merge-queue bot pushed a commit to rust-lang/cargo that referenced this pull request Jan 22, 2026
### What does this PR try to resolve?

rust-lang/rust#149514 added a build.rs to libtest,
which affected how Cargo print status message
(build.rs was scheduled first because it has one dependent)

### How to test and review this PR?

See
<https://github.com/rust-lang/cargo/actions/runs/21232930264/job/61094884597?pr=16506>

```
thread 'basic' (9963) panicked at tests/build-std/main.rs:179:10:

---- expected: tests/build-std/main.rs:167:27
++++ actual:   stderr
   1    1 | [COMPILING] [..]
   2      - ...
   3      - [COMPILING] test v0.0.0 ([..])
        2 + [COMPILING] rustc-std-workspace-std v1.99.0 (/home/runner/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/src/rust/library/rustc-std-workspace-std)
        3 + [COMPILING] getopts v0.2.24
   4    4 | [COMPILING] foo v0.0.1 ([ROOT]/foo)
   5    5 | [FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
   6    6 | [RUNNING] unittests src/lib.rs (target/[HOST_TARGET]/debug/deps/foo-[HASH])
   7    7 | [RUNNING] unittests src/main.rs (target/[HOST_TARGET]/debug/deps/foo-[HASH])
   8    8 | [RUNNING] tests/smoke.rs (target/[HOST_TARGET]/debug/deps/smoke-[HASH])
   9    9 | [DOCTEST] foo

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

Labels

A-CI Area: Our Github Actions CI 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) T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants