Skip to content

Remove default config from bootstrap #145352

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

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

Shourya742
Copy link
Contributor

This PR removes the default config initialization from parse_inner, as it introduced many assumptions during config setup. Instead, each variable is now manually initialized to eliminate certain invariants in parse_inner and streamline the process.

The PR is still a WIP and has been opened for an initial review.

r? @Kobzol

@rustbot rustbot added 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) labels Aug 13, 2025
@rust-log-analyzer

This comment has been minimized.

@Shourya742 Shourya742 force-pushed the 2025-08-12-remove-default-config branch from e1f4e5c to 9662ff8 Compare August 13, 2025 13:04
@rust-log-analyzer
Copy link
Collaborator

The job tidy failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
   Compiling termcolor v1.4.1
error[E0609]: no field `download_rustc_commit` on type `std::option::Option<PathBuf>`
##[error]    --> src/bootstrap/src/core/config/config.rs:1118:49
     |
1118 |         if debug_assertions_requested && config.download_rustc_commit.is_some() {
     |                                                 ^^^^^^^^^^^^^^^^^^^^^ unknown field

For more information about this error, try `rustc --explain E0609`.
error: could not compile `bootstrap` (lib) due to 1 previous error
failed to run: /checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo build --manifest-path /checkout/src/bootstrap/Cargo.toml -Zroot-dir=/checkout --locked --features build-metrics
---
   Compiling bootstrap v0.0.0 (/checkout/src/bootstrap)
error[E0609]: no field `download_rustc_commit` on type `std::option::Option<PathBuf>`
##[error]    --> src/bootstrap/src/core/config/config.rs:1118:49
     |
1118 |         if debug_assertions_requested && config.download_rustc_commit.is_some() {
     |                                                 ^^^^^^^^^^^^^^^^^^^^^ unknown field

For more information about this error, try `rustc --explain E0609`.
error: could not compile `bootstrap` (lib) due to 1 previous error
failed to run: /checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo build --manifest-path /checkout/src/bootstrap/Cargo.toml -Zroot-dir=/checkout --locked --features build-metrics
---
   Compiling bootstrap v0.0.0 (/checkout/src/bootstrap)
error[E0609]: no field `download_rustc_commit` on type `std::option::Option<PathBuf>`
##[error]    --> src/bootstrap/src/core/config/config.rs:1118:49
     |
1118 |         if debug_assertions_requested && config.download_rustc_commit.is_some() {
     |                                                 ^^^^^^^^^^^^^^^^^^^^^ unknown field

For more information about this error, try `rustc --explain E0609`.
error: could not compile `bootstrap` (lib) due to 1 previous error
failed to run: /checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo build --manifest-path /checkout/src/bootstrap/Cargo.toml -Zroot-dir=/checkout --locked --features build-metrics
---
   Compiling bootstrap v0.0.0 (/checkout/src/bootstrap)
error[E0609]: no field `download_rustc_commit` on type `std::option::Option<PathBuf>`
##[error]    --> src/bootstrap/src/core/config/config.rs:1118:49
     |
1118 |         if debug_assertions_requested && config.download_rustc_commit.is_some() {
     |                                                 ^^^^^^^^^^^^^^^^^^^^^ unknown field

For more information about this error, try `rustc --explain E0609`.
error: could not compile `bootstrap` (lib) due to 1 previous error
failed to run: /checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo build --manifest-path /checkout/src/bootstrap/Cargo.toml -Zroot-dir=/checkout --locked --features build-metrics
---
   Compiling bootstrap v0.0.0 (/checkout/src/bootstrap)
error[E0609]: no field `download_rustc_commit` on type `std::option::Option<PathBuf>`
##[error]    --> src/bootstrap/src/core/config/config.rs:1118:49
     |
1118 |         if debug_assertions_requested && config.download_rustc_commit.is_some() {
     |                                                 ^^^^^^^^^^^^^^^^^^^^^ unknown field

For more information about this error, try `rustc --explain E0609`.
error: could not compile `bootstrap` (lib) due to 1 previous error
failed to run: /checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo build --manifest-path /checkout/src/bootstrap/Cargo.toml -Zroot-dir=/checkout --locked --features build-metrics

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.

Heh, I had feedback for you, but I see that Clippy did it for me in one of the commits xD Let me know once it's ready and I'll check the changes locally, but in general looks great.

let mut full_bootstrap = false;
let mut bootstrap_cache_path = None;
let mut extended = false;
let tools;
Copy link
Member

Choose a reason for hiding this comment

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

What does it mean for a variable to not be mut here? If the variable is initialized only once, I would just initialize it at the end of the function, in the Config { ... } struct literal.

let stage;
let keep_stage;
let keep_stage_std;
let mut src = {
Copy link
Member

Choose a reason for hiding this comment

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

Could you please group the variables that have an "interesting" (i.e. non-Default) default together? Although I assume that once you remove the let XXX vars and move them to the Config constructor, this will be less of an issue.

&get_toml,
);
let (mut toml, toml_path) = load_toml_config(&src, flags_config, &get_toml);
config = toml_path.clone();
Copy link
Member

Choose a reason for hiding this comment

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

Let's just initialize the variables at places where they are first used (let config;). I don't think that the ultra long list of variable declarations at the start of the function win us anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants