Skip to content

Commit 27b0946

Browse files
Thread in-tree information through Mode
1 parent fda251b commit 27b0946

File tree

6 files changed

+50
-73
lines changed

6 files changed

+50
-73
lines changed

src/bootstrap/builder.rs

+13-6
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,9 @@ impl<'a> Builder<'a> {
765765
if cmd == "doc" || cmd == "rustdoc" {
766766
let my_out = match mode {
767767
// This is the intended out directory for compiler documentation.
768-
Mode::Rustc | Mode::ToolRustc | Mode::Codegen => self.compiler_doc_out(target),
768+
Mode::Rustc | Mode::ToolRustc { .. } | Mode::Codegen => {
769+
self.compiler_doc_out(target)
770+
}
769771
_ => self.crate_doc_out(target),
770772
};
771773
let rustdoc = self.rustdoc(compiler);
@@ -797,8 +799,8 @@ impl<'a> Builder<'a> {
797799
}
798800

799801
match mode {
800-
Mode::Std | Mode::ToolBootstrap | Mode::ToolStd => {},
801-
Mode::Rustc | Mode::Codegen | Mode::ToolRustc => {
802+
Mode::Std | Mode::ToolBootstrap { .. } | Mode::ToolStd { .. } => {},
803+
Mode::Rustc | Mode::Codegen | Mode::ToolRustc { .. } => {
802804
// Build proc macros both for the host and the target
803805
if target != compiler.host && cmd != "check" {
804806
cargo.arg("-Zdual-proc-macros");
@@ -891,7 +893,11 @@ impl<'a> Builder<'a> {
891893
// the stage0 build means it uses libraries build by the stage0
892894
// compiler, but for tools we just use the precompiled libraries that
893895
// we've downloaded
894-
let use_snapshot = mode == Mode::ToolBootstrap;
896+
let use_snapshot = if let Mode::ToolBootstrap { .. } = mode {
897+
true
898+
} else {
899+
false
900+
};
895901
assert!(!use_snapshot || stage == 0 || self.local_rebuild);
896902

897903
let maybe_sysroot = self.sysroot(compiler);
@@ -944,8 +950,9 @@ impl<'a> Builder<'a> {
944950
let debuginfo_level = match mode {
945951
Mode::Rustc | Mode::Codegen => self.config.rust_debuginfo_level_rustc,
946952
Mode::Std => self.config.rust_debuginfo_level_std,
947-
Mode::ToolBootstrap | Mode::ToolStd |
948-
Mode::ToolRustc => self.config.rust_debuginfo_level_tools,
953+
Mode::ToolBootstrap { .. } | Mode::ToolStd { .. } | Mode::ToolRustc { .. } => {
954+
self.config.rust_debuginfo_level_tools
955+
}
949956
};
950957
cargo.env("RUSTC_DEBUGINFO_LEVEL", debuginfo_level.to_string());
951958

src/bootstrap/check.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use crate::compile::{run_cargo, std_cargo, rustc_cargo, rustc_cargo_env,
44
add_to_sysroot};
55
use crate::builder::{RunConfig, Builder, Kind, ShouldRun, Step};
6-
use crate::tool::{prepare_tool_cargo, SourceType};
6+
use crate::tool::prepare_tool_cargo;
77
use crate::{Compiler, Mode};
88
use crate::cache::{INTERNER, Interned};
99
use std::path::PathBuf;
@@ -187,11 +187,10 @@ impl Step for Rustdoc {
187187

188188
let mut cargo = prepare_tool_cargo(builder,
189189
compiler,
190-
Mode::ToolRustc,
190+
Mode::ToolRustc { in_tree: true },
191191
target,
192192
cargo_subcommand(builder.kind),
193193
"src/tools/rustdoc",
194-
SourceType::InTree,
195194
&[]);
196195

197196
println!("Checking rustdoc artifacts ({} -> {})", &compiler.host, target);
@@ -244,6 +243,7 @@ pub fn rustdoc_stamp(
244243
compiler: Compiler,
245244
target: Interned<String>,
246245
) -> PathBuf {
247-
builder.cargo_out(compiler, Mode::ToolRustc, target)
246+
// doesn't really matter whether we're in-tree or not
247+
builder.cargo_out(compiler, Mode::ToolRustc { in_tree: true }, target)
248248
.join(".rustdoc-check.stamp")
249249
}

src/bootstrap/doc.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use build_helper::{t, up_to_date};
1717

1818
use crate::util::symlink_dir;
1919
use crate::builder::{Builder, Compiler, RunConfig, ShouldRun, Step};
20-
use crate::tool::{self, prepare_tool_cargo, Tool, SourceType};
20+
use crate::tool::{self, prepare_tool_cargo, Tool};
2121
use crate::compile;
2222
use crate::cache::{INTERNER, Interned};
2323
use crate::config::Config;
@@ -633,7 +633,7 @@ impl Step for Rustdoc {
633633
builder.ensure(tool::Rustdoc { compiler: compiler });
634634

635635
// Symlink compiler docs to the output directory of rustdoc documentation.
636-
let out_dir = builder.stage_out(compiler, Mode::ToolRustc)
636+
let out_dir = builder.stage_out(compiler, Mode::ToolRustc { in_tree: true })
637637
.join(target)
638638
.join("doc");
639639
t!(fs::create_dir_all(&out_dir));
@@ -643,11 +643,10 @@ impl Step for Rustdoc {
643643
let mut cargo = prepare_tool_cargo(
644644
builder,
645645
compiler,
646-
Mode::ToolRustc,
646+
Mode::ToolRustc { in_tree: true },
647647
target,
648648
"doc",
649649
"src/tools/rustdoc",
650-
SourceType::InTree,
651650
&[]
652651
);
653652

src/bootstrap/lib.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -304,19 +304,19 @@ pub enum Mode {
304304
/// "other" here is for miscellaneous sets of tools that are built using the
305305
/// bootstrap compiler in its entirety (target libraries and all).
306306
/// Typically these tools compile with stable Rust.
307-
ToolBootstrap,
307+
ToolBootstrap { in_tree: bool },
308308

309309
/// Compile a tool which uses all libraries we compile (up to rustc).
310310
/// Doesn't use the stage0 compiler libraries like "other", and includes
311311
/// tools like rustdoc, cargo, rls, etc.
312-
ToolStd,
313-
ToolRustc,
312+
ToolStd { in_tree: bool },
313+
ToolRustc { in_tree: bool },
314314
}
315315

316316
impl Mode {
317317
pub fn is_tool(&self) -> bool {
318318
match self {
319-
Mode::ToolBootstrap | Mode::ToolRustc | Mode::ToolStd => true,
319+
Mode::ToolBootstrap { .. } | Mode::ToolRustc { .. } | Mode::ToolStd { .. } => true,
320320
_ => false
321321
}
322322
}
@@ -528,8 +528,8 @@ impl Build {
528528
Mode::Std => "-std",
529529
Mode::Rustc => "-rustc",
530530
Mode::Codegen => "-codegen",
531-
Mode::ToolBootstrap => "-bootstrap-tools",
532-
Mode::ToolStd | Mode::ToolRustc => "-tools",
531+
Mode::ToolBootstrap { .. } => "-bootstrap-tools",
532+
Mode::ToolStd { .. } | Mode::ToolRustc { .. } => "-tools",
533533
};
534534
self.out.join(&*compiler.host)
535535
.join(format!("stage{}{}", compiler.stage, suffix))

src/bootstrap/test.rs

+10-18
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::compile;
1919
use crate::dist;
2020
use crate::flags::Subcommand;
2121
use crate::native;
22-
use crate::tool::{self, Tool, SourceType};
22+
use crate::tool::{self, Tool};
2323
use crate::toolstate::ToolState;
2424
use crate::util::{self, dylib_path, dylib_path_var};
2525
use crate::Crate as CargoCrate;
@@ -213,11 +213,10 @@ impl Step for Cargo {
213213
});
214214
let mut cargo = tool::prepare_tool_cargo(builder,
215215
compiler,
216-
Mode::ToolRustc,
216+
Mode::ToolRustc { in_tree: false },
217217
self.host,
218218
"test",
219219
"src/tools/cargo",
220-
SourceType::Submodule,
221220
&[]);
222221

223222
if !builder.fail_fast {
@@ -279,11 +278,10 @@ impl Step for Rls {
279278

280279
let mut cargo = tool::prepare_tool_cargo(builder,
281280
compiler,
282-
Mode::ToolRustc,
281+
Mode::ToolRustc { in_tree: false },
283282
host,
284283
"test",
285284
"src/tools/rls",
286-
SourceType::Submodule,
287285
&[]);
288286

289287
builder.add_rustc_lib_path(compiler, &mut cargo);
@@ -335,11 +333,10 @@ impl Step for Rustfmt {
335333

336334
let mut cargo = tool::prepare_tool_cargo(builder,
337335
compiler,
338-
Mode::ToolRustc,
336+
Mode::ToolRustc { in_tree: false },
339337
host,
340338
"test",
341339
"src/tools/rustfmt",
342-
SourceType::Submodule,
343340
&[]);
344341

345342
let dir = testdir(builder, compiler.host);
@@ -392,11 +389,10 @@ impl Step for Miri {
392389
let mut cargo = tool::prepare_tool_cargo(
393390
builder,
394391
compiler,
395-
Mode::ToolRustc,
392+
Mode::ToolRustc { in_tree: false },
396393
host,
397394
"run",
398395
"src/tools/miri",
399-
SourceType::Submodule,
400396
&[],
401397
);
402398
cargo
@@ -451,11 +447,10 @@ impl Step for Miri {
451447
let mut cargo = tool::prepare_tool_cargo(
452448
builder,
453449
compiler,
454-
Mode::ToolRustc,
450+
Mode::ToolRustc { in_tree: false },
455451
host,
456452
"test",
457453
"src/tools/miri",
458-
SourceType::Submodule,
459454
&[],
460455
);
461456

@@ -504,11 +499,10 @@ impl Step for CompiletestTest {
504499

505500
let mut cargo = tool::prepare_tool_cargo(builder,
506501
compiler,
507-
Mode::ToolBootstrap,
502+
Mode::ToolBootstrap { in_tree: true },
508503
host,
509504
"test",
510505
"src/tools/compiletest",
511-
SourceType::InTree,
512506
&[]);
513507

514508
try_run(builder, &mut cargo);
@@ -551,19 +545,18 @@ impl Step for Clippy {
551545
if let Some(clippy) = clippy {
552546
let mut cargo = tool::prepare_tool_cargo(builder,
553547
compiler,
554-
Mode::ToolRustc,
548+
Mode::ToolRustc { in_tree: false },
555549
host,
556550
"test",
557551
"src/tools/clippy",
558-
SourceType::Submodule,
559552
&[]);
560553

561554
// clippy tests need to know about the stage sysroot
562555
cargo.env("SYSROOT", builder.sysroot(compiler));
563556
cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler));
564557
cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler));
565558
let host_libs = builder
566-
.stage_out(compiler, Mode::ToolRustc)
559+
.stage_out(compiler, Mode::ToolRustc { in_tree: false })
567560
.join(builder.cargo_dir());
568561
cargo.env("HOST_LIBS", host_libs);
569562
// clippy tests need to find the driver
@@ -1877,11 +1870,10 @@ impl Step for CrateRustdoc {
18771870

18781871
let mut cargo = tool::prepare_tool_cargo(builder,
18791872
compiler,
1880-
Mode::ToolRustc,
1873+
Mode::ToolRustc { in_tree: true },
18811874
target,
18821875
test_kind.subcommand(),
18831876
"src/tools/rustdoc",
1884-
SourceType::InTree,
18851877
&[]);
18861878
if test_kind.subcommand() == "test" && !builder.fail_fast {
18871879
cargo.arg("--no-fail-fast");

0 commit comments

Comments
 (0)