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

Consider exposing target_feature option in cargo CLI #14524

Open
Kixunil opened this issue Sep 9, 2024 · 4 comments
Open

Consider exposing target_feature option in cargo CLI #14524

Kixunil opened this issue Sep 9, 2024 · 4 comments
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

Comments

@Kixunil
Copy link

Kixunil commented Sep 9, 2024

Problem

When testing with miri one often has to enable target features (all SIMD features) to be sure to test SIMD instructions which tend to contain unsafe code. This requires target_feature to be set in both RUSTFLAGS and RUSTDOCFLAGS. Not only is this annoying but also a footgun. From my understanding miri just passes the arguments along so it's a cargo issue.

Proposed Solution

Consider adding an argument that can set the target features as needed. Even better, also have an argument that enables all SIMD features.

Alternatively it could be decided that this is too niche and should be handled by miri and that may be the only tool that currently needs it, in which case I'll be happy to open an issue there.

Notes

I've opened this as requested in #12739 (comment)

@Kixunil Kixunil added C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage. labels Sep 9, 2024
@epage
Copy link
Contributor

epage commented Sep 9, 2024

Is this request specifically for cargo miri? If so, thats actually an external plugin and we'll want to move this issue to the appropriate repo.

@epage epage added S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request. and removed S-triage Status: This issue is waiting on initial triage. labels Sep 9, 2024
@Kixunil
Copy link
Author

Kixunil commented Sep 9, 2024

Hard to say, miri just passes the arguments and maybe this is useful for someone else (compiling to a different CPU?) but I specifically need it for miri only.

@epage
Copy link
Contributor

epage commented Sep 9, 2024

Keeping it here for now in case we want this on other commands and so we'd want consistency.

You mention CLI. For myself, I'm trying to be particular about what we add to the CLI. The CLI is front and center. As we add new flags, we make it harder to discover the flags that are already there. This means that adding a new flag, while having value for someone, can reduce the value gained by every other CLI flag for everyone. This is a phenomenon I've seen in clap where people ask for "new" features that exist or talk about things being impossible that are built-in. The cost of adding to the CLI is also discussed in #6100 (comment)

For the use case given, I wonder if this is justified.

This seems context dependent, like a profile, but machine specific, like the target table. We don't currently have config that encompasses both.

Another approach is we do put this in the CLI but in a generic flag, like rustc -C target-feature=val.

@epage epage added S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted. and removed S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request. labels Sep 9, 2024
@Kixunil
Copy link
Author

Kixunil commented Sep 9, 2024

Interesting, I can understand that at minimum the --help table gets noisy. I guess the main problems for me are:

  • Consistency between RUSTFLAGS and RUSTDOCFLAGS
  • Being able to set commonly-used flags in automated way (though I guess this is really miri-specific)

If the generic flag resolves the first problem, then it's already a win.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.
Projects
None yet
Development

No branches or pull requests

2 participants