Skip to content
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

always run configure_linker except for mir-opt tests #120803

Merged
merged 2 commits into from
Feb 11, 2024
Merged
Show file tree
Hide file tree
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
19 changes: 14 additions & 5 deletions src/bootstrap/src/core/build_steps/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ use crate::core::build_steps::compile::{
add_to_sysroot, run_cargo, rustc_cargo, rustc_cargo_env, std_cargo,
};
use crate::core::build_steps::tool::{prepare_tool_cargo, SourceType};
use crate::core::builder::{crate_description, Alias, Builder, Kind, RunConfig, ShouldRun, Step};
use crate::core::builder::{
self, crate_description, Alias, Builder, Kind, RunConfig, ShouldRun, Step,
};
use crate::core::config::TargetSelection;
use crate::utils::cache::Interned;
use crate::INTERNER;
Expand Down Expand Up @@ -110,13 +112,15 @@ impl Step for Std {
let target = self.target;
let compiler = builder.compiler(builder.top_stage, builder.config.build);

let mut cargo = builder.cargo(
let mut cargo = builder::Cargo::new(
builder,
compiler,
Mode::Std,
SourceType::InTree,
target,
cargo_subcommand(builder.kind),
);

std_cargo(builder, target, compiler.stage, &mut cargo);
if matches!(builder.config.cmd, Subcommand::Fix { .. }) {
// By default, cargo tries to fix all targets. Tell it not to fix tests until we've added `test` to the sysroot.
Expand Down Expand Up @@ -162,7 +166,8 @@ impl Step for Std {
// since we initialize with an empty sysroot.
//
// Currently only the "libtest" tree of crates does this.
let mut cargo = builder.cargo(
let mut cargo = builder::Cargo::new(
builder,
compiler,
Mode::Std,
SourceType::InTree,
Expand Down Expand Up @@ -256,13 +261,15 @@ impl Step for Rustc {
builder.ensure(Std::new(target));
}

let mut cargo = builder.cargo(
let mut cargo = builder::Cargo::new(
builder,
compiler,
Mode::Rustc,
SourceType::InTree,
target,
cargo_subcommand(builder.kind),
);

rustc_cargo(builder, &mut cargo, target, compiler.stage);

// For ./x.py clippy, don't run with --all-targets because
Expand Down Expand Up @@ -332,13 +339,15 @@ impl Step for CodegenBackend {

builder.ensure(Rustc::new(target, builder));

let mut cargo = builder.cargo(
let mut cargo = builder::Cargo::new(
builder,
compiler,
Mode::Codegen,
SourceType::InTree,
target,
cargo_subcommand(builder.kind),
);

cargo
.arg("--manifest-path")
.arg(builder.src.join(format!("compiler/rustc_codegen_{backend}/Cargo.toml")));
Expand Down
38 changes: 34 additions & 4 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use serde_derive::Deserialize;
use crate::core::build_steps::dist;
use crate::core::build_steps::llvm;
use crate::core::build_steps::tool::SourceType;
use crate::core::builder;
use crate::core::builder::crate_description;
use crate::core::builder::Cargo;
use crate::core::builder::{Builder, Kind, PathSet, RunConfig, ShouldRun, Step, TaskPath};
Expand Down Expand Up @@ -237,12 +238,26 @@ impl Step for Std {
// with -Zalways-encode-mir. This frees us from the need to have a target linker, and the
// fact that this is a check build integrates nicely with run_cargo.
let mut cargo = if self.is_for_mir_opt_tests {
let mut cargo = builder.cargo(compiler, Mode::Std, SourceType::InTree, target, "check");
let mut cargo = builder::Cargo::new_for_mir_opt_tests(
builder,
compiler,
Mode::Std,
SourceType::InTree,
target,
"check",
);
cargo.rustflag("-Zalways-encode-mir");
cargo.arg("--manifest-path").arg(builder.src.join("library/sysroot/Cargo.toml"));
cargo
} else {
let mut cargo = builder.cargo(compiler, Mode::Std, SourceType::InTree, target, "build");
let mut cargo = builder::Cargo::new(
builder,
compiler,
Mode::Std,
SourceType::InTree,
target,
"build",
);
std_cargo(builder, target, compiler.stage, &mut cargo);
for krate in &*self.crates {
cargo.arg("-p").arg(krate);
Expand Down Expand Up @@ -911,7 +926,15 @@ impl Step for Rustc {
builder.config.build,
));

let mut cargo = builder.cargo(compiler, Mode::Rustc, SourceType::InTree, target, "build");
let mut cargo = builder::Cargo::new(
builder,
compiler,
Mode::Rustc,
SourceType::InTree,
target,
"build",
);

rustc_cargo(builder, &mut cargo, target, compiler.stage);

if builder.config.rust_profile_use.is_some()
Expand Down Expand Up @@ -1331,7 +1354,14 @@ impl Step for CodegenBackend {

let out_dir = builder.cargo_out(compiler, Mode::Codegen, target);

let mut cargo = builder.cargo(compiler, Mode::Codegen, SourceType::InTree, target, "build");
let mut cargo = builder::Cargo::new(
builder,
compiler,
Mode::Codegen,
SourceType::InTree,
target,
"build",
);
cargo
.arg("--manifest-path")
.arg(builder.src.join(format!("compiler/rustc_codegen_{backend}/Cargo.toml")));
Expand Down
10 changes: 7 additions & 3 deletions src/bootstrap/src/core/build_steps/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::{fs, mem};

use crate::core::build_steps::compile;
use crate::core::build_steps::tool::{self, prepare_tool_cargo, SourceType, Tool};
use crate::core::builder::crate_description;
use crate::core::builder::{self, crate_description};
use crate::core::builder::{Alias, Builder, Compiler, Kind, RunConfig, ShouldRun, Step};
use crate::core::config::{Config, TargetSelection};
use crate::utils::cache::{Interned, INTERNER};
Expand Down Expand Up @@ -684,7 +684,9 @@ fn doc_std(
// as a function parameter.
let out_dir = target_dir.join(target.triple).join("doc");

let mut cargo = builder.cargo(compiler, Mode::Std, SourceType::InTree, target, "doc");
let mut cargo =
builder::Cargo::new(builder, compiler, Mode::Std, SourceType::InTree, target, "doc");

compile::std_cargo(builder, target, compiler.stage, &mut cargo);
cargo
.arg("--no-deps")
Expand Down Expand Up @@ -785,7 +787,9 @@ impl Step for Rustc {
);

// Build cargo command.
let mut cargo = builder.cargo(compiler, Mode::Rustc, SourceType::InTree, target, "doc");
let mut cargo =
builder::Cargo::new(builder, compiler, Mode::Rustc, SourceType::InTree, target, "doc");

cargo.rustdocflag("--document-private-items");
// Since we always pass --document-private-items, there's no need to warn about linking to private items.
cargo.rustdocflag("-Arustdoc::private-intra-doc-links");
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/build_steps/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ impl Step for Miri {
SourceType::InTree,
&[],
);
miri.add_rustc_lib_path(builder, compiler);
miri.add_rustc_lib_path(builder);
// Forward arguments.
miri.arg("--").arg("--target").arg(target.rustc_target_arg());
miri.args(builder.config.args());
Expand Down
34 changes: 23 additions & 11 deletions src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use crate::core::build_steps::llvm;
use crate::core::build_steps::synthetic_targets::MirOptPanicAbortSyntheticTarget;
use crate::core::build_steps::tool::{self, SourceType, Tool};
use crate::core::build_steps::toolstate::ToolState;
use crate::core::builder;
use crate::core::builder::crate_description;
use crate::core::builder::{Builder, Compiler, Kind, RunConfig, ShouldRun, Step};
use crate::core::config::flags::get_completion;
Expand Down Expand Up @@ -380,7 +381,7 @@ impl Step for RustAnalyzer {
// work in Rust CI
cargo.env("SKIP_SLOW_TESTS", "1");

cargo.add_rustc_lib_path(builder, compiler);
cargo.add_rustc_lib_path(builder);
run_cargo_test(cargo, &[], &[], "rust-analyzer", "rust-analyzer", compiler, host, builder);
}
}
Expand Down Expand Up @@ -426,7 +427,7 @@ impl Step for Rustfmt {
t!(fs::create_dir_all(&dir));
cargo.env("RUSTFMT_TEST_DIR", dir);

cargo.add_rustc_lib_path(builder, compiler);
cargo.add_rustc_lib_path(builder);

run_cargo_test(cargo, &[], &[], "rustfmt", "rustfmt", compiler, host, builder);
}
Expand Down Expand Up @@ -476,7 +477,7 @@ impl Step for RustDemangler {
t!(fs::create_dir_all(&dir));

cargo.env("RUST_DEMANGLER_DRIVER_PATH", rust_demangler);
cargo.add_rustc_lib_path(builder, compiler);
cargo.add_rustc_lib_path(builder);

run_cargo_test(
cargo,
Expand Down Expand Up @@ -517,7 +518,7 @@ impl Miri {
SourceType::InTree,
&[],
);
cargo.add_rustc_lib_path(builder, compiler);
cargo.add_rustc_lib_path(builder);
cargo.arg("--").arg("miri").arg("setup");
cargo.arg("--target").arg(target.rustc_target_arg());

Expand Down Expand Up @@ -618,7 +619,7 @@ impl Step for Miri {
);
let _guard = builder.msg_sysroot_tool(Kind::Test, compiler.stage, "miri", host, target);

cargo.add_rustc_lib_path(builder, compiler);
cargo.add_rustc_lib_path(builder);

// miri tests need to know about the stage sysroot
cargo.env("MIRI_SYSROOT", &miri_sysroot);
Expand Down Expand Up @@ -671,7 +672,7 @@ impl Step for Miri {
SourceType::Submodule,
&[],
);
cargo.add_rustc_lib_path(builder, compiler);
cargo.add_rustc_lib_path(builder);
cargo.arg("--").arg("miri").arg("test");
if builder.config.locked_deps {
cargo.arg("--locked");
Expand Down Expand Up @@ -788,7 +789,7 @@ impl Step for Clippy {
let host_libs = builder.stage_out(compiler, Mode::ToolRustc).join(builder.cargo_dir());
cargo.env("HOST_LIBS", host_libs);

cargo.add_rustc_lib_path(builder, compiler);
cargo.add_rustc_lib_path(builder);
let mut cargo = prepare_cargo_test(cargo, &[], &[], "clippy", compiler, host, builder);

let _guard = builder.msg_sysroot_tool(Kind::Test, compiler.stage, "clippy", host, host);
Expand Down Expand Up @@ -2499,8 +2500,15 @@ 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, SourceType::InTree, target, builder.kind.as_str());
let mut cargo = builder::Cargo::new(
builder,
compiler,
mode,
SourceType::InTree,
target,
builder.kind.as_str(),
);

match mode {
Mode::Std => {
compile::std_cargo(builder, target, compiler.stage, &mut cargo);
Expand Down Expand Up @@ -3134,13 +3142,15 @@ impl Step for CodegenCranelift {
let compiler = builder.compiler_for(compiler.stage, compiler.host, target);

let build_cargo = || {
let mut cargo = builder.cargo(
let mut cargo = builder::Cargo::new(
builder,
compiler,
Mode::Codegen, // Must be codegen to ensure dlopen on compiled dylibs works
SourceType::InTree,
target,
"run",
);

cargo.current_dir(&builder.src.join("compiler/rustc_codegen_cranelift"));
cargo
.arg("--manifest-path")
Expand Down Expand Up @@ -3260,13 +3270,15 @@ impl Step for CodegenGCC {
let compiler = builder.compiler_for(compiler.stage, compiler.host, target);

let build_cargo = || {
let mut cargo = builder.cargo(
let mut cargo = builder::Cargo::new(
builder,
compiler,
Mode::Codegen, // Must be codegen to ensure dlopen on compiled dylibs works
SourceType::InTree,
target,
"run",
);

cargo.current_dir(&builder.src.join("compiler/rustc_codegen_gcc"));
cargo
.arg("--manifest-path")
Expand Down
4 changes: 3 additions & 1 deletion src/bootstrap/src/core/build_steps/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::process::Command;

use crate::core::build_steps::compile;
use crate::core::build_steps::toolstate::ToolState;
use crate::core::builder;
use crate::core::builder::{Builder, Cargo as CargoCommand, RunConfig, ShouldRun, Step};
use crate::core::config::TargetSelection;
use crate::utils::channel::GitInfo;
Expand Down Expand Up @@ -142,7 +143,8 @@ pub fn prepare_tool_cargo(
source_type: SourceType,
extra_features: &[String],
) -> CargoCommand {
let mut cargo = builder.cargo(compiler, mode, source_type, target, command);
let mut cargo = builder::Cargo::new(builder, compiler, mode, source_type, target, command);

let dir = builder.src.join(path);
cargo.arg("--manifest-path").arg(dir.join("Cargo.toml"));

Expand Down
Loading
Loading