Add --dist-std bootstrap flag - #158264
adamgemmell wants to merge 6 commits into
Conversation
|
r? @clubby789 rustbot has assigned @clubby789. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
r? @Kobzol |
|
|
| # That causes some mir-opt tests which inline functions from the standard library to | ||
| # break when incremental compilation is enabled. So this overrides the "no inlining | ||
| # during incremental builds" heuristic for the standard library. | ||
| "-Zunstable-options", |
There was a problem hiding this comment.
What is this necessary for? None of the other rustflags are both unstable and not behind -Z, so -Zunstable-options shouldn't be necessary afaict.
There was a problem hiding this comment.
Cargo does pass it unconditionally here, though I didn't disable it doing so in this commit. It's not necessary for the dist profile I agree, but might still be for some certain configs for other builds
There was a problem hiding this comment.
Ended up reverting this change as -Cforce-frame-pointers=non-leaf requires -Zunstable options
|
What is the motivation for this? This would make it harder for distros to change how the standard library gets built, right? For example a distro might want to enforce overflow checks for the standard library for security reasons. Or they might want to disable LTO because the codegen backend they chose doesn't support LTO. Or they might want to build the standard library with full debuginfo. I also personally have used |
|
The motivation is enforcing that any configuration for dist builds lives somewhere that build-std can see it. We had some discussion on zulip a while ago: https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Standard.20library.20dist.20configuration. From that the two main complications that led to this approach were:
The intention is that panic never triggers, it's a sanity check for bootstrap itself. Yes, this is quite disruptive and annoying, and anyone doing dist builds would need to translate all their options to the library manifest, but distros need to do this anyway so the build-std artifacts have the same compatibility as the prebuilt std. I'm not sure on the best way to make this less disruptive - perhaps it should only ignore config options when |
For example for the debuginfo options, if a distro wants to enable full debuginfo for their precompiled standard library, they probably don't want to enable full debuginfo for end users that use |
|
The initial version of build-std we're stabilising doesn't support customising the standard library, it should match the distributed std as closely as possible. When we change Cargo to use the dist profile, we'll add an unstable option that keeps the "user profile" behaviour build-std currently has. |
|
You are adding several of these flags even to the non-dist profiles. |
|
I've only moved over options that are unconditionally passed by bootstrap. This is because I'd like to explore doing something similar to RUSTFLAGS as I have for profile variables here, but I'm happy to defer that. |
|
The |
|
LTO is off for the standard library's own profile. Presumably if it were on then LTO would run twice for it if the user requested it too? |
|
|
|
It won't be with build-std's currently approved RFCs, as until we introduce |
This comment has been minimized.
This comment has been minimized.
|
@bors retry |
|
❗ You can only retry pull requests that are approved and have a previously failed auto build. |
|
I've retried the PR CI from the github interface for you. Bors is not involved with PR CI, only try runs and pre-merge CI. |
68c4a2a to
0c0800e
Compare
This comment has been minimized.
This comment has been minimized.
| // Some std configuration exists in its own profile | ||
| (Mode::Std, _) => "DIST", | ||
| (Mode::DistStd, _) => { | ||
| panic!("Attempted to override the distributed std's profile with {name}") |
There was a problem hiding this comment.
Capturing bjorn's message here in a comment, namely that we're still working out if this is the right approach for distros and contributors who use x.py dist
0c0800e to
8517e47
Compare
|
Hmm, hmm... This is tricky. Gating whether we choose This might also introduce more differences between stdlib that we test on CI and stdlib that we dist. There are already differences there caused by various CI config options, but now it would also exercise different paths in bootstrap, which doesn't seem good to me. There are various approaches at making this work; bjorn's |
|
@Kobzol I asked Fabian here and came the same conclusion on bootstrap subcommands. I considered gating the behaviour on DEPLOY but at least debian doesn't seem to set that - I'm not sure if it's intended for external users or that it's just useful for rust's CI. Probably a flag would be better. It's not clear to me how a rustc-build-sysroot layer could help or change much here. It could take responsibility for configuring the DistStd away from the library profile, but while tidier and more flexible that doesn't seem functionally better. I don't understand the motivation behind bootstrap using |
This comment has been minimized.
This comment has been minimized.
8517e47 to
b9ac4f0
Compare
|
This PR modifies If appropriate, please update |
This comment has been minimized.
This comment has been minimized.
b9ac4f0 to
7d1b074
Compare
|
Some changes occurred in src/tools/cargo cc @weihanglo |
|
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. |
This comment has been minimized.
This comment has been minimized.
DistStd uses the dist profile for the standard library while Std uses debug/release, but otherwise these two are the same in this commit.
As a previous commit changes CI to use the dev/release profiles by default we need to move the dist profile settings there for now.
This commit adds a panic when attempting to override the dist profile of the standard library. This means that the standard library will no longer respect some bootstrap settings when built with `--dist-std`, instead forcing them to be set in the dist profile of the standard library.
7d1b074 to
a9755d5
Compare
|
I've reworked this PR significantly to tighten its scope. The @weihanglo sorry for the noise, no cargo changes are intended in this |
--dist-std bootstrap flag
View all comments
The configuration used by std needs to be moved to somewhere the new build-std can see it. This PR moves settings that Cargo can model in its profile to the dist profile and ensures that bootstrap does not try to override them.
This PR adds a new Mode, DistStd, to bootstrap, as proposed by @Kobzol a while ago, which is used when building the standard library and when passing the
--dist-stdflag to certain bootstrap commands. This new mode:distprofile in the library workspace, added in Move bootstrap configuration to library workspace #149514The PR also moves some rustflags that are unconditionally passed when building std over to the library workspace.
Planned followups for this work:
-Zbuild-stdto consume standard library config files which will allow for configuring the standard library much more flexibly--dist-std, which involves moving all configuration from the jobs (and CI scripts like run.sh) over to the library workspace or configuration.--dist-stdis passed.🤖 LLM disclosure: I used Codex primarily to explain certain concepts in bootstrap to me and asked it to review my branch before sharing it upstream. There is no LLM-generated content in the branch or PR itself.