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

tool::prepare_tool_cargo should run builder.ensure automatically, based on tool mode #128012

Open
tgross35 opened this issue Jul 20, 2024 · 4 comments
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@tgross35
Copy link
Contributor

I was somewhat thrown off by 6062059#diff-675065335a90de4a4e1ac5bc0a078709f865ff2d357ba2650309f0ad8614b1d3R3531-R3549; setting Mode::ToolStd or some of the other Mode::Tool* options caused a can't find crate for `core` (and std) error. This was fixed by adding builder.ensure(compile::Std::new(compiler, bootstrap_host));.

Since prepare_tool_cargo knows the mode, it should just call builder.ensure itself. This manual ensure could then be removed from the rest of build_steps/test.rs.

@tgross35 tgross35 added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. A-testsuite Area: The testsuite used to check the correctness of rustc T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jul 20, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 20, 2024
@tgross35 tgross35 removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 20, 2024
@onur-ozkan
Copy link
Member

Tools test steps usually ensure their corresponding step in tool module and that is usually managed by ToolBuild step. When you look at ToolBuild::run, you can see that it handles this problem:

/// Builds a tool in `src/tools`
///
/// This will build the specified tool with the specified `host` compiler in
/// `stage` into the normal cargo output directory.
fn run(self, builder: &Builder<'_>) -> PathBuf {
let compiler = self.compiler;
let target = self.target;
let mut tool = self.tool;
let path = self.path;
match self.mode {
Mode::ToolRustc => {
builder.ensure(compile::Std::new(compiler, compiler.host));
builder.ensure(compile::Rustc::new(compiler, target));
}
Mode::ToolStd => builder.ensure(compile::Std::new(compiler, target)),
Mode::ToolBootstrap => {} // uses downloaded stage0 compiler libs
_ => panic!("unexpected Mode for tool build"),
}

So, if you add this new tool under tool module with ToolBuild, this problem will be handled automatically.

@tgross35
Copy link
Contributor Author

I opened this because a few other tools seem to call builder.ensure(compile::Std::new(...)) right before tool::prepare_tool_cargo (Miri, CompiletestTest, RunMakeSupport, CrateRustdoc, TierCheck) so it seemed like a common pattern.

Are you saying that the new TestFloatParse could just be a ToolBuild step? I think I looked at that first but since it needs to both cargo test and cargo run with some args, it seemed like it was easier to just add a new step (I could easily have missed something here).

@onur-ozkan
Copy link
Member

I think the right pattern should be having a specific build step in tool module (so we can also build it with x build), then ensure that in the test step.

@tgross35
Copy link
Contributor Author

Alright, it ideally would also have a x run but that isn't implemented. I don't want to touch that PR now since it's pretty large and already in the queue, but I'll send a follow up after it merges and r? you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

No branches or pull requests

3 participants