diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 4f5de1ecd2b44..fbae3629c4bd9 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -765,7 +765,9 @@ impl<'a> Builder<'a> { if cmd == "doc" || cmd == "rustdoc" { let my_out = match mode { // This is the intended out directory for compiler documentation. - Mode::Rustc | Mode::ToolRustc | Mode::Codegen => self.compiler_doc_out(target), + Mode::Rustc | Mode::ToolRustc { .. } | Mode::Codegen => { + self.compiler_doc_out(target) + } _ => self.crate_doc_out(target), }; let rustdoc = self.rustdoc(compiler); @@ -797,8 +799,8 @@ impl<'a> Builder<'a> { } match mode { - Mode::Std | Mode::ToolBootstrap | Mode::ToolStd => {}, - Mode::Rustc | Mode::Codegen | Mode::ToolRustc => { + Mode::Std | Mode::ToolBootstrap { .. } | Mode::ToolStd { .. } => {}, + Mode::Rustc | Mode::Codegen | Mode::ToolRustc { .. } => { // Build proc macros both for the host and the target if target != compiler.host && cmd != "check" { cargo.arg("-Zdual-proc-macros"); @@ -891,7 +893,11 @@ impl<'a> Builder<'a> { // the stage0 build means it uses libraries build by the stage0 // compiler, but for tools we just use the precompiled libraries that // we've downloaded - let use_snapshot = mode == Mode::ToolBootstrap; + let use_snapshot = if let Mode::ToolBootstrap { .. } = mode { + true + } else { + false + }; assert!(!use_snapshot || stage == 0 || self.local_rebuild); let maybe_sysroot = self.sysroot(compiler); @@ -944,8 +950,9 @@ impl<'a> Builder<'a> { let debuginfo_level = match mode { Mode::Rustc | Mode::Codegen => self.config.rust_debuginfo_level_rustc, Mode::Std => self.config.rust_debuginfo_level_std, - Mode::ToolBootstrap | Mode::ToolStd | - Mode::ToolRustc => self.config.rust_debuginfo_level_tools, + Mode::ToolBootstrap { .. } | Mode::ToolStd { .. } | Mode::ToolRustc { .. } => { + self.config.rust_debuginfo_level_tools + } }; cargo.env("RUSTC_DEBUGINFO_LEVEL", debuginfo_level.to_string()); diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index 205a80c3a3a9e..9a806c6463975 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -3,7 +3,7 @@ use crate::compile::{run_cargo, std_cargo, rustc_cargo, rustc_cargo_env, add_to_sysroot}; use crate::builder::{RunConfig, Builder, Kind, ShouldRun, Step}; -use crate::tool::{prepare_tool_cargo, SourceType}; +use crate::tool::prepare_tool_cargo; use crate::{Compiler, Mode}; use crate::cache::{INTERNER, Interned}; use std::path::PathBuf; @@ -187,11 +187,10 @@ impl Step for Rustdoc { let mut cargo = prepare_tool_cargo(builder, compiler, - Mode::ToolRustc, + Mode::ToolRustc { in_tree: true }, target, cargo_subcommand(builder.kind), "src/tools/rustdoc", - SourceType::InTree, &[]); println!("Checking rustdoc artifacts ({} -> {})", &compiler.host, target); @@ -244,6 +243,7 @@ pub fn rustdoc_stamp( compiler: Compiler, target: Interned, ) -> PathBuf { - builder.cargo_out(compiler, Mode::ToolRustc, target) + // doesn't really matter whether we're in-tree or not + builder.cargo_out(compiler, Mode::ToolRustc { in_tree: true }, target) .join(".rustdoc-check.stamp") } diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index 6faedc80ad3f5..b96efa05b380e 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -17,7 +17,7 @@ use build_helper::{t, up_to_date}; use crate::util::symlink_dir; use crate::builder::{Builder, Compiler, RunConfig, ShouldRun, Step}; -use crate::tool::{self, prepare_tool_cargo, Tool, SourceType}; +use crate::tool::{self, prepare_tool_cargo, Tool}; use crate::compile; use crate::cache::{INTERNER, Interned}; use crate::config::Config; @@ -633,7 +633,7 @@ impl Step for Rustdoc { builder.ensure(tool::Rustdoc { compiler: compiler }); // Symlink compiler docs to the output directory of rustdoc documentation. - let out_dir = builder.stage_out(compiler, Mode::ToolRustc) + let out_dir = builder.stage_out(compiler, Mode::ToolRustc { in_tree: true }) .join(target) .join("doc"); t!(fs::create_dir_all(&out_dir)); @@ -643,11 +643,10 @@ impl Step for Rustdoc { let mut cargo = prepare_tool_cargo( builder, compiler, - Mode::ToolRustc, + Mode::ToolRustc { in_tree: true }, target, "doc", "src/tools/rustdoc", - SourceType::InTree, &[] ); diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 5d7581c8211be..ecfd5e754a704 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -304,19 +304,19 @@ pub enum Mode { /// "other" here is for miscellaneous sets of tools that are built using the /// bootstrap compiler in its entirety (target libraries and all). /// Typically these tools compile with stable Rust. - ToolBootstrap, + ToolBootstrap { in_tree: bool }, /// Compile a tool which uses all libraries we compile (up to rustc). /// Doesn't use the stage0 compiler libraries like "other", and includes /// tools like rustdoc, cargo, rls, etc. - ToolStd, - ToolRustc, + ToolStd { in_tree: bool }, + ToolRustc { in_tree: bool }, } impl Mode { pub fn is_tool(&self) -> bool { match self { - Mode::ToolBootstrap | Mode::ToolRustc | Mode::ToolStd => true, + Mode::ToolBootstrap { .. } | Mode::ToolRustc { .. } | Mode::ToolStd { .. } => true, _ => false } } @@ -528,8 +528,8 @@ impl Build { Mode::Std => "-std", Mode::Rustc => "-rustc", Mode::Codegen => "-codegen", - Mode::ToolBootstrap => "-bootstrap-tools", - Mode::ToolStd | Mode::ToolRustc => "-tools", + Mode::ToolBootstrap { .. } => "-bootstrap-tools", + Mode::ToolStd { .. } | Mode::ToolRustc { .. } => "-tools", }; self.out.join(&*compiler.host) .join(format!("stage{}{}", compiler.stage, suffix)) diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 97b28ed9e96c8..3ee71f2caba0c 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -19,7 +19,7 @@ use crate::compile; use crate::dist; use crate::flags::Subcommand; use crate::native; -use crate::tool::{self, Tool, SourceType}; +use crate::tool::{self, Tool}; use crate::toolstate::ToolState; use crate::util::{self, dylib_path, dylib_path_var}; use crate::Crate as CargoCrate; @@ -213,11 +213,10 @@ impl Step for Cargo { }); let mut cargo = tool::prepare_tool_cargo(builder, compiler, - Mode::ToolRustc, + Mode::ToolRustc { in_tree: false }, self.host, "test", "src/tools/cargo", - SourceType::Submodule, &[]); if !builder.fail_fast { @@ -279,11 +278,10 @@ impl Step for Rls { let mut cargo = tool::prepare_tool_cargo(builder, compiler, - Mode::ToolRustc, + Mode::ToolRustc { in_tree: false }, host, "test", "src/tools/rls", - SourceType::Submodule, &[]); builder.add_rustc_lib_path(compiler, &mut cargo); @@ -335,11 +333,10 @@ impl Step for Rustfmt { let mut cargo = tool::prepare_tool_cargo(builder, compiler, - Mode::ToolRustc, + Mode::ToolRustc { in_tree: false }, host, "test", "src/tools/rustfmt", - SourceType::Submodule, &[]); let dir = testdir(builder, compiler.host); @@ -392,11 +389,10 @@ impl Step for Miri { let mut cargo = tool::prepare_tool_cargo( builder, compiler, - Mode::ToolRustc, + Mode::ToolRustc { in_tree: false }, host, "run", "src/tools/miri", - SourceType::Submodule, &[], ); cargo @@ -451,11 +447,10 @@ impl Step for Miri { let mut cargo = tool::prepare_tool_cargo( builder, compiler, - Mode::ToolRustc, + Mode::ToolRustc { in_tree: false }, host, "test", "src/tools/miri", - SourceType::Submodule, &[], ); @@ -504,11 +499,10 @@ impl Step for CompiletestTest { let mut cargo = tool::prepare_tool_cargo(builder, compiler, - Mode::ToolBootstrap, + Mode::ToolBootstrap { in_tree: true }, host, "test", "src/tools/compiletest", - SourceType::InTree, &[]); try_run(builder, &mut cargo); @@ -551,11 +545,10 @@ impl Step for Clippy { if let Some(clippy) = clippy { let mut cargo = tool::prepare_tool_cargo(builder, compiler, - Mode::ToolRustc, + Mode::ToolRustc { in_tree: false }, host, "test", "src/tools/clippy", - SourceType::Submodule, &[]); // clippy tests need to know about the stage sysroot @@ -563,7 +556,7 @@ impl Step for Clippy { cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler)); cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler)); let host_libs = builder - .stage_out(compiler, Mode::ToolRustc) + .stage_out(compiler, Mode::ToolRustc { in_tree: false }) .join(builder.cargo_dir()); cargo.env("HOST_LIBS", host_libs); // clippy tests need to find the driver @@ -1877,11 +1870,10 @@ impl Step for CrateRustdoc { let mut cargo = tool::prepare_tool_cargo(builder, compiler, - Mode::ToolRustc, + Mode::ToolRustc { in_tree: true }, target, test_kind.subcommand(), "src/tools/rustdoc", - SourceType::InTree, &[]); if test_kind.subcommand() == "test" && !builder.fail_fast { cargo.arg("--no-fail-fast"); diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index 54fe26f18e741..b8435a1f89e3e 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -16,12 +16,6 @@ use crate::channel; use crate::cache::Interned; use crate::toolstate::ToolState; -#[derive(Debug, Clone, Hash, PartialEq, Eq)] -pub enum SourceType { - InTree, - Submodule, -} - #[derive(Debug, Clone, Hash, PartialEq, Eq)] struct ToolBuild { compiler: Compiler, @@ -30,7 +24,6 @@ struct ToolBuild { path: &'static str, mode: Mode, is_optional_tool: bool, - source_type: SourceType, extra_features: Vec, } @@ -53,13 +46,13 @@ impl Step for ToolBuild { let is_optional_tool = self.is_optional_tool; match self.mode { - Mode::ToolRustc => { + Mode::ToolRustc { .. } => { builder.ensure(compile::Rustc { compiler, target }) } - Mode::ToolStd => { + Mode::ToolStd { .. }=> { builder.ensure(compile::Std { compiler, target }) } - Mode::ToolBootstrap => {} // uses downloaded stage0 compiler libs + Mode::ToolBootstrap { .. } => {} // uses downloaded stage0 compiler libs _ => panic!("unexpected Mode for tool build") } @@ -70,7 +63,6 @@ impl Step for ToolBuild { target, "build", path, - self.source_type, &self.extra_features, ); @@ -227,7 +219,6 @@ pub fn prepare_tool_cargo( target: Interned, command: &'static str, path: &'static str, - source_type: SourceType, extra_features: &[String], ) -> Command { let mut cargo = builder.cargo(compiler, mode, target, command); @@ -238,10 +229,6 @@ pub fn prepare_tool_cargo( // stages and such and it's just easier if they're not dynamically linked. cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1"); - if source_type == SourceType::Submodule { - cargo.env("RUSTC_EXTERNAL_TOOL", "1"); - } - let mut features = extra_features.iter().cloned().collect::>(); if builder.build.config.cargo_native_static { if path.ends_with("cargo") || @@ -357,14 +344,9 @@ macro_rules! bootstrap_tool { compiler: self.compiler, target: self.target, tool: $tool_name, - mode: Mode::ToolBootstrap, + mode: Mode::ToolBootstrap { in_tree: true $(&& !$external)* }, path: $path, is_optional_tool: false, - source_type: if false $(|| $external)* { - SourceType::Submodule - } else { - SourceType::InTree - }, extra_features: { // FIXME(#60643): avoid this lint by using `_` let mut _tmp = Vec::new(); @@ -430,10 +412,9 @@ impl Step for ErrorIndex { compiler: self.compiler, target: self.compiler.host, tool: "error_index_generator", - mode: Mode::ToolRustc, + mode: Mode::ToolRustc { in_tree: true }, path: "src/tools/error_index_generator", is_optional_tool: false, - source_type: SourceType::InTree, extra_features: Vec::new(), }).expect("expected to build -- essential tool") } @@ -464,10 +445,9 @@ impl Step for RemoteTestServer { compiler: self.compiler, target: self.target, tool: "remote-test-server", - mode: Mode::ToolStd, + mode: Mode::ToolStd { in_tree: true }, path: "src/tools/remote-test-server", is_optional_tool: false, - source_type: SourceType::InTree, extra_features: Vec::new(), }).expect("expected to build -- essential tool") } @@ -520,11 +500,10 @@ impl Step for Rustdoc { let mut cargo = prepare_tool_cargo( builder, build_compiler, - Mode::ToolRustc, + Mode::ToolRustc { in_tree: true }, target, "build", "src/tools/rustdoc", - SourceType::InTree, &[], ); @@ -535,8 +514,9 @@ impl Step for Rustdoc { // Cargo adds a number of paths to the dylib search path on windows, which results in // the wrong rustdoc being executed. To avoid the conflicting rustdocs, we name the "tool" // rustdoc a different name. - let tool_rustdoc = builder.cargo_out(build_compiler, Mode::ToolRustc, target) - .join(exe("rustdoc_tool_binary", &target_compiler.host)); + let tool_rustdoc = builder.cargo_out( + build_compiler, Mode::ToolRustc { in_tree: true }, target + ).join(exe("rustdoc_tool_binary", &target_compiler.host)); // don't create a stage0-sysroot/bin directory. if target_compiler.stage > 0 { @@ -581,10 +561,9 @@ impl Step for Cargo { compiler: self.compiler, target: self.target, tool: "cargo", - mode: Mode::ToolRustc, + mode: Mode::ToolRustc { in_tree: false }, path: "src/tools/cargo", is_optional_tool: false, - source_type: SourceType::Submodule, extra_features: Vec::new(), }).expect("expected to build -- essential tool") } @@ -630,11 +609,10 @@ macro_rules! tool_extended { compiler: $sel.compiler, target: $sel.target, tool: $tool_name, - mode: Mode::ToolRustc, + mode: Mode::ToolRustc { in_tree: false }, path: $path, extra_features: $sel.extra_features, is_optional_tool: true, - source_type: SourceType::Submodule, }) } } @@ -674,7 +652,8 @@ impl<'a> Builder<'a> { // right location to run `compiler`. let mut lib_paths: Vec = vec![ self.build.rustc_snapshot_libdir(), - self.cargo_out(compiler, Mode::ToolBootstrap, *host).join("deps"), + // doesn't really matter here whether we're in tree or not so just pass true + self.cargo_out(compiler, Mode::ToolBootstrap { in_tree: true }, *host).join("deps"), ]; // On MSVC a tool may invoke a C compiler (e.g., compiletest in run-make