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

Some way to pass Miri flags without MIRIFLAGS? #2051

Open
RalfJung opened this issue Apr 6, 2022 · 12 comments
Open

Some way to pass Miri flags without MIRIFLAGS? #2051

RalfJung opened this issue Apr 6, 2022 · 12 comments
Labels
A-cargo Area: affects the cargo wrapper (cargo miri) C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement E-good-first-issue A good way to start contributing, mentoring is available

Comments

@RalfJung
Copy link
Member

RalfJung commented Apr 6, 2022

@Gankra points out that the recommended way to pass flags to Miri -- MIRIFLAGS=-Zmiri-strict-provenance cargo miri test -- does not work on Windows. Also I have to admit this style of flag passing is somewhat verbose.

Is there a way we can pass flags via the CLI while also still being compatible with all cargo test invocations? One suggestion is to "grab" all flags starting with -Zmiri before cargo even sees then, and populate MIRIFLAGS with that. This could break in some corner cases (like when a feature is called -Zmiri-me and someone calls cargo miri test --feature -Zmiri-me), but that seems very unlikely. This does also assume cargo will never have a -Z flag starting with miri, which sounds like a reasonable assumption. Then we could do cargo miri test -Zmiri-strict-provenance, which works on Windows and looks nicer even on non-Windows.

@RalfJung RalfJung added C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement A-cargo Area: affects the cargo wrapper (cargo miri) labels Apr 6, 2022
@RalfJung RalfJung changed the title Some way to pass Miri flags withiut MIRIFLAGS? Some way to pass Miri flags without MIRIFLAGS? Apr 6, 2022
@vexx32
Copy link

vexx32 commented Apr 6, 2022

Is there not a way to pass an additional parameter explicitly to cargo binaries when they're invoked? Or is it mainly just that we want Miri to be able to seamlessly pass args through to cargo test itself so we don't have to manually support them?

From a usability standpoint I think it might be slightly nicer to have an explicit --miri-flags parameter for cargo miri than (essentially) guessing which -Z flags the user is trying to pass to Miri vs other tools.

@RalfJung
Copy link
Member Author

RalfJung commented Apr 6, 2022

cargo miri test -- foo passes foo to the test binaries, i.e. the interpreted program, not the interpreter. So we cannot use that path.

From a usability standpoint I think it might be slightly nicer to have an explicit --miri-flags parameter for cargo miri than (essentially) guessing which -Z flags the user is trying to pass to Miri vs other tools.

That would make it cargo miri test --miri-flag -Zmiri-strict-provenance which is rather verbose. :/

@vexx32
Copy link

vexx32 commented Apr 6, 2022

It's entirely unambiguous and unlikely to cause any kind of collision, and it's about the same (+2-3 chars) as the current de facto of MIRIFLAGS=-Zmiri-strict-provenance cargo miri test, so I'm not sure there's much of a difference -- other than if we go that route it can be done the same way on all platforms. 🤷

@RalfJung
Copy link
Member Author

RalfJung commented Apr 6, 2022

I was comparing that with cargo miri test -Zmiri-strict-provenance.

@RalfJung RalfJung added the E-good-first-issue A good way to start contributing, mentoring is available label May 4, 2022
@V0ldek
Copy link
Contributor

V0ldek commented May 20, 2022

It would be best if this was supported by .cargo/config.toml. You can pass flags to rustc with build.rustflags, same for flags for docs with build.rustdocflags. Supporting build.miriflags would be very useful. Most of the time I want to run every miri invocation with -Zmiri-strict-provenance, so just setting it globally for the workspace would be ideal.

@RalfJung
Copy link
Member Author

Hm, that makes sense but I have even less of an idea for how to support that without reimplementing all the cargo flags logic.^^

@V0ldek
Copy link
Contributor

V0ldek commented May 20, 2022

After digging a bit I think it'd have to be a request for rust-lang/cargo itself 😕

@oli-obk
Copy link
Contributor

oli-obk commented May 21, 2022

We could have a .cargo/miri.toml that we process ourselves

@RalfJung
Copy link
Member Author

RalfJung commented Jun 8, 2022

Most of the time I want to run every miri invocation with -Zmiri-strict-provenance, so just setting it globally for the workspace would be ideal.

Could you open a separate issue for that? I think in this one I would like to track passing flags "ah-hoc" for a particular invocation.

@dtolnay
Copy link
Member

dtolnay commented Jul 8, 2022

Filed #2347 for .cargo/config.toml, since I want it as well for -Zmiri-disable-isolation.

@lolbinarycat
Copy link

one option would be the form cargo miri -Zmiri-whatever test, since arguments in that position are interpreted by miri itself, and not cargo (currently this is only used by --help)

@RalfJung
Copy link
Member Author

RalfJung commented Jun 16, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cargo Area: affects the cargo wrapper (cargo miri) C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement E-good-first-issue A good way to start contributing, mentoring is available
Projects
None yet
Development

No branches or pull requests

6 participants