X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fbootstrap%2Flib.rs;h=5728b9d24de99a8738fef482ada7c28689d7f23a;hb=75983e137eeae5e9b210c2e97e6239bf888d9620;hp=db861cb7013713c040677ba0ffbfaf37a4ded2c6;hpb=1dc6c3c4ad2d08cc8d8d414cd04cbf0350e2bb14;p=rust.git diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index db861cb7013..5728b9d24de 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -270,12 +270,7 @@ struct Crate { } impl Crate { - fn is_local(&self, build: &Build) -> bool { - self.path.starts_with(&build.config.src) && !self.path.to_string_lossy().ends_with("_shim") - } - fn local_path(&self, build: &Build) -> PathBuf { - assert!(self.is_local(build)); self.path.strip_prefix(&build.config.src).unwrap().into() } } @@ -306,16 +301,21 @@ pub enum Mode { /// Build codegen libraries, placing output in the "stageN-codegen" directory Codegen, - /// Build some tools, placing output in the "stageN-tools" directory. The - /// "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. + /// Build a tool, placing output in the "stage0-bootstrap-tools" + /// directory. This is for miscellaneous sets of tools that are built + /// using the bootstrap stage0 compiler in its entirety (target libraries + /// and all). Typically these tools compile with stable Rust. ToolBootstrap, - /// 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. + /// Build a tool which uses the locally built std, placing output in the + /// "stageN-tools" directory. Its usage is quite rare, mainly used by + /// compiletest which needs libtest. ToolStd, + + /// Build a tool which uses the locally built rustc and the target std, + /// placing the output in the "stageN-tools" directory. This is used for + /// anything that needs a fully functional rustc, such as rustdoc, clippy, + /// cargo, rls, rustfmt, miri, etc. ToolRustc, } @@ -1090,17 +1090,29 @@ fn unstable_features(&self) -> bool { } } + /// Returns a Vec of all the dependencies of the given root crate, + /// including transitive dependencies and the root itself. Only includes + /// "local" crates (those in the local source tree, not from a registry). fn in_tree_crates(&self, root: &str) -> Vec<&Crate> { let mut ret = Vec::new(); let mut list = vec![INTERNER.intern_str(root)]; let mut visited = HashSet::new(); while let Some(krate) = list.pop() { let krate = &self.crates[&krate]; - if krate.is_local(self) { - ret.push(krate); - } + ret.push(krate); for dep in &krate.deps { - if visited.insert(dep) && dep != "build_helper" { + // Don't include optional deps if their features are not + // enabled. Ideally this would be computed from `cargo + // metadata --features …`, but that is somewhat slow. Just + // skip `build_helper` since there aren't any operations we + // want to perform on it. In the future, we may want to + // consider just filtering all build and dev dependencies in + // metadata::build. + if visited.insert(dep) + && dep != "build_helper" + && (dep != "profiler_builtins" || self.config.profiler) + && (dep != "rustc_codegen_llvm" || self.config.llvm_enabled()) + { list.push(*dep); } }