From 11915108810250f74e0d30ac6f12948a7e94e648 Mon Sep 17 00:00:00 2001 From: Mark Simulacrum Date: Sun, 11 Feb 2018 15:39:09 -0700 Subject: [PATCH 1/5] Remove ONLY_BUILD_TARGETS. All cases where it is used can be replaced by substituing run.host for run.builder.build.build; that is its only effect. As such, it is removable. --- src/bootstrap/builder.rs | 7 +------ src/bootstrap/dist.rs | 21 +++------------------ src/bootstrap/install.rs | 3 +-- 3 files changed, 5 insertions(+), 26 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 22656e5a9da4c..1e15d5393829f 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -60,9 +60,6 @@ pub trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash { /// Run this rule for all hosts without cross compiling. const ONLY_HOSTS: bool = false; - /// Run this rule for all targets, but only with the native host. - const ONLY_BUILD_TARGETS: bool = false; - /// Only run this step with the build triple as host and target. const ONLY_BUILD: bool = false; @@ -101,7 +98,6 @@ pub struct RunConfig<'a> { struct StepDescription { default: bool, only_hosts: bool, - only_build_targets: bool, only_build: bool, should_run: fn(ShouldRun) -> ShouldRun, make_run: fn(RunConfig), @@ -138,7 +134,6 @@ impl StepDescription { StepDescription { default: S::DEFAULT, only_hosts: S::ONLY_HOSTS, - only_build_targets: S::ONLY_BUILD_TARGETS, only_build: S::ONLY_BUILD, should_run: S::should_run, make_run: S::make_run, @@ -155,7 +150,7 @@ impl StepDescription { self.name, builder.config.exclude); } let build = builder.build; - let hosts = if self.only_build_targets || self.only_build { + let hosts = if self.only_build { build.build_triple() } else { &build.hosts diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index aa0a7c52246ba..c3d8c9f8c010d 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -70,7 +70,6 @@ pub struct Docs { impl Step for Docs { type Output = PathBuf; const DEFAULT: bool = true; - const ONLY_BUILD_TARGETS: bool = true; fn should_run(run: ShouldRun) -> ShouldRun { run.path("src/doc") @@ -271,7 +270,6 @@ pub struct Mingw { impl Step for Mingw { type Output = Option; const DEFAULT: bool = true; - const ONLY_BUILD_TARGETS: bool = true; fn should_run(run: ShouldRun) -> ShouldRun { run.never() @@ -331,7 +329,6 @@ impl Step for Rustc { type Output = PathBuf; const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; - const ONLY_BUILD_TARGETS: bool = true; fn should_run(run: ShouldRun) -> ShouldRun { run.path("src/librustc") @@ -561,7 +558,6 @@ pub struct Std { impl Step for Std { type Output = PathBuf; const DEFAULT: bool = true; - const ONLY_BUILD_TARGETS: bool = true; fn should_run(run: ShouldRun) -> ShouldRun { run.path("src/libstd") @@ -569,7 +565,7 @@ impl Step for Std { fn make_run(run: RunConfig) { run.builder.ensure(Std { - compiler: run.builder.compiler(run.builder.top_stage, run.host), + compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build), target: run.target, }); } @@ -638,7 +634,6 @@ pub struct Analysis { impl Step for Analysis { type Output = PathBuf; const DEFAULT: bool = true; - const ONLY_BUILD_TARGETS: bool = true; fn should_run(run: ShouldRun) -> ShouldRun { let builder = run.builder; @@ -647,7 +642,7 @@ impl Step for Analysis { fn make_run(run: RunConfig) { run.builder.ensure(Analysis { - compiler: run.builder.compiler(run.builder.top_stage, run.host), + compiler: run.builder.compiler(run.builder.top_stage, run.builder.build.build), target: run.target, }); } @@ -755,8 +750,6 @@ impl Step for Src { type Output = PathBuf; const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; - const ONLY_BUILD_TARGETS: bool = true; - const ONLY_BUILD: bool = true; fn should_run(run: ShouldRun) -> ShouldRun { run.path("src") @@ -851,8 +844,6 @@ impl Step for PlainSourceTarball { type Output = PathBuf; const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; - const ONLY_BUILD_TARGETS: bool = true; - const ONLY_BUILD: bool = true; fn should_run(run: ShouldRun) -> ShouldRun { let builder = run.builder; @@ -1007,7 +998,6 @@ pub struct Cargo { impl Step for Cargo { type Output = PathBuf; - const ONLY_BUILD_TARGETS: bool = true; const ONLY_HOSTS: bool = true; fn should_run(run: ShouldRun) -> ShouldRun { @@ -1095,7 +1085,6 @@ pub struct Rls { impl Step for Rls { type Output = Option; - const ONLY_BUILD_TARGETS: bool = true; const ONLY_HOSTS: bool = true; fn should_run(run: ShouldRun) -> ShouldRun { @@ -1177,7 +1166,6 @@ pub struct Rustfmt { impl Step for Rustfmt { type Output = Option; - const ONLY_BUILD_TARGETS: bool = true; const ONLY_HOSTS: bool = true; fn should_run(run: ShouldRun) -> ShouldRun { @@ -1263,7 +1251,6 @@ pub struct Extended { impl Step for Extended { type Output = (); const DEFAULT: bool = true; - const ONLY_BUILD_TARGETS: bool = true; const ONLY_HOSTS: bool = true; fn should_run(run: ShouldRun) -> ShouldRun { @@ -1274,7 +1261,7 @@ impl Step for Extended { fn make_run(run: RunConfig) { run.builder.ensure(Extended { stage: run.builder.top_stage, - host: run.host, + host: run.builder.build.build, target: run.target, }); } @@ -1692,9 +1679,7 @@ pub struct HashSign; impl Step for HashSign { type Output = (); - const ONLY_BUILD_TARGETS: bool = true; const ONLY_HOSTS: bool = true; - const ONLY_BUILD: bool = true; fn should_run(run: ShouldRun) -> ShouldRun { run.path("hash-and-sign") diff --git a/src/bootstrap/install.rs b/src/bootstrap/install.rs index 20f7d379a6967..fa48902d55893 100644 --- a/src/bootstrap/install.rs +++ b/src/bootstrap/install.rs @@ -161,7 +161,6 @@ macro_rules! install { impl Step for $name { type Output = (); const DEFAULT: bool = true; - const ONLY_BUILD_TARGETS: bool = true; const ONLY_HOSTS: bool = $only_hosts; $(const $c: bool = true;)* @@ -174,7 +173,7 @@ macro_rules! install { run.builder.ensure($name { stage: run.builder.top_stage, target: run.target, - host: run.host, + host: run.builder.build.build, }); } From 1c8f3b011cacdc2e5c614f9b05c509db4a4217db Mon Sep 17 00:00:00 2001 From: Mark Simulacrum Date: Sun, 11 Feb 2018 15:41:06 -0700 Subject: [PATCH 2/5] Remove ONLY_BUILD. All uses are replaced with not accessing run.target/run.host, and instead directly using run.builder.build.build. --- src/bootstrap/builder.rs | 13 +------------ src/bootstrap/install.rs | 33 +++++++++++++++++++++++++++++---- src/bootstrap/test.rs | 16 ++++------------ 3 files changed, 34 insertions(+), 28 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 1e15d5393829f..7da88bffa4b4a 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -60,9 +60,6 @@ pub trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash { /// Run this rule for all hosts without cross compiling. const ONLY_HOSTS: bool = false; - /// Only run this step with the build triple as host and target. - const ONLY_BUILD: bool = false; - /// Primary function to execute this rule. Can call `builder.ensure(...)` /// with other steps to run those. fn run(self, builder: &Builder) -> Self::Output; @@ -98,7 +95,6 @@ pub struct RunConfig<'a> { struct StepDescription { default: bool, only_hosts: bool, - only_build: bool, should_run: fn(ShouldRun) -> ShouldRun, make_run: fn(RunConfig), name: &'static str, @@ -134,7 +130,6 @@ impl StepDescription { StepDescription { default: S::DEFAULT, only_hosts: S::ONLY_HOSTS, - only_build: S::ONLY_BUILD, should_run: S::should_run, make_run: S::make_run, name: unsafe { ::std::intrinsics::type_name::() }, @@ -150,18 +145,12 @@ impl StepDescription { self.name, builder.config.exclude); } let build = builder.build; - let hosts = if self.only_build { - build.build_triple() - } else { - &build.hosts - }; + let hosts = &build.hosts; // Determine the targets participating in this rule. let targets = if self.only_hosts { if build.config.run_host_only { &[] - } else if self.only_build { - build.build_triple() } else { &build.hosts } diff --git a/src/bootstrap/install.rs b/src/bootstrap/install.rs index fa48902d55893..17900fc35e095 100644 --- a/src/bootstrap/install.rs +++ b/src/bootstrap/install.rs @@ -225,10 +225,6 @@ install!((self, builder, _config), }); install_analysis(builder, self.stage, self.target); }; - Src, "src", Self::should_build(_config) , only_hosts: true, { - builder.ensure(dist::Src); - install_src(builder, self.stage); - }, ONLY_BUILD; Rustc, "src/librustc", true, only_hosts: true, { builder.ensure(dist::Rustc { compiler: builder.compiler(self.stage, self.target), @@ -236,3 +232,32 @@ install!((self, builder, _config), install_rustc(builder, self.stage, self.target); }; ); + +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct Src { + pub stage: u32, +} + +impl Step for Src { + type Output = (); + const DEFAULT: bool = true; + const ONLY_HOSTS: bool = true; + + fn should_run(run: ShouldRun) -> ShouldRun { + let config = &run.builder.config; + let cond = config.extended && + config.tools.as_ref().map_or(true, |t| t.contains("src")); + run.path("src").default_condition(cond) + } + + fn make_run(run: RunConfig) { + run.builder.ensure(Src { + stage: run.builder.top_stage, + }); + } + + fn run(self, builder: &Builder) { + builder.ensure(dist::Src); + install_src(builder, self.stage); + } +} diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 48490493525f9..7054c8005060c 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -505,27 +505,23 @@ impl Step for RustdocJS { } #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub struct Tidy { - host: Interned, -} +pub struct Tidy; impl Step for Tidy { type Output = (); const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; - const ONLY_BUILD: bool = true; - /// Runs the `tidy` tool as compiled in `stage` by the `host` compiler. + /// Runs the `tidy` tool. /// /// This tool in `src/tools` checks up on various bits and pieces of style and /// otherwise just implements a few lint-like checks that are specific to the /// compiler itself. fn run(self, builder: &Builder) { let build = builder.build; - let host = self.host; let _folder = build.fold_output(|| "tidy"); - println!("tidy check ({})", host); + println!("tidy check"); let mut cmd = builder.tool_cmd(Tool::Tidy); cmd.arg(build.src.join("src")); cmd.arg(&build.initial_cargo); @@ -543,9 +539,7 @@ impl Step for Tidy { } fn make_run(run: RunConfig) { - run.builder.ensure(Tidy { - host: run.builder.build.build, - }); + run.builder.ensure(Tidy); } } @@ -1607,7 +1601,6 @@ pub struct Distcheck; impl Step for Distcheck { type Output = (); - const ONLY_BUILD: bool = true; fn should_run(run: ShouldRun) -> ShouldRun { run.path("distcheck") @@ -1673,7 +1666,6 @@ impl Step for Bootstrap { type Output = (); const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; - const ONLY_BUILD: bool = true; /// Test the build system itself fn run(self, builder: &Builder) { From c8edb3652096bc3d294593375a5333503e6e86b1 Mon Sep 17 00:00:00 2001 From: Mark Simulacrum Date: Wed, 14 Feb 2018 18:50:11 -0700 Subject: [PATCH 3/5] Print out the sysroot and libdir on verbose builds. --- src/bootstrap/bin/rustc.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index 6c3c48aba72f1..40e2ef41144f3 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -95,7 +95,7 @@ fn main() { let rustc = env::var_os(rustc).unwrap_or_else(|| panic!("{:?} was not set", rustc)); let libdir = env::var_os(libdir).unwrap_or_else(|| panic!("{:?} was not set", libdir)); let mut dylib_path = bootstrap::util::dylib_path(); - dylib_path.insert(0, PathBuf::from(libdir)); + dylib_path.insert(0, PathBuf::from(&libdir)); let mut cmd = Command::new(rustc); cmd.args(&args) @@ -107,7 +107,7 @@ fn main() { if let Some(target) = target { // The stage0 compiler has a special sysroot distinct from what we // actually downloaded, so we just always pass the `--sysroot` option. - cmd.arg("--sysroot").arg(sysroot); + cmd.arg("--sysroot").arg(&sysroot); // When we build Rust dylibs they're all intended for intermediate // usage, so make sure we pass the -Cprefer-dynamic flag instead of @@ -280,6 +280,8 @@ fn main() { if verbose > 1 { eprintln!("rustc command: {:?}", cmd); + eprintln!("sysroot: {:?}", sysroot); + eprintln!("libdir: {:?}", libdir); } // Actually run the compiler! From 9cfc73cd3ff9aa845b699eb6d66e76cd4e0cdef0 Mon Sep 17 00:00:00 2001 From: Mark Simulacrum Date: Thu, 15 Feb 2018 18:31:17 -0700 Subject: [PATCH 4/5] Deny warnings --- src/bootstrap/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index f3d9246c6fc6c..5cba65f7f0ad2 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -113,7 +113,7 @@ //! More documentation can be found in each respective module below, and you can //! also check out the `src/bootstrap/README.md` file for more information. -//#![deny(warnings)] +#![deny(warnings)] #![feature(core_intrinsics)] #[macro_use] From 29a852970bf6ac9abee1a637727ed03d1888d582 Mon Sep 17 00:00:00 2001 From: Mark Simulacrum Date: Sun, 11 Feb 2018 15:42:05 -0700 Subject: [PATCH 5/5] Refactor run_host_only to have the proper effect. Previously it was set to true when we didn't run HOSTS steps. --- src/bootstrap/builder.rs | 4 ++-- src/bootstrap/config.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 7da88bffa4b4a..74b9978a8373c 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -149,8 +149,8 @@ impl StepDescription { // Determine the targets participating in this rule. let targets = if self.only_hosts { - if build.config.run_host_only { - &[] + if !build.config.run_host_only { + return; // don't run anything } else { &build.hosts } diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index f15d4d3585839..eeafa6891cc87 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -347,7 +347,7 @@ impl Config { config.keep_stage = flags.keep_stage; // If --target was specified but --host wasn't specified, don't run any host-only tests. - config.run_host_only = flags.host.is_empty() && !flags.target.is_empty(); + config.run_host_only = !(flags.host.is_empty() && !flags.target.is_empty()); let toml = file.map(|file| { let mut f = t!(File::open(&file));