Skip to content
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
14 changes: 9 additions & 5 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1999,12 +1999,16 @@ impl Step for Sysroot {
}

// Copy the compiler into the correct sysroot.
// NOTE(#108767): We intentionally don't copy `rustc-dev` artifacts until they're requested with `builder.ensure(Rustc)`.
// This fixes an issue where we'd have multiple copies of libc in the sysroot with no way to tell which to load.
// There are a few quirks of bootstrap that interact to make this reliable:
//
// FIXME(#156525): investigate if this is still needed.
//
// NOTE(#108767): We intentionally don't copy `rustc-dev` artifacts until they're
// requested with `builder.ensure(Rustc)`. This fixes an issue where we'd have multiple
// copies of libc in the sysroot with no way to tell which to load. There are a few
// quirks of bootstrap that interact to make this reliable:
// 1. The order `Step`s are run is hard-coded in `builder.rs` and not configurable. This
// avoids e.g. reordering `test::UiFulldeps` before `test::Ui` and causing the latter to
// fail because of duplicate metadata.
// avoids e.g. reordering `test::UiFulldeps` before `test::Ui` and causing the latter
// to fail because of duplicate metadata.
// 2. The sysroot is deleted and recreated between each invocation, so running `x test
// ui-fulldeps && x test ui` can't cause failures.
let mut filtered_files = Vec::new();
Expand Down
8 changes: 4 additions & 4 deletions src/bootstrap/src/core/build_steps/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ impl Step for Rustfmt {
let compilers = RustcPrivateCompilers::new(builder, stage, host);
let rustfmt_build = builder.ensure(tool::Rustfmt::from_compilers(compilers));

let mut rustfmt = tool::prepare_tool_cargo(
let mut cargo = tool::prepare_tool_cargo(
builder,
rustfmt_build.build_compiler,
Mode::ToolRustcPrivate,
Expand All @@ -521,10 +521,10 @@ impl Step for Rustfmt {
&[],
);

rustfmt.args(["--bin", "rustfmt", "--"]);
rustfmt.args(builder.config.args());
cargo.args(["--bin", "rustfmt", "--"]);
cargo.args(builder.config.args());

rustfmt.into_cmd().run(builder);
cargo.into_cmd().run(builder);
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,11 @@ impl Step for Rustfmt {
let build_compiler = self.compilers.build_compiler();
let target = self.compilers.target();

// FIXME(#156525): `compile::Sysroot::run` intentionally do not copy `rustc-dev` artifacts
// until they're requested with `builder.ensure(Rustc)`, relevant for `download-rustc`
// flows.
builder.ensure(compile::Rustc::new(build_compiler, target));

let mut cargo = tool::prepare_tool_cargo(
builder,
build_compiler,
Expand Down Expand Up @@ -941,6 +946,11 @@ impl Step for Clippy {
let target_compiler = self.compilers.target_compiler();
let build_compiler = self.compilers.build_compiler();

// FIXME(#156525): `compile::Sysroot::run` intentionally do not copy `rustc-dev` artifacts
// until they're requested with `builder.ensure(Rustc)`, relevant for `download-rustc`
// flows.
builder.ensure(compile::Rustc::new(build_compiler, target));

let mut cargo = tool::prepare_tool_cargo(
builder,
build_compiler,
Expand Down
6 changes: 6 additions & 0 deletions src/bootstrap/src/core/build_steps/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,12 @@ pub fn prepare_tool_cargo(
// avoid rebuilding when running tests.
cargo.env("SYSROOT", builder.sysroot(compiler));

// Make sure we explicitly add rustc_private libs to path centrally here so that
// RustcPrivate tools can pick them up.
if mode == Mode::ToolRustcPrivate {
cargo.add_rustc_lib_path(builder);
}

// if tools are using lzma we want to force the build script to build its
// own copy
cargo.env("LZMA_API_STATIC", "1");
Expand Down
Loading