Skip to content

Allow building Miri with --features from miri-script #4396

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

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

Conversation

Stypox
Copy link
Contributor

@Stypox Stypox commented Jun 12, 2025

I added the --features flag to all Commands for which cargo can accept --features, i.e. install, build, check, test, run, doc. Those who can't accept --features are clippy, fmt, toolchain, rustc pull, rustc push, squash (the last 4 are not even cargo commands). Furthermore, I did not add it to the Bench command since that command doesn't take any "--flags" either.

This PR is needed because there is no way to pass e.g. --features tracing just to the cargo commands issued on the root repository. Unfortunately CARGO_EXTRA_FLAGS applies the flags to the "cargo-miri" crate, too, which does not make sense for crate-specific features.

This PR also includes a small commit to make the interface of install_to_sysroot clearer.

Note: this PR is the counterpart to rust-lang/rust#142379, which is for when Miri is built in the rustc repo.

Copy link
Member

@RalfJung RalfJung left a comment

Choose a reason for hiding this comment

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

Thanks! Overall, I am on board. I left some comments.

I'd prefer if we didn't have to pass this around everywhere, it seems easy to mix up the feature lists. But that seems like a larger refactor... so not for this PR.

Stypox added 3 commits June 13, 2025 23:32
Otherwise there was no way to pass e.g. `--features tracing` just to the `cargo` commands issued on the root repository:
CARGO_EXTRA_FLAGS applies the flags to the "cargo-miri" crate, too, which does not make sense for crate-specific features.
Since the second concatenation was against an absolute path, it didn't do anything.

This also makes the interface of install_to_sysroot() similar to that of cargo_cmd()
Also fix not passing features to one of the cargo invocations for test
@Stypox Stypox force-pushed the build-with-features branch from 6eba306 to 967a531 Compare June 13, 2025 21:48
Copy link
Contributor Author

@Stypox Stypox left a comment

Choose a reason for hiding this comment

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

Thanks for the review! I force pushed to remove the unrelated file (I made the commit a few weeks ago and cherry picked it a few times, and that file was committed accidentally at some point, sorry for not noticing). I also pushed a commit to add --features to clippy and to auto_actions and to fix the order of features and flags.

| Command::Run { features, .. }
| Command::Doc { features, .. }
| Command::Clippy { features, .. } => Self::auto_actions(features.clone())?,
| Command::Fmt { .. } => Self::auto_actions(vec![])?,
Copy link
Contributor Author

@Stypox Stypox Jun 13, 2025

Choose a reason for hiding this comment

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

Fmt does not have features, however the features might be needed for some auto action. Should I add features to Fmt too, and expand its doc to explain how it's not actually used for Fmt but rather for auto actions?

Copy link
Member

Choose a reason for hiding this comment

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

Adding this to fmt just for auto-clippy doesn't make sense IMO. I don't think auto-clippy should enable any features... but I don't use auto-clippy anyway. @oli-obk what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

auto-clippy should be indistinguishable from ./miri clippy, so no features, yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants