-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
bootstrap: Make rust
options configurable per-stage
#112679
Comments
@Kobzol would applying this to |
PGO is already only applied to stage 2, so that is already working fine. Per stage profiles could help for options that are more "global" and which are used for everything (std, tools, compiler) in the function which generates shared cargo opts, as that is now difficult to override. So things like optimize=true, debuginfo, cgu=1, etc. |
@rustbot claim Let me give it a shot. |
@jyn514 Could you please take a look? Does this make sense? Do you think we need to move more parameters? You can modify the checkbox. |
jyn514 is currently not actively working on Rust, so I'd like to try help move this forward. There are several things to resolve in the "design". We could apply the per-stage configuration in two ways:
[rust]
codegen-units = 1
[rust.stage1]
codegen-units = 16
[rust]
codegen-units = { default = 1, stage1 = 16 } I think that the first option is better, since we define Then, we need a way to query this information. As suggested by @Mark-Simulacrum here, I think that it would make sense to allow querying configuration options with an optional parameter that describes the stage (I would make it optional and introduce a new function for this to avoid changing a million callsites in bootstrap at once). So if you ask for An additional question is how will this interact with the bootstrap stage re-design, and if we even want to keep a distinction of stageN. |
I agree, the first option appears to be the better choice in my opinion as well. The second option adds complexity and could potentially lead to breaking changes for current 'config.toml' usage. With the first option, existing configurations can continue to work seamlessly, and if a stage is not explicitly specified, the same configuration can be applied across all stages. This approach simplifies the handling of configurations and maintains backward compatibility. One challenge with this implementation is how to load configurations efficiently. For instance, if we lazy-load configurations at each stage, we won't be able to detect errors in invalid configurations until we reach that specific stage. If we change the |
Hi @hi-rustin, have you made any progress so far? Asking because this issue is somewhat of a blocker for #102600. |
No, I haven't. I have no time to work on it recently. |
There are several cases where it makes sense to have different configuration between different stages. A simple one is debuginfo - we enable
rust.debuginfo-level-std = 1
in dist builders, but only need it for stage 2, not stage 1. Another is optimization levels; for developing, it can make sense to build rustc withoptimize = true
but std withoptimize = false
(#112678).We should make it easier to configure this without using RUSTFLAGS_NOT_BOOTSTRAP, which is hard to discover and breaks caching if you get it wrong. I'm imagining something like
rust.stage1.debuginfo-level-std
, where any option underrust
is allowed to be configured per-stage. This also implies that any option underrust
should be applicable to a single stage; anything today that isn't should be moved tobuild
.Mentoring instructions:
channel
,musl_root
,rpath
).build
. I expect there to be a lot of these, so if possible add aliases from the old name to the new one - maybe add something likestruct MovedOptions { ... }
and then#[serde(flatten)] renamed: MovedOptions
in bothBuild
andRust
? Make an entry in src/bootstrap/changelog.md.struct PerStage<T> { stage0: T, stage1: T, stage2: T, default: T }
and use it everywhere inRust
; add it to thedefine_config
macro if that makes it easier. This is based off of https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/def/struct.PerNS.html and should have similar apis.src/bootstrap/config/tests.rs
.The text was updated successfully, but these errors were encountered: