From c4b51c4680b8052b2e4ca67e06c0323b053ba287 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Perennou Date: Fri, 30 Jun 2017 09:55:45 +0200 Subject: [PATCH 1/2] rustbuild: add configuration option to build all tools This does not change what we install (as opposed to extended). This only causes all the tools to be built as part of './x.py build'. This is useful to check that all the tools compile fine, and will avoid some compilation during './x.py install' if it is enabled. Signed-off-by: Marc-Antoine Perennou --- src/bootstrap/config.rs | 4 ++++ src/bootstrap/config.toml.example | 12 +++++++++--- src/bootstrap/step.rs | 29 +++++++++++++++++++++++++++-- 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 3ada846e38236..876f11ee44ed0 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -49,6 +49,7 @@ pub struct Config { pub target_config: HashMap, pub full_bootstrap: bool, pub extended: bool, + pub build_all_tools: bool, pub sanitizers: bool, pub profiler: bool, @@ -162,6 +163,7 @@ struct Build { python: Option, full_bootstrap: Option, extended: Option, + build_all_tools: Option, verbose: Option, sanitizers: Option, profiler: Option, @@ -320,6 +322,7 @@ impl Config { set(&mut config.vendor, build.vendor); set(&mut config.full_bootstrap, build.full_bootstrap); set(&mut config.extended, build.extended); + set(&mut config.build_all_tools, build.build_all_tools); set(&mut config.verbose, build.verbose); set(&mut config.sanitizers, build.sanitizers); set(&mut config.profiler, build.profiler); @@ -482,6 +485,7 @@ impl Config { ("VENDOR", self.vendor), ("FULL_BOOTSTRAP", self.full_bootstrap), ("EXTENDED", self.extended), + ("BUILD_ALL_TOOLS", self.build_all_tools), ("SANITIZERS", self.sanitizers), ("PROFILER", self.profiler), ("DIST_SRC", self.rust_dist_src), diff --git a/src/bootstrap/config.toml.example b/src/bootstrap/config.toml.example index 7a52222e46e90..0ed80c11a1e7b 100644 --- a/src/bootstrap/config.toml.example +++ b/src/bootstrap/config.toml.example @@ -143,12 +143,18 @@ # option to true. #full-bootstrap = false -# Enable a build of the and extended rust tool set which is not only the -# compiler but also tools such as Cargo. This will also produce "combined -# installers" which are used to install Rust and Cargo together. This is +# Enable a build of the extended rust tool set which is not only the +# compiler but also tools such as Cargo or RLS. This will also produce "combined +# installers" which are used to install Rust, Cargo and RLS together. This is # disabled by default. #extended = false +# Build all the tools as part of the "build" phase instead of lazily +# waiting for those to be needed. This will cause tools such as rust-installer +# and rustbook to be built early on instead of during installation or +# documentation generation. This is disabled by default. +#build-all-tools = false + # Verbosity level: 0 == not verbose, 1 == verbose, 2 == very verbose #verbose = 0 diff --git a/src/bootstrap/step.rs b/src/bootstrap/step.rs index 5f0724c657757..c4f1884e57896 100644 --- a/src/bootstrap/step.rs +++ b/src/bootstrap/step.rs @@ -541,52 +541,77 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules { // // Tools used during the build system but not shipped rules.build("tool-rustbook", "src/tools/rustbook") + .default(build.config.build_all_tools) + .host(true) .dep(|s| s.name("maybe-clean-tools")) .dep(|s| s.name("librustc-tool")) .run(move |s| compile::tool(build, s.stage, s.target, "rustbook")); rules.build("tool-error-index", "src/tools/error_index_generator") + .default(build.config.build_all_tools) + .host(true) .dep(|s| s.name("maybe-clean-tools")) .dep(|s| s.name("librustc-tool")) .run(move |s| compile::tool(build, s.stage, s.target, "error_index_generator")); rules.build("tool-unstable-book-gen", "src/tools/unstable-book-gen") + .default(build.config.build_all_tools) + .host(true) .dep(|s| s.name("maybe-clean-tools")) .dep(|s| s.name("libstd-tool")) .run(move |s| compile::tool(build, s.stage, s.target, "unstable-book-gen")); rules.build("tool-tidy", "src/tools/tidy") + .default(build.config.build_all_tools) + .host(true) + .only_build(true) .dep(|s| s.name("maybe-clean-tools")) .dep(|s| s.name("libstd-tool")) .run(move |s| compile::tool(build, s.stage, s.target, "tidy")); rules.build("tool-linkchecker", "src/tools/linkchecker") + .default(build.config.build_all_tools) + .host(true) .dep(|s| s.name("maybe-clean-tools")) .dep(|s| s.name("libstd-tool")) .run(move |s| compile::tool(build, s.stage, s.target, "linkchecker")); rules.build("tool-cargotest", "src/tools/cargotest") + .default(build.config.build_all_tools) + .host(true) .dep(|s| s.name("maybe-clean-tools")) .dep(|s| s.name("libstd-tool")) .run(move |s| compile::tool(build, s.stage, s.target, "cargotest")); rules.build("tool-compiletest", "src/tools/compiletest") + .default(build.config.build_all_tools) + .host(true) .dep(|s| s.name("maybe-clean-tools")) .dep(|s| s.name("libtest-tool")) .run(move |s| compile::tool(build, s.stage, s.target, "compiletest")); rules.build("tool-build-manifest", "src/tools/build-manifest") + .default(build.config.build_all_tools) + .host(true) + .only_build(true) + .only_host_build(true) .dep(|s| s.name("maybe-clean-tools")) .dep(|s| s.name("libstd-tool")) .run(move |s| compile::tool(build, s.stage, s.target, "build-manifest")); rules.build("tool-remote-test-server", "src/tools/remote-test-server") + .default(build.config.build_all_tools) + .host(true) .dep(|s| s.name("maybe-clean-tools")) .dep(|s| s.name("libstd-tool")) .run(move |s| compile::tool(build, s.stage, s.target, "remote-test-server")); rules.build("tool-remote-test-client", "src/tools/remote-test-client") + .default(build.config.build_all_tools) + .host(true) .dep(|s| s.name("maybe-clean-tools")) .dep(|s| s.name("libstd-tool")) .run(move |s| compile::tool(build, s.stage, s.target, "remote-test-client")); rules.build("tool-rust-installer", "src/tools/rust-installer") + .default(build.config.build_all_tools) + .host(true) .dep(|s| s.name("maybe-clean-tools")) .dep(|s| s.name("libstd-tool")) .run(move |s| compile::tool(build, s.stage, s.target, "rust-installer")); rules.build("tool-cargo", "src/tools/cargo") + .default(build.config.extended || build.config.build_all_tools) .host(true) - .default(build.config.extended) .dep(|s| s.name("maybe-clean-tools")) .dep(|s| s.name("libstd-tool")) .dep(|s| s.stage(0).host(s.target).name("openssl")) @@ -599,8 +624,8 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules { }) .run(move |s| compile::tool(build, s.stage, s.target, "cargo")); rules.build("tool-rls", "src/tools/rls") + .default(build.config.extended || build.config.build_all_tools) .host(true) - .default(build.config.extended) .dep(|s| s.name("librustc-tool")) .dep(|s| s.stage(0).host(s.target).name("openssl")) .dep(move |s| { From 071ae56d67852e448ffdeda3c61fc8c755bfa097 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Perennou Date: Fri, 30 Jun 2017 10:56:55 +0200 Subject: [PATCH 2/2] rustbuild: explicitely build some components only for a given stage Some components are only built when they're being pulled in as dependencies with .stage(0) specified. They now can also be pulled in with build-all-tools, hence only build them as stage 0. Signed-off-by: Marc-Antoine Perennou --- src/bootstrap/step.rs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/step.rs b/src/bootstrap/step.rs index c4f1884e57896..12bbdbb1da4ed 100644 --- a/src/bootstrap/step.rs +++ b/src/bootstrap/step.rs @@ -543,18 +543,21 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules { rules.build("tool-rustbook", "src/tools/rustbook") .default(build.config.build_all_tools) .host(true) + .only_stage(0) .dep(|s| s.name("maybe-clean-tools")) .dep(|s| s.name("librustc-tool")) .run(move |s| compile::tool(build, s.stage, s.target, "rustbook")); rules.build("tool-error-index", "src/tools/error_index_generator") .default(build.config.build_all_tools) .host(true) + .only_stage(0) .dep(|s| s.name("maybe-clean-tools")) .dep(|s| s.name("librustc-tool")) .run(move |s| compile::tool(build, s.stage, s.target, "error_index_generator")); rules.build("tool-unstable-book-gen", "src/tools/unstable-book-gen") .default(build.config.build_all_tools) .host(true) + .only_stage(0) .dep(|s| s.name("maybe-clean-tools")) .dep(|s| s.name("libstd-tool")) .run(move |s| compile::tool(build, s.stage, s.target, "unstable-book-gen")); @@ -562,24 +565,28 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules { .default(build.config.build_all_tools) .host(true) .only_build(true) + .only_stage(0) .dep(|s| s.name("maybe-clean-tools")) .dep(|s| s.name("libstd-tool")) .run(move |s| compile::tool(build, s.stage, s.target, "tidy")); rules.build("tool-linkchecker", "src/tools/linkchecker") .default(build.config.build_all_tools) .host(true) + .only_stage(0) .dep(|s| s.name("maybe-clean-tools")) .dep(|s| s.name("libstd-tool")) .run(move |s| compile::tool(build, s.stage, s.target, "linkchecker")); rules.build("tool-cargotest", "src/tools/cargotest") .default(build.config.build_all_tools) .host(true) + .only_stage(0) .dep(|s| s.name("maybe-clean-tools")) .dep(|s| s.name("libstd-tool")) .run(move |s| compile::tool(build, s.stage, s.target, "cargotest")); rules.build("tool-compiletest", "src/tools/compiletest") .default(build.config.build_all_tools) .host(true) + .only_stage(0) .dep(|s| s.name("maybe-clean-tools")) .dep(|s| s.name("libtest-tool")) .run(move |s| compile::tool(build, s.stage, s.target, "compiletest")); @@ -588,6 +595,7 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules { .host(true) .only_build(true) .only_host_build(true) + .only_stage(0) .dep(|s| s.name("maybe-clean-tools")) .dep(|s| s.name("libstd-tool")) .run(move |s| compile::tool(build, s.stage, s.target, "build-manifest")); @@ -600,12 +608,14 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules { rules.build("tool-remote-test-client", "src/tools/remote-test-client") .default(build.config.build_all_tools) .host(true) + .only_stage(0) .dep(|s| s.name("maybe-clean-tools")) .dep(|s| s.name("libstd-tool")) .run(move |s| compile::tool(build, s.stage, s.target, "remote-test-client")); rules.build("tool-rust-installer", "src/tools/rust-installer") .default(build.config.build_all_tools) .host(true) + .only_stage(0) .dep(|s| s.name("maybe-clean-tools")) .dep(|s| s.name("libstd-tool")) .run(move |s| compile::tool(build, s.stage, s.target, "rust-installer")); @@ -980,6 +990,9 @@ struct Rule<'a> { /// targets. only_build: bool, + /// Whether this rule is only built for one stage (usually stage 0). + only_stage: Option, + /// A list of "order only" dependencies. This rules does not actually /// depend on these rules, but if they show up in the dependency graph then /// this rule must be executed after all these rules. @@ -1008,6 +1021,7 @@ impl<'a> Rule<'a> { host: false, only_host_build: false, only_build: false, + only_stage: None, after: Vec::new(), } } @@ -1059,6 +1073,11 @@ impl<'a, 'b> RuleBuilder<'a, 'b> { self.rule.only_host_build = only_host_build; self } + + fn only_stage(&mut self, stage: u32) -> &mut Self { + self.rule.only_stage = Some(stage); + self + } } impl<'a, 'b> Drop for RuleBuilder<'a, 'b> { @@ -1225,6 +1244,7 @@ invalid rule dependency graph detected, was a rule added and maybe typo'd? Subcommand::Install { ref paths } => (Kind::Install, &paths[..]), Subcommand::Clean => panic!(), }; + let current_stage = self.sbuild.stage; let mut rules: Vec<_> = self.rules.values().filter_map(|rule| { if rule.kind != kind { @@ -1278,7 +1298,10 @@ invalid rule dependency graph detected, was a rule added and maybe typo'd? hosts.iter().flat_map(move |host| { arr.iter().map(move |target| { - self.sbuild.name(rule.name).target(target).host(host) + self.sbuild.name(rule.name) + .target(target) + .host(host) + .stage(rule.only_stage.unwrap_or(current_stage)) }) }) }).collect()