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

Add a way to extract miri flags from --config, env and toml #3875

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

badumbatish
Copy link

@badumbatish badumbatish commented Sep 10, 2024

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 via flagsplit().

I'm not sure how to write the test to describe this precedence of (1) over (2). Advice would be helpful :)

@badumbatish
Copy link
Author

hmmm hahha ok maybe i should have retained "-Zmiri" instead of just miri. The latter makes file name and other things gets tangled in

@badumbatish
Copy link
Author

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?

@badumbatish
Copy link
Author

@rustbot ready

@rustbot rustbot added the S-waiting-on-review Status: Waiting for a review to complete label Sep 14, 2024
@badumbatish
Copy link
Author

heheh now i know how to ask for review

@RalfJung
Copy link
Member

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.

@@ -181,6 +181,8 @@ pub fn phase_cargo_miri(mut args: impl Iterator<Item = String>) {
let target_dir = get_target_dir(&metadata);
cmd.arg("--target-dir").arg(target_dir);

// eprintln!("Getting miri flags in phase_cargo_miri");
Copy link
Contributor

Choose a reason for hiding this comment

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

This commented eprintln might need to be removed.

But I am not the maintainer and this PR might be on a draft state, so this is just a reminder. :)

Copy link
Author

Choose a reason for hiding this comment

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

haha yes I'll remove it on the next iteration :) ty for the review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Waiting for a review to complete
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Set MIRIFLAGS from .cargo/config.toml
5 participants