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

Closed
tgross35 opened this issue Jul 20, 2024 · 11 comments
Assignees
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

tgross35 commented Jul 20, 2024

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.

@lucarlig
Copy link
Contributor

@tgross35 still working on this?

@tgross35
Copy link
Contributor Author

I guess this slipped my mind. All yours @lucarlig if you are interested, just comment @rustbot claim and it will assign you.

@lucarlig
Copy link
Contributor

will try it out,
@rustbot claim

@jieyouxu
Copy link
Member

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.

The RunMakeSupport one looks wrong to me now in that that ensure on std shouldn't be there. At the time I implemented that, I had no idea what I was doing, I just copied whatever code was around it lol.

@lucarlig
Copy link
Contributor

lucarlig commented Oct 18, 2024

I think this issue is not needed @onur-ozkan based on #131855

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.

The RunMakeSupport one looks wrong to me now in that that ensure on std shouldn't be there. At the time I implemented that, I had no idea what I was doing, I just copied whatever code was around it lol.

regarding this maybe is worth opening a new issue @jieyouxu ? Or can you explain exactly what I need to do, I can add it to the PR.
regarding TestFloatParse pr is there already #131731

@jieyouxu
Copy link
Member

jieyouxu commented Oct 18, 2024

For specific ones that might have special handling yes, otherwise I believe the tool builds already do the std handling. Those test steps seem to me like they have subtly different needs so I don't think they want to or can be trivially unified.

@jieyouxu
Copy link
Member

The RunMakeSupport one looks wrong to me now in that that ensure on std shouldn't be there. At the time I implemented that, I had no idea what I was doing, I just copied whatever code was around it lol.

Hm actually no, I read it again, the RunMakeSupport is a test step and has special handling, nevermind.

bors added a commit to rust-lang-ci/rust that referenced this issue Oct 19, 2024
add `TestFloatParse` to `tools.rs` for bootstrap

add TestFloatParse to tools for bootstrap, I am not sure this is what the issue rust-lang#128012 discussion wants.

try-job: aarch64-apple
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Oct 22, 2024
add `TestFloatParse` to `tools.rs` for bootstrap

add TestFloatParse to tools for bootstrap, I am not sure this is what the issue rust-lang#128012 discussion wants.

try-job: aarch64-apple
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Oct 22, 2024
Rollup merge of rust-lang#131731 - lucarlig:master, r=onur-ozkan

add `TestFloatParse` to `tools.rs` for bootstrap

add TestFloatParse to tools for bootstrap, I am not sure this is what the issue rust-lang#128012 discussion wants.

try-job: aarch64-apple
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

5 participants