-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Clean up dependency tracking in Rustbuild [1/2] #50904
Conversation
c73b239
to
5f40201
Compare
src/bootstrap/lib.rs
Outdated
/// Build librustc and compiler libraries, placing output in the "stageN-rustc" directory. | ||
Librustc, | ||
/// Build librustc, codegen and compiler libraries, placing output | ||
/// in the "stageN-rustc" directory. |
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 comment should be modified for Codegen since we place its output in -codegen directory.
src/bootstrap/lib.rs
Outdated
Mode::ToolTest => "-tools", | ||
Mode::Codegen => "-rustc", | ||
Mode::Rustc => "-rustc", | ||
Mode::ToolRustc => "-tools", |
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.
Let's instead combine all of the tools into one pattern or have them after each other so it's clearer what's going on
src/bootstrap/tool.rs
Outdated
let compiler = if builder.force_use_stage1(compiler, target) { | ||
builder.compiler(1, compiler.host) | ||
} else { | ||
compiler | ||
}; | ||
|
||
for &cur_mode in &[Mode::Libstd, Mode::Libtest, Mode::Librustc] { | ||
for &cur_mode in &[Mode::ToolStd, Mode::ToolTest, Mode::ToolRustc] { |
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 believe we're calling CleanTools with Mode::Rustc
instead of RustcTool
in at least some places. Let's change the field to cause: Mode
(or a different name if you can come up with something better) and switch these back to Mode::Std
, Mode::Test
and Mode::Rustc
.
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.
Hi, @Mark-Simulacrum Just to make sure I'm getting this right. Do you mean we should change the field mode: Mode
on CleanTools
to cause: Mode
? Also, should the values just remain as they were? Thanks.
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.
Yes, change the field to cause, and change values to Mode::Std
vs. Mode::ToolStd
since the cause was Std
, not a tool.
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.
Got it. Thanks again!
src/bootstrap/tool.rs
Outdated
@@ -202,7 +202,7 @@ impl Step for ToolBuild { | |||
return None; | |||
} | |||
} else { | |||
let cargo_out = builder.cargo_out(compiler, Mode::Tool, target) | |||
let cargo_out = builder.cargo_out(compiler, Mode::ToolRustc, target) |
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 should be self.mode
instead
src/bootstrap/tool.rs
Outdated
@@ -218,7 +218,7 @@ pub fn prepare_tool_cargo( | |||
command: &'static str, | |||
path: &'static str, | |||
) -> Command { | |||
let mut cargo = builder.cargo(compiler, Mode::Tool, target, command); | |||
let mut cargo = builder.cargo(compiler, Mode::ToolRustc, target, command); |
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.
We'll want prepare_tool_cargo
to take the mode as an argument; that'll make future changes easier. Generally speaking we should be threading tool modes through so that we never just pick "ToolRustc" for no reason.
src/bootstrap/tool.rs
Outdated
@@ -587,7 +587,7 @@ impl<'a> Builder<'a> { | |||
let host = &compiler.host; | |||
let mut lib_paths: Vec<PathBuf> = vec![ | |||
PathBuf::from(&self.sysroot_libdir(compiler, compiler.host)), | |||
self.cargo_out(compiler, Mode::Tool, *host).join("deps"), | |||
self.cargo_out(compiler, Mode::ToolRustc, *host).join("deps"), |
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.
Same as above, this should thread mode through from arguments
Hi @Mark-Simulacrum, this should now be ready for another look. Thanks! |
src/bootstrap/test.rs
Outdated
@@ -264,6 +264,7 @@ impl Step for Rls { | |||
|
|||
let mut cargo = tool::prepare_tool_cargo(builder, | |||
compiler, | |||
Mode::Rustc, |
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 should be Mode::ToolRustc
as we're building a tool
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.
Oops! let me fix this ASAP
src/bootstrap/test.rs
Outdated
@@ -318,6 +319,7 @@ impl Step for Rustfmt { | |||
|
|||
let mut cargo = tool::prepare_tool_cargo(builder, | |||
compiler, | |||
Mode::Rustc, |
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.
Same here, Mode::ToolRustc
src/bootstrap/builder.rs
Outdated
@@ -662,7 +662,7 @@ impl<'a> Builder<'a> { | |||
cargo.env("RUSTDOC_LIBDIR", self.rustc_libdir(self.compiler(2, self.config.build))); | |||
} | |||
|
|||
if mode == Mode::Tool { | |||
if [Mode::ToolRustc, Mode::ToolStd, Mode::ToolTest].iter().any(|m| &mode == m) { |
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.
Let's implement an is_tool
method on Tool
.
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.
By this, do you mean we should use a closure is_tool
that checks if mode is in ToolRustc, ToolStd, etc
?
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.
Not quite -- method on Tool
, not a closure.
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.
It makes sense now. Thanks!
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
7f47fb6
to
2c9ded9
Compare
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
☔ The latest upstream changes (presumably #50892) made this pull request unmergeable. Please resolve the merge conflicts. |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
Fixed! cc @Mark-Simulacrum |
src/bootstrap/builder.rs
Outdated
@@ -662,7 +663,7 @@ impl<'a> Builder<'a> { | |||
cargo.env("RUSTDOC_LIBDIR", self.rustc_libdir(self.compiler(2, self.config.build))); | |||
} | |||
|
|||
if mode == Mode::Tool { | |||
if Tool::is_tool(mode) { |
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.
Could we instead make this inherent, so mode.is_tool()
? I think I may have previously mislead you; I intended this to be implemented on Mode
.
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.
No worries! Going to fix this ASAP. Thanks
☔ The latest upstream changes (presumably #51138) made this pull request unmergeable. Please resolve the merge conflicts. |
Hi @Mark-Simulacrum, this should be fixed now. Thanks! |
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 think this is the last thing!
src/bootstrap/builder.rs
Outdated
@@ -1012,7 +1012,7 @@ impl<'a> Builder<'a> { | |||
// be resolved because MinGW has the import library. The downside is we | |||
// don't get newer functions from Windows, but we don't use any of them | |||
// anyway. | |||
if mode != Mode::Tool { | |||
if mode.is_tool() { |
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 should be !mode.is_tool()
.
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.
Oops! missed this.
Fixed! Thank you |
If you can clean up the commit history a little bit -- maybe merging in the |
make is_tool inherent prop of mode fix errors from rebase resolve issues from review
Done! thank you. |
@bors r+ |
📌 Commit 36eafe5 has been approved by |
Clean up dependency tracking in Rustbuild [1/2] Initial refactor of the `Mode` enum. Still a WIP Ref #50509 r? @Mark-Simulacrum
☀️ Test successful - status-appveyor, status-travis |
Clean up dependency tracking in Rustbuild [2/2] Make `clear_if_dirty` calls in `Builder::cargo` with stamp dependencies for the given Mode. Continuation of #50904 Ref issue #50509 r? @Mark-Simulacrum
Clean up dependency tracking in Rustbuild [2/2] Make `clear_if_dirty` calls in `Builder::cargo` with stamp dependencies for the given Mode. Continuation of #50904 Ref issue #50509 r? @Mark-Simulacrum
Clean up dependency tracking in Rustbuild [2/2] Make `clear_if_dirty` calls in `Builder::cargo` with stamp dependencies for the given Mode. Continuation of #50904 Ref issue #50509 r? @Mark-Simulacrum
Initial refactor of the
Mode
enum. Still a WIPRef #50509
r? @Mark-Simulacrum