-
Notifications
You must be signed in to change notification settings - Fork 349
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
Fetch miri flags from cargo config #2451
Conversation
Thanks for the PR! What does cargo do when RUSTFLAGS is set and there are also flags set via And yes this should also be documented. :) Tests could be a bit tricky, do you have ideas for that? |
Regarding Thinking of tests, as I understand we can simply test this by making a cargo project where |
Our tests for cargo-miri are in
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. :) I just have some minor nits.
@rustbot author |
☔ The latest upstream changes (presumably #2459) made this pull request unmergeable. Please resolve the merge conflicts. |
@rustbot review I also added alongside others one test for checking the priority between |
@rustbot author |
@@ -541,6 +541,27 @@ pub fn phase_runner(mut binary_args: impl Iterator<Item = String>, phase: Runner | |||
} | |||
} | |||
|
|||
fn get_miriflags() -> Option<Vec<String>> { | |||
// Fetch miri flags from cargo config. | |||
let mut cmd = cargo(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to do a bit more work here: the user might have passed --config ...
to cargo miri run
, which would be ignored this way. See get_cargo_metadata
for how to forward that. Also they might have set the manifest path, which even get_cargo_metadata
gets wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once #2474 lands there will be a function cargo_extra_flags
you can call to get all the flags you need.
However, you can only call that function in phase_cargo_miri
; the arguments are lost here in phase_runner
. So you'll need to do the flag handling there, and then put the results into an env var that is picked up again in phase_runner
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the "right" way to do that is to have a variable like CARGO_ENCODED_MIRIFLAGS. Then phase_cargo_miri can determine the flags (from either MIRIFLAGS or via the config -- or from CARGO_ENCODED_MIRIFLAGS if that is already set -- and then store the flags losslessly (without spaces causing trouble) into CARGO_ENCODED_MIRIFLAGS here phase_runner can retreive it.
If that's more work than what you signed up for, then storing it into MIRIFLAGS and not supporting spaces within arguments for now would also work.
@@ -90,6 +90,12 @@ def test_no_rebuild(name, cmd, env={}): | |||
fail("Something was being rebuilt when it should not be (or we got no output)"); | |||
|
|||
def test_cargo_miri_run(): | |||
# Try to remove cargo config to avoid unexpected settings | |||
try: | |||
os.remove('.cargo/config.toml') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized this seems to edit the same file as
Line 49 in aa53f3f
echo 'build.rustc-wrapper = "thisdoesnotexist"' > .cargo/config.toml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah, the path should be absolute here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not what I mean. It can be relative, the other paths in the python file are also relative.
What I mean is that removing that file removes testing the build.rustc-wrapper = "thisdoesnotexist"
configuration!
@avrong we haven't heard from you in a while; what is the status of this PR? |
@RalfJung sorry for a long delay. Will be looking at this again soon |
@avrong I'm going to close this due to inactivity, but feel free to pick it up again any time! |
i'll study the PR and initial issue on this |
Closes #2347
This PR introduces cargo config parsing, and in a current implementation uses
miri.flags
property if there is noMIRIFLAGS
env variable present. Maybe the best way to do that is to have some kind of merge of the parameters in both configs, sort of like cargo configs do it by themselves depending on location.I did not make other tests, nor changed the docs, would be happy to do that if it's better to have them :)
Didn't figure out yet how to make a independent test to check the handling of
.cargo/config.toml
flags.