Skip to content

minor improvements on running miri #140898

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

Merged
merged 2 commits into from
May 26, 2025
Merged

minor improvements on running miri #140898

merged 2 commits into from
May 26, 2025

Conversation

onur-ozkan
Copy link
Member

It should be clear from the commit messages when reviewing them one by one.

@rustbot
Copy link
Collaborator

rustbot commented May 10, 2025

r? @clubby789

rustbot has assigned @clubby789.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels May 10, 2025
@onur-ozkan
Copy link
Member Author

onur-ozkan commented May 10, 2025

I assume Ralf uses this API a lot, it's worth pinging him to make sure he will be aware of this change (especially the second commit as the first one doesn't affect anything on the user side).

cc @RalfJung

@RalfJung
Copy link
Member

I have no idea what the first commit does from a user perspective. The second commit looks good, except for the comment I added. :)

@clubby789
Copy link
Contributor

Yes second commit also lgtm but I'm not sure of what the first is doing 😅

@onur-ozkan
Copy link
Member Author

Yes second commit also lgtm but I'm not sure of what the first is doing 😅

Sure. r? bootstrap

@rustbot rustbot assigned Kobzol and unassigned clubby789 May 12, 2025
// This compiler runs on the host, we'll just use it for the target.
let target_compiler = builder.compiler(stage, host);
let host_compiler = tool::get_tool_rustc_compiler(builder, target_compiler);
let compiler = builder.compiler(stage, target);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test implementation for Miri uses (stage, host) here. Shouldn't it be unified with this change?

Also, could you please explain what this change does? And add a comment to the code to make it easier to understand in the future.

I tried this with ./x run miri --stage 1 --dry-run --host x86_64-unknown-linux-none.

  • On master, the build compiler for miri is stage0/-gnu, while the target compiler is stage1/-gnu.
  • With this PR, the build compiler for miri is stage 0/-gnu, while the target compiler is stage1/-none.

So it seems like this changes behavior.

Copy link
Member Author

@onur-ozkan onur-ozkan May 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test implementation for Miri uses (stage, host) here. Shouldn't it be unified with this change?

It's not really specific to Miri, this approach is used in other Rustc tools as well. It's fairly straightforward and I am not sure creating another function would make it any simpler.

Also, could you please explain what this change does? And add a comment to the code to make it easier to understand in the future.

I tried (17d27c9) to make it less complicated. Let me know if it's simpler to understand now.

I tried this with ./x run miri --stage 1 --dry-run --host x86_64-unknown-linux-none.

  • On master, the build compiler for miri is stage0/-gnu, while the target compiler is stage1/-gnu.
  • With this PR, the build compiler for miri is stage 0/-gnu, while the target compiler is stage1/-none.

So it seems like this changes behavior.

You can use this patch and see that compilers are still the same:

diff --git a/src/bootstrap/src/core/build_steps/run.rs b/src/bootstrap/src/core/build_steps/run.rs
index 6cf88278d79..81d6218ccaa 100644
--- a/src/bootstrap/src/core/build_steps/run.rs
+++ b/src/bootstrap/src/core/build_steps/run.rs
@@ -133,8 +133,12 @@ fn run(self, builder: &Builder<'_>) {
         }

         let compiler = builder.compiler(stage, target);
+        let host_compiler = tool::get_tool_rustc_compiler(builder, compiler);
         let miri_build = builder.ensure(tool::Miri { compiler, target });

+        assert_eq!(miri_build.target_compiler, compiler);
+        assert_eq!(miri_build.build_compiler, host_compiler);
+
         // Get a target sysroot for Miri.
         let miri_sysroot =
             test::Miri::build_miri_sysroot(builder, miri_build.target_compiler, target);

It's just the stage shifting logic is now fully controlled by tool::Miri. There may be some additional logic handled within tool::Miri (which are mostly good to have), but the overall outcome should remain the same.

@Kobzol
Copy link
Contributor

Kobzol commented May 26, 2025

@bors r+

@bors
Copy link
Collaborator

bors commented May 26, 2025

📌 Commit 17d27c9 has been approved by Kobzol

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 26, 2025
bors added a commit that referenced this pull request May 26, 2025
Rollup of 10 pull requests

Successful merges:

 - #140898 (minor improvements on running miri)
 - #141392 (Avoid obligation construction dance with query region constraints)
 - #141431 (Emit dummy open drop for unsafe binder)
 - #141433 (Properly analyze captures from unsafe binders)
 - #141439 (Deduplicate dyn compatibility violations due to coercion)
 - #141449 (further deduplicate ast visitor code)
 - #141513 (interpret: add allocation parameters to `AllocBytes`)
 - #141516 (speed up charsearcher for ascii chars)
 - #141526 (add a dedicated section for compiler environment variables in the unstable book)
 - #141550 (Fix `unused_braces` lint suggestion when encountering attributes)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 0912d1f into rust-lang:master May 26, 2025
6 checks passed
@rustbot rustbot added this to the 1.89.0 milestone May 26, 2025
rust-timer added a commit that referenced this pull request May 26, 2025
Rollup merge of #140898 - onur-ozkan:miri-run, r=Kobzol

minor improvements on running miri

It should be clear from the commit messages when reviewing them one by one.
@onur-ozkan onur-ozkan deleted the miri-run branch May 27, 2025 03:53
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request May 27, 2025
Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#140898 (minor improvements on running miri)
 - rust-lang/rust#141392 (Avoid obligation construction dance with query region constraints)
 - rust-lang/rust#141431 (Emit dummy open drop for unsafe binder)
 - rust-lang/rust#141433 (Properly analyze captures from unsafe binders)
 - rust-lang/rust#141439 (Deduplicate dyn compatibility violations due to coercion)
 - rust-lang/rust#141449 (further deduplicate ast visitor code)
 - rust-lang/rust#141513 (interpret: add allocation parameters to `AllocBytes`)
 - rust-lang/rust#141516 (speed up charsearcher for ascii chars)
 - rust-lang/rust#141526 (add a dedicated section for compiler environment variables in the unstable book)
 - rust-lang/rust#141550 (Fix `unused_braces` lint suggestion when encountering attributes)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants