Auto merge of #128588 - onur-ozkan:clean-up-bootstrap-internals, r=albertlarsan68
bootstrap minor improvements and clean-ups 3rd commit fixes https://github.com/rust-lang/rust/issues/128553#issuecomment-2266119948.
This commit is contained in:
commit
5601d14249
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
use crate::core::build_steps::doc::DocumentationFormat;
|
use crate::core::build_steps::doc::DocumentationFormat;
|
||||||
use crate::core::build_steps::tool::{self, Tool};
|
use crate::core::build_steps::tool::{self, Tool};
|
||||||
|
use crate::core::build_steps::vendor::default_paths_to_vendor;
|
||||||
use crate::core::build_steps::{compile, llvm};
|
use crate::core::build_steps::{compile, llvm};
|
||||||
use crate::core::builder::{Builder, Kind, RunConfig, ShouldRun, Step};
|
use crate::core::builder::{Builder, Kind, RunConfig, ShouldRun, Step};
|
||||||
use crate::core::config::TargetSelection;
|
use crate::core::config::TargetSelection;
|
||||||
@ -1004,35 +1005,18 @@ fn run(self, builder: &Builder<'_>) -> GeneratedTarball {
|
|||||||
if builder.rust_info().is_managed_git_subrepository()
|
if builder.rust_info().is_managed_git_subrepository()
|
||||||
|| builder.rust_info().is_from_tarball()
|
|| builder.rust_info().is_from_tarball()
|
||||||
{
|
{
|
||||||
// FIXME: This code looks _very_ similar to what we have in `src/core/build_steps/vendor.rs`
|
|
||||||
// perhaps it should be removed in favor of making `dist` perform the `vendor` step?
|
|
||||||
|
|
||||||
builder.require_and_update_all_submodules();
|
builder.require_and_update_all_submodules();
|
||||||
|
|
||||||
// Vendor all Cargo dependencies
|
// Vendor all Cargo dependencies
|
||||||
let mut cmd = command(&builder.initial_cargo);
|
let mut cmd = command(&builder.initial_cargo);
|
||||||
cmd.arg("vendor")
|
cmd.arg("vendor").arg("--versioned-dirs");
|
||||||
.arg("--versioned-dirs")
|
|
||||||
.arg("--sync")
|
for p in default_paths_to_vendor(builder) {
|
||||||
.arg(builder.src.join("./src/tools/cargo/Cargo.toml"))
|
cmd.arg("--sync").arg(p);
|
||||||
.arg("--sync")
|
}
|
||||||
.arg(builder.src.join("./src/tools/rust-analyzer/Cargo.toml"))
|
|
||||||
.arg("--sync")
|
cmd
|
||||||
.arg(builder.src.join("./compiler/rustc_codegen_cranelift/Cargo.toml"))
|
// Will read the libstd Cargo.toml which uses the unstable `public-dependency` feature.
|
||||||
.arg("--sync")
|
|
||||||
.arg(builder.src.join("./compiler/rustc_codegen_gcc/Cargo.toml"))
|
|
||||||
.arg("--sync")
|
|
||||||
.arg(builder.src.join("./library/Cargo.toml"))
|
|
||||||
.arg("--sync")
|
|
||||||
.arg(builder.src.join("./src/bootstrap/Cargo.toml"))
|
|
||||||
.arg("--sync")
|
|
||||||
.arg(builder.src.join("./src/tools/opt-dist/Cargo.toml"))
|
|
||||||
.arg("--sync")
|
|
||||||
.arg(builder.src.join("./src/tools/rustc-perf/Cargo.toml"))
|
|
||||||
.arg("--sync")
|
|
||||||
.arg(builder.src.join("./src/tools/rustbook/Cargo.toml"))
|
|
||||||
// Will read the libstd Cargo.toml
|
|
||||||
// which uses the unstable `public-dependency` feature.
|
|
||||||
.env("RUSTC_BOOTSTRAP", "1")
|
.env("RUSTC_BOOTSTRAP", "1")
|
||||||
.current_dir(plain_dst_src);
|
.current_dir(plain_dst_src);
|
||||||
|
|
||||||
|
@ -247,9 +247,11 @@ fn setup_config_toml(path: &PathBuf, profile: Profile, config: &Config) {
|
|||||||
impl Step for Link {
|
impl Step for Link {
|
||||||
type Output = ();
|
type Output = ();
|
||||||
const DEFAULT: bool = true;
|
const DEFAULT: bool = true;
|
||||||
|
|
||||||
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
||||||
run.alias("link")
|
run.alias("link")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_run(run: RunConfig<'_>) {
|
fn make_run(run: RunConfig<'_>) {
|
||||||
if run.builder.config.dry_run() {
|
if run.builder.config.dry_run() {
|
||||||
return;
|
return;
|
||||||
@ -262,21 +264,30 @@ fn make_run(run: RunConfig<'_>) {
|
|||||||
}
|
}
|
||||||
fn run(self, builder: &Builder<'_>) -> Self::Output {
|
fn run(self, builder: &Builder<'_>) -> Self::Output {
|
||||||
let config = &builder.config;
|
let config = &builder.config;
|
||||||
|
|
||||||
if config.dry_run() {
|
if config.dry_run() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !rustup_installed(builder) {
|
||||||
|
println!("WARNING: `rustup` is not installed; Skipping `stage1` toolchain linking.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let stage_path =
|
let stage_path =
|
||||||
["build", config.build.rustc_target_arg(), "stage1"].join(MAIN_SEPARATOR_STR);
|
["build", config.build.rustc_target_arg(), "stage1"].join(MAIN_SEPARATOR_STR);
|
||||||
if !rustup_installed(builder) {
|
|
||||||
eprintln!("`rustup` is not installed; cannot link `stage1` toolchain");
|
if stage_dir_exists(&stage_path[..]) && !config.dry_run() {
|
||||||
} else if stage_dir_exists(&stage_path[..]) && !config.dry_run() {
|
|
||||||
attempt_toolchain_link(builder, &stage_path[..]);
|
attempt_toolchain_link(builder, &stage_path[..]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rustup_installed(builder: &Builder<'_>) -> bool {
|
fn rustup_installed(builder: &Builder<'_>) -> bool {
|
||||||
command("rustup").arg("--version").run_capture_stdout(builder).is_success()
|
let mut rustup = command("rustup");
|
||||||
|
rustup.arg("--version");
|
||||||
|
|
||||||
|
rustup.allow_failure().run_always().run_capture_stdout(builder).is_success()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn stage_dir_exists(stage_path: &str) -> bool {
|
fn stage_dir_exists(stage_path: &str) -> bool {
|
||||||
|
@ -1091,18 +1091,13 @@ fn run(mut $sel, $builder: &Builder<'_>) -> PathBuf {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: tools need to be also added to `Builder::get_step_descriptions` in `builder.rs`
|
|
||||||
// to make `./x.py build <tool>` work.
|
|
||||||
tool_extended!((self, builder),
|
tool_extended!((self, builder),
|
||||||
Cargofmt, "src/tools/rustfmt", "cargo-fmt", stable=true;
|
Cargofmt, "src/tools/rustfmt", "cargo-fmt", stable=true;
|
||||||
CargoClippy, "src/tools/clippy", "cargo-clippy", stable=true;
|
CargoClippy, "src/tools/clippy", "cargo-clippy", stable=true;
|
||||||
Clippy, "src/tools/clippy", "clippy-driver", stable=true, add_bins_to_sysroot = ["clippy-driver", "cargo-clippy"];
|
Clippy, "src/tools/clippy", "clippy-driver", stable=true, add_bins_to_sysroot = ["clippy-driver", "cargo-clippy"];
|
||||||
Miri, "src/tools/miri", "miri", stable=false, add_bins_to_sysroot = ["miri"];
|
Miri, "src/tools/miri", "miri", stable=false, add_bins_to_sysroot = ["miri"];
|
||||||
CargoMiri, "src/tools/miri/cargo-miri", "cargo-miri", stable=true, add_bins_to_sysroot = ["cargo-miri"];
|
CargoMiri, "src/tools/miri/cargo-miri", "cargo-miri", stable=true, add_bins_to_sysroot = ["cargo-miri"];
|
||||||
// FIXME: tool_std is not quite right, we shouldn't allow nightly features.
|
Rls, "src/tools/rls", "rls", stable=true;
|
||||||
// But `builder.cargo` doesn't know how to handle ToolBootstrap in stages other than 0,
|
|
||||||
// and this is close enough for now.
|
|
||||||
Rls, "src/tools/rls", "rls", stable=true, tool_std=true;
|
|
||||||
Rustfmt, "src/tools/rustfmt", "rustfmt", stable=true, add_bins_to_sysroot = ["rustfmt", "cargo-fmt"];
|
Rustfmt, "src/tools/rustfmt", "rustfmt", stable=true, add_bins_to_sysroot = ["rustfmt", "cargo-fmt"];
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -4,6 +4,26 @@
|
|||||||
use crate::core::builder::{Builder, RunConfig, ShouldRun, Step};
|
use crate::core::builder::{Builder, RunConfig, ShouldRun, Step};
|
||||||
use crate::utils::exec::command;
|
use crate::utils::exec::command;
|
||||||
|
|
||||||
|
/// List of default paths used for vendoring for `x vendor` and dist tarballs.
|
||||||
|
pub fn default_paths_to_vendor(builder: &Builder<'_>) -> Vec<PathBuf> {
|
||||||
|
let mut paths = vec![];
|
||||||
|
for p in [
|
||||||
|
"src/tools/cargo/Cargo.toml",
|
||||||
|
"src/tools/rust-analyzer/Cargo.toml",
|
||||||
|
"compiler/rustc_codegen_cranelift/Cargo.toml",
|
||||||
|
"compiler/rustc_codegen_gcc/Cargo.toml",
|
||||||
|
"library/Cargo.toml",
|
||||||
|
"src/bootstrap/Cargo.toml",
|
||||||
|
"src/tools/rustbook/Cargo.toml",
|
||||||
|
"src/tools/rustc-perf/Cargo.toml",
|
||||||
|
"src/tools/opt-dist/Cargo.toml",
|
||||||
|
] {
|
||||||
|
paths.push(builder.src.join(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
paths
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
|
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
|
||||||
pub(crate) struct Vendor {
|
pub(crate) struct Vendor {
|
||||||
sync_args: Vec<PathBuf>,
|
sync_args: Vec<PathBuf>,
|
||||||
@ -42,16 +62,8 @@ fn run(self, builder: &Builder<'_>) -> Self::Output {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sync these paths by default.
|
// Sync these paths by default.
|
||||||
for p in [
|
for p in default_paths_to_vendor(builder) {
|
||||||
"src/tools/cargo/Cargo.toml",
|
cmd.arg("--sync").arg(p);
|
||||||
"src/tools/rust-analyzer/Cargo.toml",
|
|
||||||
"compiler/rustc_codegen_cranelift/Cargo.toml",
|
|
||||||
"compiler/rustc_codegen_gcc/Cargo.toml",
|
|
||||||
"library/Cargo.toml",
|
|
||||||
"src/bootstrap/Cargo.toml",
|
|
||||||
"src/tools/rustbook/Cargo.toml",
|
|
||||||
] {
|
|
||||||
cmd.arg("--sync").arg(builder.src.join(p));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Also sync explicitly requested paths.
|
// Also sync explicitly requested paths.
|
||||||
|
@ -1455,15 +1455,11 @@ pub fn bare_cargo(
|
|||||||
assert_eq!(target, compiler.host);
|
assert_eq!(target, compiler.host);
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.config.rust_optimize.is_release() {
|
if self.config.rust_optimize.is_release() &&
|
||||||
// FIXME: cargo bench/install do not accept `--release`
|
// cargo bench/install do not accept `--release` and miri doesn't want it
|
||||||
// and miri doesn't want it
|
!matches!(cmd_kind, Kind::Bench | Kind::Install | Kind::Miri | Kind::MiriSetup | Kind::MiriTest)
|
||||||
match cmd_kind {
|
{
|
||||||
Kind::Bench | Kind::Install | Kind::Miri | Kind::MiriSetup | Kind::MiriTest => {}
|
cargo.arg("--release");
|
||||||
_ => {
|
|
||||||
cargo.arg("--release");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove make-related flags to ensure Cargo can correctly set things up
|
// Remove make-related flags to ensure Cargo can correctly set things up
|
||||||
|
@ -620,8 +620,6 @@ fn download_component(
|
|||||||
};
|
};
|
||||||
|
|
||||||
// For the beta compiler, put special effort into ensuring the checksums are valid.
|
// For the beta compiler, put special effort into ensuring the checksums are valid.
|
||||||
// FIXME: maybe we should do this for download-rustc as well? but it would be a pain to update
|
|
||||||
// this on each and every nightly ...
|
|
||||||
let checksum = if should_verify {
|
let checksum = if should_verify {
|
||||||
let error = format!(
|
let error = format!(
|
||||||
"src/stage0 doesn't contain a checksum for {url}. \
|
"src/stage0 doesn't contain a checksum for {url}. \
|
||||||
|
Loading…
Reference in New Issue
Block a user