Skip to content

[WIP] Verify if #64098 causes link errors #64232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions src/bootstrap/bin/rustc.rs
Original file line number Diff line number Diff line change
@@ -119,18 +119,9 @@ fn main() {
cmd.arg(format!("-Cdebuginfo={}", debuginfo_level));
}

if env::var_os("RUSTC_DENY_WARNINGS").is_some() &&
env::var_os("RUSTC_EXTERNAL_TOOL").is_none() {
// 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.
cmd.arg("-Dwarnings");
cmd.arg("-Drust_2018_idioms");
cmd.arg("-Dunused_lifetimes");
if use_internal_lints(crate_name) {
cmd.arg("-Zunstable-options");
cmd.arg("-Drustc::internal");
}
if use_internal_lints(crate_name) {
cmd.arg("-Zunstable-options");
cmd.arg("-Wrustc::internal");
}

if let Some(target) = target {
3 changes: 2 additions & 1 deletion src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
@@ -631,8 +631,9 @@ def build_bootstrap(self):
target_linker = self.get_toml("linker", build_section)
if target_linker is not None:
env["RUSTFLAGS"] += "-C linker=" + target_linker + " "
env["RUSTFLAGS"] += " -Wrust_2018_idioms -Wunused_lifetimes "
if self.get_toml("deny-warnings", "rust") != "false":
env["RUSTFLAGS"] += "-Dwarnings -Drust_2018_idioms -Dunused_lifetimes "
env["RUSTFLAGS"] += "-Dwarnings "

env["PATH"] = os.path.join(self.bin_root(), "bin") + \
os.pathsep + env["PATH"]
45 changes: 35 additions & 10 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
@@ -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");
@@ -873,6 +875,28 @@ impl<'a> Builder<'a> {
extra_args.push_str("-Zforce-unstable-if-unmarked");
}

match mode {
Mode::ToolStd { in_tree: true } |
Mode::ToolRustc { in_tree: true } |
Mode::ToolBootstrap { in_tree: true } |
Mode::Std |
Mode::Rustc |
Mode::Codegen => {
// 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.
extra_args.push_str(" -Wrust_2018_idioms");
extra_args.push_str(" -Wunused_lifetimes");
}
Mode::ToolStd { in_tree: false } |
Mode::ToolRustc { in_tree: false } |
Mode::ToolBootstrap { in_tree: false } => {}
}

if self.config.deny_warnings {
extra_args.push_str(" -Dwarnings");
}

if !extra_args.is_empty() {
cargo.env(
"RUSTFLAGS",
@@ -891,7 +915,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 +972,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());

@@ -1031,10 +1060,6 @@ impl<'a> Builder<'a> {

cargo.env("RUSTC_VERBOSE", self.verbosity.to_string());

if self.config.deny_warnings {
cargo.env("RUSTC_DENY_WARNINGS", "1");
}

// Throughout the build Cargo can execute a number of build scripts
// compiling C/C++ code and we need to pass compilers, archivers, flags, etc
// obtained previously to those build scripts.
8 changes: 4 additions & 4 deletions src/bootstrap/check.rs
Original file line number Diff line number Diff line change
@@ -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<String>,
) -> 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")
}
7 changes: 3 additions & 4 deletions src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
@@ -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,
&[]
);

6 changes: 3 additions & 3 deletions src/bootstrap/flags.rs
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@ pub struct Flags {
// This overrides the deny-warnings configuation option,
// which passes -Dwarnings to the compiler invocations.
//
// true => deny, false => allow
// true => deny, false => warn
pub deny_warnings: Option<bool>,
}

@@ -556,10 +556,10 @@ fn split(s: &[String]) -> Vec<String> {
fn parse_deny_warnings(matches: &getopts::Matches) -> Option<bool> {
match matches.opt_str("warnings").as_ref().map(|v| v.as_str()) {
Some("deny") => Some(true),
Some("allow") => Some(false),
Some("warn") => Some(false),
Some(value) => {
eprintln!(
r#"invalid value for --warnings: {:?}, expected "allow" or "deny""#,
r#"invalid value for --warnings: {:?}, expected "warn" or "deny""#,
value,
);
process::exit(1);
12 changes: 6 additions & 6 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
@@ -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))
28 changes: 10 additions & 18 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
@@ -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,19 +545,18 @@ 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
cargo.env("SYSROOT", builder.sysroot(compiler));
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");
49 changes: 14 additions & 35 deletions src/bootstrap/tool.rs
Original file line number Diff line number Diff line change
@@ -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<String>,
}

@@ -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<String>,
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::<Vec<_>>();
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<PathBuf> = 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
8 changes: 2 additions & 6 deletions src/ci/azure-pipelines/try.yml
Original file line number Diff line number Diff line change
@@ -14,14 +14,10 @@ jobs:
- template: steps/run.yml
strategy:
matrix:
dist-x86_64-linux:
IMAGE: dist-x86_64-linux
dist-various-2:
IMAGE: dist-various-2
DEPLOY: 1

dist-x86_64-linux-alt:
IMAGE: dist-x86_64-linux
DEPLOY_ALT: 1

# The macOS and Windows builds here are currently disabled due to them not being
# overly necessary on `try` builds. We also don't actually have anything that
# consumes the artifacts currently. Perhaps one day we can reenable, but for now