-
Notifications
You must be signed in to change notification settings - Fork 14k
Implement -Z allow-partial-mitigations (RFC 3855)
#149357
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
base: main
Are you sure you want to change the base?
Conversation
|
These commits modify compiler targets. |
This comment has been minimized.
This comment has been minimized.
b34534b to
1fefdbe
Compare
compiler/rustc_metadata/messages.ftl
Outdated
| metadata_mitigation_less_strict_in_dependency = | ||
| your program uses the crate `{$extern_crate}`, that is not protected by `{$mitigation_name}{$mitigation_level}` | ||
| .note = Recompile that crate with the mitigation enabled, or use `-Z allow-partial-mitigations={$mitigation_name}` to allow creating an artifact that has the mitigation only partially enabled |
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.
Diagnostics must always start with a lowercase letter.
| .note = Recompile that crate with the mitigation enabled, or use `-Z allow-partial-mitigations={$mitigation_name}` to allow creating an artifact that has the mitigation only partially enabled | |
| .note = recompile that `{$extern_crate}` with the mitigation enabled, or use `-Z allow-partial-mitigations={$mitigation_name}` to allow creating an artifact that has the mitigation only partially enabled |
compiler/rustc_metadata/messages.ftl
Outdated
| metadata_mitigation_less_strict_in_dependency = | ||
| your program uses the crate `{$extern_crate}`, that is not protected by `{$mitigation_name}{$mitigation_level}` | ||
| .note = Recompile that crate with the mitigation enabled, or use `-Z allow-partial-mitigations={$mitigation_name}` to allow creating an artifact that has the mitigation only partially enabled | ||
| .help = It is possible to disable `-Z allow-partial-mitigations={$mitigation_name}` via `-Z allow-partial-mitigations=!{$mitigation_name}` |
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.
| .help = It is possible to disable `-Z allow-partial-mitigations={$mitigation_name}` via `-Z allow-partial-mitigations=!{$mitigation_name}` | |
| .help = it is possible to disable `-Z allow-partial-mitigations={$mitigation_name}` via `-Z allow-partial-mitigations=!{$mitigation_name}` |
I don't think we currently have any command line arguments who is edition depended, that would be a first. |
The behavior for I do think we want to eventually make |
| Some(s) => { | ||
| for sub in s.split(',') { | ||
| let (sub, enabled) = | ||
| if sub.starts_with('!') { (&sub[1..], false) } else { (sub, true) }; |
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.
Using ! for negation on the command-line is non-standard. It might also cause shell command parsing issues, because ! is a history search and insert metacharacter in some common shells.
The standard CLI negation prefix is no-, I suggest we use that instead.
The dev guide says to avoid no- for boolean flags, but I don't think that applies to more complex options:
rust/src/doc/rustc-dev-guide/src/cli.md
Lines 15 to 16 in 1be6b13
| - Avoid flags with the `no-` prefix. Instead, use the [`parse_bool`] function, | |
| such as `-C embed-bitcode=no`. |
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 basically put ! as a placeholder. Let's wait with it for a little bit of time until we figure out what to do.
c72b434 to
2f2a134
Compare
This implements `-Z allow-partial-mitigations` as an unstable option, currently with support for control-flow-guard and stack-protector. As a difference from the RFC, we have `-Z allow-partial-mitigations=!foo` rather than `-Z deny-partial-mitigations=foo`, since I couldn't find an easy way to have an allow/deny pair of flags where the latter flag wins. To allow for stabilization, this is only enabled starting from the next edition. Maybe a better policy is possible (bikeshed).
2f2a134 to
99913dd
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
This implements
-Z allow-partial-mitigationsas an unstable option, currently with support for control-flow-guard and stack-protector.As a difference from the RFC, we have
-Z allow-partial-mitigations=!foorather than-Z deny-partial-mitigations=foo, since I couldn't find an easy way to have an allow/deny pair of flags where the latter flag wins.To allow for stabilization, this is only enabled starting from the next edition. Maybe a better policy is possible (bikeshed).
r? @rcvalle