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

Set MIRIFLAGS from .cargo/config.toml #2347

Open
dtolnay opened this issue Jul 8, 2022 · 4 comments · May be fixed by #3875
Open

Set MIRIFLAGS from .cargo/config.toml #2347

dtolnay opened this issue Jul 8, 2022 · 4 comments · May be fixed by #3875
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

@dtolnay
Copy link
Member

dtolnay commented Jul 8, 2022

You can pass flags to rustc with build.rustflags, and to rustdoc with build.rustdocflags.

[build]
rustflags = ["-C", "target-cpu=native"]

Supporting MIRIFLAGS the same way would be nice. Most of the time I want to run every miri invocation for a project with a particular flag like -Zmiri-disable-isolation, so just setting it globally for the workspace would be ideal.

[miri]
miriflags = ["-Zmiri-disable-isolation"]

Related issue for MIRIFLAGS as command line arguments: #2051

@RalfJung
Copy link
Member

RalfJung commented Jul 8, 2022

Ah yes that makes a lot of sense. Two notes:

  • I have no idea how to do that without re-implementing all the logic from cargo, which I'd rather not maintain in our codebase. (It looks up a bunch of files, right?) Can we ask cargo nicely to tell us the value of some option, rather than having to look it up ourselves?
  • We probably then also want negated versions of all our flags so you can overwrite your locally adjusted defaults. Like, if you set -Zmiri-disable-isolation, but then want to run with isolation one time to make sure it is deterministic, currently there's no way to do that. So maybe it should be -Zmiri-isolation=true/false instead?

@dtolnay
Copy link
Member Author

dtolnay commented Jul 8, 2022

It's already exposed by Cargo:

$ cargo -Zunstable-options config get miri.flags --format=json-value
["-Zmiri-disable-isolation"]

It handles the usual cascading/merging of whatever files Cargo normally looks in ($WORKSPACE/.cargo/config, $WORKSPACE/.cargo/config.toml, ~/.cargo/config, ~/.cargo/config.toml, etc(?)).

Tracking issue rust-lang/cargo#9301 but I assume you don't require this to be stable given you're pinned to nightly anyway.

@RalfJung
Copy link
Member

RalfJung commented Jul 9, 2022

Wow, that's cool!

@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 Jul 12, 2022
@RalfJung RalfJung added the E-good-first-issue A good way to start contributing, mentoring is available label Jul 19, 2022
@RalfJung
Copy link
Member

#2451 contains a draft implementation of this feature, but needs a bit of work to be finished -- see the PR comments for details.

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
2 participants