Skip to content

Commit 5601d14

Browse files
committed
Auto merge of #128588 - onur-ozkan:clean-up-bootstrap-internals, r=albertlarsan68
bootstrap minor improvements and clean-ups 3rd commit fixes #128553 (comment).
2 parents 4fe1e2b + 8d7c374 commit 5601d14

File tree

6 files changed

+52
-56
lines changed

6 files changed

+52
-56
lines changed

Diff for: src/bootstrap/src/core/build_steps/dist.rs

+9-25
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use object::BinaryFormat;
1919

2020
use crate::core::build_steps::doc::DocumentationFormat;
2121
use crate::core::build_steps::tool::{self, Tool};
22+
use crate::core::build_steps::vendor::default_paths_to_vendor;
2223
use crate::core::build_steps::{compile, llvm};
2324
use crate::core::builder::{Builder, Kind, RunConfig, ShouldRun, Step};
2425
use crate::core::config::TargetSelection;
@@ -1004,35 +1005,18 @@ impl Step for PlainSourceTarball {
10041005
if builder.rust_info().is_managed_git_subrepository()
10051006
|| builder.rust_info().is_from_tarball()
10061007
{
1007-
// FIXME: This code looks _very_ similar to what we have in `src/core/build_steps/vendor.rs`
1008-
// perhaps it should be removed in favor of making `dist` perform the `vendor` step?
1009-
10101008
builder.require_and_update_all_submodules();
10111009

10121010
// Vendor all Cargo dependencies
10131011
let mut cmd = command(&builder.initial_cargo);
1014-
cmd.arg("vendor")
1015-
.arg("--versioned-dirs")
1016-
.arg("--sync")
1017-
.arg(builder.src.join("./src/tools/cargo/Cargo.toml"))
1018-
.arg("--sync")
1019-
.arg(builder.src.join("./src/tools/rust-analyzer/Cargo.toml"))
1020-
.arg("--sync")
1021-
.arg(builder.src.join("./compiler/rustc_codegen_cranelift/Cargo.toml"))
1022-
.arg("--sync")
1023-
.arg(builder.src.join("./compiler/rustc_codegen_gcc/Cargo.toml"))
1024-
.arg("--sync")
1025-
.arg(builder.src.join("./library/Cargo.toml"))
1026-
.arg("--sync")
1027-
.arg(builder.src.join("./src/bootstrap/Cargo.toml"))
1028-
.arg("--sync")
1029-
.arg(builder.src.join("./src/tools/opt-dist/Cargo.toml"))
1030-
.arg("--sync")
1031-
.arg(builder.src.join("./src/tools/rustc-perf/Cargo.toml"))
1032-
.arg("--sync")
1033-
.arg(builder.src.join("./src/tools/rustbook/Cargo.toml"))
1034-
// Will read the libstd Cargo.toml
1035-
// which uses the unstable `public-dependency` feature.
1012+
cmd.arg("vendor").arg("--versioned-dirs");
1013+
1014+
for p in default_paths_to_vendor(builder) {
1015+
cmd.arg("--sync").arg(p);
1016+
}
1017+
1018+
cmd
1019+
// Will read the libstd Cargo.toml which uses the unstable `public-dependency` feature.
10361020
.env("RUSTC_BOOTSTRAP", "1")
10371021
.current_dir(plain_dst_src);
10381022

Diff for: src/bootstrap/src/core/build_steps/setup.rs

+15-4
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,11 @@ pub struct Link;
247247
impl Step for Link {
248248
type Output = ();
249249
const DEFAULT: bool = true;
250+
250251
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
251252
run.alias("link")
252253
}
254+
253255
fn make_run(run: RunConfig<'_>) {
254256
if run.builder.config.dry_run() {
255257
return;
@@ -262,21 +264,30 @@ impl Step for Link {
262264
}
263265
fn run(self, builder: &Builder<'_>) -> Self::Output {
264266
let config = &builder.config;
267+
265268
if config.dry_run() {
266269
return;
267270
}
271+
272+
if !rustup_installed(builder) {
273+
println!("WARNING: `rustup` is not installed; Skipping `stage1` toolchain linking.");
274+
return;
275+
}
276+
268277
let stage_path =
269278
["build", config.build.rustc_target_arg(), "stage1"].join(MAIN_SEPARATOR_STR);
270-
if !rustup_installed(builder) {
271-
eprintln!("`rustup` is not installed; cannot link `stage1` toolchain");
272-
} else if stage_dir_exists(&stage_path[..]) && !config.dry_run() {
279+
280+
if stage_dir_exists(&stage_path[..]) && !config.dry_run() {
273281
attempt_toolchain_link(builder, &stage_path[..]);
274282
}
275283
}
276284
}
277285

278286
fn rustup_installed(builder: &Builder<'_>) -> bool {
279-
command("rustup").arg("--version").run_capture_stdout(builder).is_success()
287+
let mut rustup = command("rustup");
288+
rustup.arg("--version");
289+
290+
rustup.allow_failure().run_always().run_capture_stdout(builder).is_success()
280291
}
281292

282293
fn stage_dir_exists(stage_path: &str) -> bool {

Diff for: src/bootstrap/src/core/build_steps/tool.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -1091,18 +1091,13 @@ macro_rules! tool_extended {
10911091
}
10921092
}
10931093

1094-
// NOTE: tools need to be also added to `Builder::get_step_descriptions` in `builder.rs`
1095-
// to make `./x.py build <tool>` work.
10961094
tool_extended!((self, builder),
10971095
Cargofmt, "src/tools/rustfmt", "cargo-fmt", stable=true;
10981096
CargoClippy, "src/tools/clippy", "cargo-clippy", stable=true;
10991097
Clippy, "src/tools/clippy", "clippy-driver", stable=true, add_bins_to_sysroot = ["clippy-driver", "cargo-clippy"];
11001098
Miri, "src/tools/miri", "miri", stable=false, add_bins_to_sysroot = ["miri"];
11011099
CargoMiri, "src/tools/miri/cargo-miri", "cargo-miri", stable=true, add_bins_to_sysroot = ["cargo-miri"];
1102-
// FIXME: tool_std is not quite right, we shouldn't allow nightly features.
1103-
// But `builder.cargo` doesn't know how to handle ToolBootstrap in stages other than 0,
1104-
// and this is close enough for now.
1105-
Rls, "src/tools/rls", "rls", stable=true, tool_std=true;
1100+
Rls, "src/tools/rls", "rls", stable=true;
11061101
Rustfmt, "src/tools/rustfmt", "rustfmt", stable=true, add_bins_to_sysroot = ["rustfmt", "cargo-fmt"];
11071102
);
11081103

Diff for: src/bootstrap/src/core/build_steps/vendor.rs

+22-10
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,26 @@ use crate::core::build_steps::tool::SUBMODULES_FOR_RUSTBOOK;
44
use crate::core::builder::{Builder, RunConfig, ShouldRun, Step};
55
use crate::utils::exec::command;
66

7+
/// List of default paths used for vendoring for `x vendor` and dist tarballs.
8+
pub fn default_paths_to_vendor(builder: &Builder<'_>) -> Vec<PathBuf> {
9+
let mut paths = vec![];
10+
for p in [
11+
"src/tools/cargo/Cargo.toml",
12+
"src/tools/rust-analyzer/Cargo.toml",
13+
"compiler/rustc_codegen_cranelift/Cargo.toml",
14+
"compiler/rustc_codegen_gcc/Cargo.toml",
15+
"library/Cargo.toml",
16+
"src/bootstrap/Cargo.toml",
17+
"src/tools/rustbook/Cargo.toml",
18+
"src/tools/rustc-perf/Cargo.toml",
19+
"src/tools/opt-dist/Cargo.toml",
20+
] {
21+
paths.push(builder.src.join(p));
22+
}
23+
24+
paths
25+
}
26+
727
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
828
pub(crate) struct Vendor {
929
sync_args: Vec<PathBuf>,
@@ -42,16 +62,8 @@ impl Step for Vendor {
4262
}
4363

4464
// Sync these paths by default.
45-
for p in [
46-
"src/tools/cargo/Cargo.toml",
47-
"src/tools/rust-analyzer/Cargo.toml",
48-
"compiler/rustc_codegen_cranelift/Cargo.toml",
49-
"compiler/rustc_codegen_gcc/Cargo.toml",
50-
"library/Cargo.toml",
51-
"src/bootstrap/Cargo.toml",
52-
"src/tools/rustbook/Cargo.toml",
53-
] {
54-
cmd.arg("--sync").arg(builder.src.join(p));
65+
for p in default_paths_to_vendor(builder) {
66+
cmd.arg("--sync").arg(p);
5567
}
5668

5769
// Also sync explicitly requested paths.

Diff for: src/bootstrap/src/core/builder.rs

+5-9
Original file line numberDiff line numberDiff line change
@@ -1455,15 +1455,11 @@ impl<'a> Builder<'a> {
14551455
assert_eq!(target, compiler.host);
14561456
}
14571457

1458-
if self.config.rust_optimize.is_release() {
1459-
// FIXME: cargo bench/install do not accept `--release`
1460-
// and miri doesn't want it
1461-
match cmd_kind {
1462-
Kind::Bench | Kind::Install | Kind::Miri | Kind::MiriSetup | Kind::MiriTest => {}
1463-
_ => {
1464-
cargo.arg("--release");
1465-
}
1466-
}
1458+
if self.config.rust_optimize.is_release() &&
1459+
// cargo bench/install do not accept `--release` and miri doesn't want it
1460+
!matches!(cmd_kind, Kind::Bench | Kind::Install | Kind::Miri | Kind::MiriSetup | Kind::MiriTest)
1461+
{
1462+
cargo.arg("--release");
14671463
}
14681464

14691465
// Remove make-related flags to ensure Cargo can correctly set things up

Diff for: src/bootstrap/src/core/download.rs

-2
Original file line numberDiff line numberDiff line change
@@ -620,8 +620,6 @@ impl Config {
620620
};
621621

622622
// For the beta compiler, put special effort into ensuring the checksums are valid.
623-
// FIXME: maybe we should do this for download-rustc as well? but it would be a pain to update
624-
// this on each and every nightly ...
625623
let checksum = if should_verify {
626624
let error = format!(
627625
"src/stage0 doesn't contain a checksum for {url}. \

0 commit comments

Comments
 (0)