-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Link rustc tools into the correct sysroot #123384
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,7 +81,11 @@ impl Step for ToolBuild { | |
match self.mode { | ||
Mode::ToolRustc => { | ||
builder.ensure(compile::Std::new(compiler, compiler.host)); | ||
builder.ensure(compile::Rustc::new(compiler, target)); | ||
// When building a tool that links against rustc, | ||
// we need the rustc to link against to be present and ready in the syroot. | ||
builder.ensure(compile::Assemble { | ||
target_compiler: compiler.with_stage(compiler.stage + 1), | ||
}); | ||
} | ||
Mode::ToolStd => builder.ensure(compile::Std::new(compiler, target)), | ||
Mode::ToolBootstrap => {} // uses downloaded stage0 compiler libs | ||
|
@@ -863,8 +867,8 @@ macro_rules! tool_extended { | |
$($name:ident, | ||
$path:expr, | ||
$tool_name:expr, | ||
mode = $mode:expr, | ||
stable = $stable:expr | ||
$(,tool_std = $tool_std:literal)? | ||
$(,allow_features = $allow_features:expr)? | ||
$(,add_bins_to_sysroot = $add_bins_to_sysroot:expr)? | ||
;)+) => { | ||
|
@@ -913,15 +917,16 @@ macro_rules! tool_extended { | |
compiler: $sel.compiler, | ||
target: $sel.target, | ||
tool: $tool_name, | ||
mode: if false $(|| $tool_std)? { Mode::ToolStd } else { Mode::ToolRustc }, | ||
mode: $mode, | ||
path: $path, | ||
extra_features: $sel.extra_features, | ||
source_type: SourceType::InTree, | ||
allow_features: concat!($($allow_features)*), | ||
}); | ||
|
||
if (false $(|| !$add_bins_to_sysroot.is_empty())?) && $sel.compiler.stage > 0 { | ||
let bindir = $builder.sysroot($sel.compiler).join("bin"); | ||
if (false $(|| !$add_bins_to_sysroot.is_empty())?) { | ||
// As usual, we copy the tool into the next sysroot, as it links against the compiler in that sysroot. | ||
let bindir = $builder.sysroot($sel.compiler.with_stage($sel.compiler.stage + 1)).join("bin"); | ||
t!(fs::create_dir_all(&bindir)); | ||
|
||
#[allow(unused_variables)] | ||
|
@@ -950,17 +955,17 @@ macro_rules! tool_extended { | |
// NOTE: Most submodule updates for tools are handled by bootstrap.py, since they're needed just to | ||
// invoke Cargo to build bootstrap. See the comment there for more details. | ||
tool_extended!((self, builder), | ||
Cargofmt, "src/tools/rustfmt", "cargo-fmt", stable=true; | ||
CargoClippy, "src/tools/clippy", "cargo-clippy", stable=true; | ||
Clippy, "src/tools/clippy", "clippy-driver", stable=true, add_bins_to_sysroot = ["clippy-driver", "cargo-clippy"]; | ||
Miri, "src/tools/miri", "miri", stable=false, add_bins_to_sysroot = ["miri"]; | ||
CargoMiri, "src/tools/miri/cargo-miri", "cargo-miri", stable=true, add_bins_to_sysroot = ["cargo-miri"]; | ||
Cargofmt, "src/tools/rustfmt", "cargo-fmt", mode=Mode::ToolRustc, stable=true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've also made this a bit more obvious as to which tools are what, looking for the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm gonna revert this change to keep the PR minimal as it's complicated enough as-is, but will keep that in mind if I do this change in the future. |
||
CargoClippy, "src/tools/clippy", "cargo-clippy", mode= Mode::ToolRustc, stable=true; | ||
Clippy, "src/tools/clippy", "clippy-driver", mode=Mode::ToolRustc, stable=true, add_bins_to_sysroot = ["clippy-driver", "cargo-clippy"]; | ||
Miri, "src/tools/miri", "miri", mode= Mode::ToolRustc, stable=false, add_bins_to_sysroot = ["miri"]; | ||
CargoMiri, "src/tools/miri/cargo-miri", "cargo-miri", mode=Mode::ToolRustc, stable=true, add_bins_to_sysroot = ["cargo-miri"]; | ||
// FIXME: tool_std is not quite right, we shouldn't allow nightly features. | ||
// But `builder.cargo` doesn't know how to handle ToolBootstrap in stages other than 0, | ||
// and this is close enough for now. | ||
Rls, "src/tools/rls", "rls", stable=true, tool_std=true; | ||
RustDemangler, "src/tools/rust-demangler", "rust-demangler", stable=false, tool_std=true; | ||
Rustfmt, "src/tools/rustfmt", "rustfmt", stable=true, add_bins_to_sysroot = ["rustfmt", "cargo-fmt"]; | ||
Rls, "src/tools/rls", "rls", mode=Mode::ToolStd, stable=true; | ||
RustDemangler, "src/tools/rust-demangler", "rust-demangler", mode=Mode::ToolStd, stable=false; | ||
Rustfmt, "src/tools/rustfmt", "rustfmt", mode=Mode::ToolRustc, stable=true, add_bins_to_sysroot = ["rustfmt", "cargo-fmt"]; | ||
); | ||
|
||
impl<'a> Builder<'a> { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that we put it into the correct stage, there's nothing wrong with
x build clippy --stage 0
anymore, and we can put that into the sysroot too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This conflicts with the idea of
ToolStd
andToolRustc
rust/src/bootstrap/src/lib.rs
Lines 257 to 266 in 029cb1b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't quite understand what you mean with this. The two
ToolStd
built here don't have any bins added to the sysroot anyways, so this doesn't affect them. As for theToolRustc
, this change was targetted specifically at them.