miri
miri copied to clipboard
Some way to pass Miri flags without MIRIFLAGS?
@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.
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.
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. :/
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. 🤷
I was comparing that with cargo miri test -Zmiri-strict-provenance.
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.
Hm, that makes sense but I have even less of an idea for how to support that without reimplementing all the cargo flags logic.^^
After digging a bit I think it'd have to be a request for rust-lang/cargo itself :confused:
We could have a .cargo/miri.toml that we process ourselves
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.
Filed #2347 for .cargo/config.toml, since I want it as well for -Zmiri-disable-isolation.
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)
We now also have "--many-seeds", which is passed after "test".