Skip to content

Conversation

@bjorn3
Copy link
Member

@bjorn3 bjorn3 commented Jan 12, 2026

This flag tells the codegen backend to immediately execute the code it builds. This is exactly what miri needs as it is unable to produce real executables. Adding a builtin flag would allow cargo to add native support for this without miri needing to do a bunch of hacks in its cargo wrapper. Furthermore cg_clif also has a jit mode that benefits from it.

This flag tells the codegen backend to immediately execute the code it
builds. This is exactly what miri needs as it is unable to produce real
executables. Adding a builtin flag would allow cargo to add native
support for this without miri needing to do a bunch of hacks in its
cargo wrapper. Furthermore cg_clif also has a jit mode that benefits
from it.
If cargo gets native support for -Zjit-mode, this should allow
simplifying cargo-miri a fair bit.
@rustbot
Copy link
Collaborator

rustbot commented Jan 12, 2026

The Miri subtree was changed

cc @rust-lang/miri

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 12, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 12, 2026

r? @lcnr

rustbot has assigned @lcnr.
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

@Urgau
Copy link
Member

Urgau commented Jan 12, 2026

This is kind-of a nit, but the naming of the flag implies to me that we generate a binary that calls back rustc at runtime to generate the machine code where necessary. What about -Zrun instead? or -Zexecute?

@rust-log-analyzer

This comment has been minimized.

@bjorn3
Copy link
Member Author

bjorn3 commented Jan 12, 2026

What about -Zrun instead? or -Zexecute?

I like those names. I don't have much of a preference which of the two to use.

@JayanAXHF JayanAXHF added A-codegen Area: Code generation A-CLI Area: Command-line interface (CLI) to the compiler labels Jan 12, 2026
}
}
config.program.args.push("-Zui-testing".into());
config.program.args.push("-Zjit-mode".into());
Copy link
Member

Choose a reason for hiding this comment

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

The code for ./miri run in miri-script/src/commands.rs likely also needs to set this new flag.

@RalfJung
Copy link
Member

This seems MCP-worthy.

Also, how do you imagine this to work from cargo? Cargo currently treats output from rustc and the program very different: rustc produces JSON output that is fully consumed by cargo, cached, and then rendered to the terminal. The program just gets direct access to the terminal.

@bjorn3
Copy link
Member Author

bjorn3 commented Jan 18, 2026

Cargo currently treats output from rustc and the program very different: rustc produces JSON output that is fully consumed by cargo, cached, and then rendered to the terminal. The program just gets direct access to the terminal.

Cargo currently does forward all lines output on stdout which don't start with a } to the terminal unchanged. A more principled way would be for rustc to emit a message indicating that jit execution starts. Though that would require miri to somehow change the diagnostic emitter to disable json output and force colors at that point.

@RalfJung
Copy link
Member

RalfJung commented Jan 18, 2026

Cargo currently does forward all lines output on stdout which don't start with a }

I assume you mean {.

That said, last time I checked (which was many years ago), it did so in a buffered way, making it unsuitable for Miri (we need to be able to emit partial lines). Also, it's not acceptable for output from the program Miri interprets to be swallowed just because it looks like JSON.

@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 23, 2026

☔ The latest upstream changes (presumably #151533) made this pull request unmergeable. Please resolve the merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CLI Area: Command-line interface (CLI) to the compiler A-codegen Area: Code generation S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants