Skip to content

refactor configuration parsing #122090

Closed
@onur-ozkan

Description

@onur-ozkan

Currently in config parser flow there are multiple other tasks involved such as validating stage 0 binaries and LLVM tools and downloading the beta toolchain. These logics are currently coupled in a single function as can be seen here:

config.initial_rustc = if let Some(rustc) = rustc {
if !flags.skip_stage0_validation {
config.check_stage0_version(&rustc, "rustc");
}
PathBuf::from(rustc)
} else {
config.download_beta_toolchain();
config.out.join(config.build.triple).join("stage0/bin/rustc")
};
config.initial_cargo = if let Some(cargo) = cargo {
if !flags.skip_stage0_validation {
config.check_stage0_version(&cargo, "cargo");
}
PathBuf::from(cargo)
} else {
config.download_beta_toolchain();
config.out.join(config.build.triple).join("stage0/bin/cargo")
};

Doing this results in performing downloads, expecting valid stage 0 binaries and LLVM tools even in unit tests of bootstrap itself.

To avoid this issue, we pass some configurations from the test functions like this:

"--config=/does/not/exist".to_owned(),
"--skip-stage0-validation".to_owned(),

However, this approach is not sustainable as it could be easily missed when adding new tests. If we simplify parser functions to only parse values and perform validations and downloads immediately after the configuration parsing, this could resolve all the issues and make this process much simpler.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-cleanupCategory: PRs that clean code up or issues documenting cleanup.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions