diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2020-06-26 00:39:01 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-26 00:39:01 -0700 |
| commit | 10d655bb474c2437e38e2926fc3f4d792bd7f7e9 (patch) | |
| tree | 860895555877490544645d5d05dec73177277704 /src/bootstrap | |
| parent | 2aee60897fc85c575ae5597861a9b40c6cdcab74 (diff) | |
| parent | 75983e137eeae5e9b210c2e97e6239bf888d9620 (diff) | |
Rollup merge of #73297 - ehuss:tool-warnings, r=Mark-Simulacrum
Support configurable deny-warnings for all in-tree crates. This removes the hard-coded `deny(warnings)` on all in-tree tools, and allows it to be configured from the config. This is just a personal preference, as I find `deny(warnings)` frustrating during development or doing small tests. This also fixes some regressions in terms of warning handling. Warnings used to be dependent on `SourceType`, but in #64316 it was changed to be based on `Mode`. This means tools like rustdoc no longer used the same settings as the rest of the tree. It also made `SourceType` useless since the only thing it was used for was warnings. I think it would be better for everything in the tree to use the same settings. Fixes #64523
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/builder.rs | 5 | ||||
| -rw-r--r-- | src/bootstrap/check.rs | 29 | ||||
| -rw-r--r-- | src/bootstrap/compile.rs | 10 | ||||
| -rw-r--r-- | src/bootstrap/doc.rs | 5 | ||||
| -rw-r--r-- | src/bootstrap/lib.rs | 19 | ||||
| -rw-r--r-- | src/bootstrap/test.rs | 6 | ||||
| -rw-r--r-- | src/bootstrap/tool.rs | 19 |
7 files changed, 59 insertions, 34 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 8f0a245a565..0735ba8869a 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -23,7 +23,7 @@ use crate::install; use crate::native; use crate::run; use crate::test; -use crate::tool; +use crate::tool::{self, SourceType}; use crate::util::{self, add_dylib_path, add_link_lib_path, exe, libdir}; use crate::{Build, DocTests, GitRepo, Mode}; @@ -759,6 +759,7 @@ impl<'a> Builder<'a> { &self, compiler: Compiler, mode: Mode, + source_type: SourceType, target: Interned<String>, cmd: &str, ) -> Cargo { @@ -1125,7 +1126,7 @@ impl<'a> Builder<'a> { cargo.env("RUSTC_VERBOSE", self.verbosity.to_string()); - if !mode.is_tool() { + if source_type == SourceType::InTree { // When extending this list, add the new lints to the RUSTFLAGS of the // build_bootstrap function of src/bootstrap/bootstrap.py as well as // some code doesn't go through this `rustc` wrapper. diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index 7a8bfb2d5d8..0d38d2eebe7 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -44,7 +44,13 @@ impl Step for Std { let target = self.target; let compiler = builder.compiler(0, builder.config.build); - let mut cargo = builder.cargo(compiler, Mode::Std, target, cargo_subcommand(builder.kind)); + let mut cargo = builder.cargo( + compiler, + Mode::Std, + SourceType::InTree, + target, + cargo_subcommand(builder.kind), + ); std_cargo(builder, target, compiler.stage, &mut cargo); builder.info(&format!("Checking std artifacts ({} -> {})", &compiler.host, target)); @@ -92,8 +98,13 @@ impl Step for Rustc { builder.ensure(Std { target }); - let mut cargo = - builder.cargo(compiler, Mode::Rustc, target, cargo_subcommand(builder.kind)); + let mut cargo = builder.cargo( + compiler, + Mode::Rustc, + SourceType::InTree, + target, + cargo_subcommand(builder.kind), + ); rustc_cargo(builder, &mut cargo, target); builder.info(&format!("Checking compiler artifacts ({} -> {})", &compiler.host, target)); @@ -113,7 +124,7 @@ impl Step for Rustc { } macro_rules! tool_check_step { - ($name:ident, $path:expr) => { + ($name:ident, $path:expr, $source_type:expr) => { #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct $name { pub target: Interned<String>, @@ -145,7 +156,7 @@ macro_rules! tool_check_step { target, cargo_subcommand(builder.kind), $path, - SourceType::InTree, + $source_type, &[], ); @@ -184,8 +195,12 @@ macro_rules! tool_check_step { }; } -tool_check_step!(Rustdoc, "src/tools/rustdoc"); -tool_check_step!(Clippy, "src/tools/clippy"); +tool_check_step!(Rustdoc, "src/tools/rustdoc", SourceType::InTree); +// Clippy is a hybrid. It is an external tool, but uses a git subtree instead +// of a submodule. Since the SourceType only drives the deny-warnings +// behavior, treat it as in-tree so that any new warnings in clippy will be +// rejected. +tool_check_step!(Clippy, "src/tools/clippy", SourceType::InTree); /// Cargo's output path for the standard library in a given stage, compiled /// by a particular compiler for the specified target. diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index afcf0dcac7e..0208dc8ba5e 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -20,14 +20,14 @@ use filetime::FileTime; use serde::Deserialize; use crate::builder::Cargo; +use crate::builder::{Builder, Kind, RunConfig, ShouldRun, Step}; +use crate::cache::{Interned, INTERNER}; use crate::dist; use crate::native; +use crate::tool::SourceType; use crate::util::{exe, is_dylib, symlink_dir}; use crate::{Compiler, DependencyType, GitRepo, Mode}; -use crate::builder::{Builder, Kind, RunConfig, ShouldRun, Step}; -use crate::cache::{Interned, INTERNER}; - #[derive(Debug, PartialOrd, Ord, Copy, Clone, PartialEq, Eq, Hash)] pub struct Std { pub target: Interned<String>, @@ -87,7 +87,7 @@ impl Step for Std { target_deps.extend(copy_third_party_objects(builder, &compiler, target)); target_deps.extend(copy_self_contained_objects(builder, &compiler, target)); - let mut cargo = builder.cargo(compiler, Mode::Std, target, "build"); + let mut cargo = builder.cargo(compiler, Mode::Std, SourceType::InTree, target, "build"); std_cargo(builder, target, compiler.stage, &mut cargo); builder.info(&format!( @@ -513,7 +513,7 @@ impl Step for Rustc { target: builder.config.build, }); - let mut cargo = builder.cargo(compiler, Mode::Rustc, target, "build"); + let mut cargo = builder.cargo(compiler, Mode::Rustc, SourceType::InTree, target, "build"); rustc_cargo(builder, &mut cargo, target); builder.info(&format!( diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index 6d7fb7acfcb..8b76158f9e5 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -435,7 +435,8 @@ impl Step for Std { t!(fs::copy(builder.src.join("src/doc/rust.css"), out.join("rust.css"))); let run_cargo_rustdoc_for = |package: &str| { - let mut cargo = builder.cargo(compiler, Mode::Std, target, "rustdoc"); + let mut cargo = + builder.cargo(compiler, Mode::Std, SourceType::InTree, target, "rustdoc"); compile::std_cargo(builder, target, compiler.stage, &mut cargo); // Keep a whitelist so we do not build internal stdlib crates, these will be @@ -534,7 +535,7 @@ impl Step for Rustc { t!(symlink_dir_force(&builder.config, &out, &out_dir)); // Build cargo command. - let mut cargo = builder.cargo(compiler, Mode::Rustc, target, "doc"); + let mut cargo = builder.cargo(compiler, Mode::Rustc, SourceType::InTree, target, "doc"); cargo.env( "RUSTDOCFLAGS", "--document-private-items \ diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index e7aeb08643c..5728b9d24de 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -301,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, } diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index bb35203c826..12ab6b1636c 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -367,7 +367,8 @@ impl Step for Miri { extra_features: Vec::new(), }); if let (Some(miri), Some(_cargo_miri)) = (miri, cargo_miri) { - let mut cargo = builder.cargo(compiler, Mode::ToolRustc, host, "install"); + let mut cargo = + builder.cargo(compiler, Mode::ToolRustc, SourceType::Submodule, host, "install"); cargo.arg("xargo"); // Configure `cargo install` path. cargo adds a `bin/`. cargo.env("CARGO_INSTALL_ROOT", &builder.out); @@ -1696,7 +1697,8 @@ impl Step for Crate { // we're working with automatically. let compiler = builder.compiler_for(compiler.stage, compiler.host, target); - let mut cargo = builder.cargo(compiler, mode, target, test_kind.subcommand()); + let mut cargo = + builder.cargo(compiler, mode, SourceType::InTree, target, test_kind.subcommand()); match mode { Mode::Std => { compile::std_cargo(builder, target, compiler.stage, &mut cargo); diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index c92082a9423..0055dee6092 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -16,7 +16,7 @@ use crate::util::{add_dylib_path, exe, CiEnv}; use crate::Compiler; use crate::Mode; -#[derive(Debug, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum SourceType { InTree, Submodule, @@ -226,14 +226,10 @@ pub fn prepare_tool_cargo( source_type: SourceType, extra_features: &[String], ) -> CargoCommand { - let mut cargo = builder.cargo(compiler, mode, target, command); + let mut cargo = builder.cargo(compiler, mode, source_type, target, command); let dir = builder.src.join(path); cargo.arg("--manifest-path").arg(dir.join("Cargo.toml")); - if source_type == SourceType::Submodule { - cargo.env("RUSTC_EXTERNAL_TOOL", "1"); - } - let mut features = extra_features.to_vec(); if builder.build.config.cargo_native_static { if path.ends_with("cargo") @@ -596,6 +592,7 @@ macro_rules! tool_extended { $path:expr, $tool_name:expr, stable = $stable:expr, + $(in_tree = $in_tree:expr,)* $extra_deps:block;)+) => { $( #[derive(Debug, Clone, Hash, PartialEq, Eq)] @@ -647,7 +644,11 @@ macro_rules! tool_extended { path: $path, extra_features: $sel.extra_features, is_optional_tool: true, - source_type: SourceType::Submodule, + source_type: if false $(|| $in_tree)* { + SourceType::InTree + } else { + SourceType::Submodule + }, }) } } @@ -659,8 +660,8 @@ macro_rules! tool_extended { // to make `./x.py build <tool>` work. tool_extended!((self, builder), Cargofmt, rustfmt, "src/tools/rustfmt", "cargo-fmt", stable=true, {}; - CargoClippy, clippy, "src/tools/clippy", "cargo-clippy", stable=true, {}; - Clippy, clippy, "src/tools/clippy", "clippy-driver", stable=true, {}; + CargoClippy, clippy, "src/tools/clippy", "cargo-clippy", stable=true, in_tree=true, {}; + Clippy, clippy, "src/tools/clippy", "clippy-driver", stable=true, in_tree=true, {}; Miri, miri, "src/tools/miri", "miri", stable=false, {}; CargoMiri, miri, "src/tools/miri/cargo-miri", "cargo-miri", stable=false, {}; Rls, rls, "src/tools/rls", "rls", stable=true, { |
