Add a way to extract miri flags from --config, env and toml
Fixes #2347.
The main driver is get_miri_flags in cargo-miri/src/util.rs, which follow this stratergy:
// Strategy: (1) check pseudo var CARGO_ENCODED_MIRIFLAGS first (this is only set after we check for --config
// in the cargo_dash_dash in the if else)
//
// if CARGO_ENCODED_MIRIFLAGS doesn't exist, we check in --config (2)
// if --config doesn't exist, we check offical env var MIRIFLAGS (3)
//
// if MIRIFLAGS is non-existent, we then check for toml (4)
This is called once in phase_cargo_miri, then again in phase_runner.
For --config, I only retains all String that contains "miri", and then join them via " " for env. This is because flagsplit splits based on the space character. Please let me know if this is not the procedure.
In later stage this env is resolved into Vec<String> via flagsplit().
I'm not sure how to write the test to describe this precedence of (1) over (2). Advice would be helpful :)
hmmm hahha ok maybe i should have retained "-Zmiri" instead of just miri. The latter makes file name and other things gets tangled in
after debugging i found out that in phase_cargo_miri if i try to extract MIRIFLAGS (a.k.a choice (3)) from env then some of the program will fail like this
FAILED TEST: tests/pass-dep/num_cpus.rs
command: "Dependencies"
full stderr:
0: [91mfailed to compile dependencies:
command: env -u RUSTFLAGS "/home/jjasmine/Developer/github/miri/target/debug/cargo-miri" "miri" "run" "--target-dir" "/home/jjasmine/Developer/github/miri/target/miri_ui" "--manifest-path" "test_dependencies/Cargo.toml" "--target=x86_64-unknown-linux-gnu" "--locked" "--message-format=json"
stderr:
Getting miri flags in phase_cargo_miri
Choice 3
-Zmiri-provenance-gc=1
error: unknown `-Z` flag specified: miri-provenance-gc
For available unstable features, see https://doc.rust-lang.org/nightly/cargo/reference/unstable.html
If you intended to use an unstable rustc feature, try setting `RUSTFLAGS="-Zmiri-provenance-gc"`
stdout:[0m
but if i seperate them into so that in phase_cargo_miri I only perform choice (1) and (2) and then in phase_runner the rest then the ui test passes fine. I think I'm missing sth important?
@rustbot ready
heheh now i know how to ask for review
Yeah I've seen the PR. :) Thanks for creating it!
It's quite busy in my life currently though, so I can't promise when I will get around to take a look at this.
@rustbot author
Apologies for the delay. I'm jampacked with classes, exams and projects right now. I'll get back to it soon. Really sorry for this
Thanks for the update, and no worries. :)
:umbrella: The latest upstream changes (possibly 887b4984e2ec4690afb6aa2c3f31408b570033ca) made this pull request unmergeable. Please resolve the merge conflicts.
@badumbatish I'll close this for now due to inactivity. Feel free to reopen the PR if you want to get back to this. :)
Note: do not push to the branch while the PR is closed. Github will only let you reopen the PR if the branch is exactly in the current state (commit 914bda3d31fa1cc39ef809dff639e46fe1001ed8).
Sounds good! Sorry for your inconvience ~~