-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Target modifiers (special marked options) are recorded in metainfo #133138
base: master
Are you sure you want to change the base?
Conversation
r? @davidtwco rustbot has assigned @davidtwco. Use |
This comment has been minimized.
This comment has been minimized.
d99ff62
to
bd52a23
Compare
This comment has been minimized.
This comment has been minimized.
bd52a23
to
500600b
Compare
This comment has been minimized.
This comment has been minimized.
db91299
to
43e5956
Compare
This comment has been minimized.
This comment has been minimized.
43e5956
to
6793451
Compare
95f9595
to
9cd86c3
Compare
@rustbot ready |
9cd86c3
to
97a8240
Compare
This comment has been minimized.
This comment has been minimized.
97a8240
to
8603b2b
Compare
8603b2b
to
95ffdf8
Compare
This comment was marked as resolved.
This comment was marked as resolved.
@davidtwco btw, could you slightly elaborate on what you mean by this? As in, do you want feedback from another reviewer for an aspect of this change in particular, or this PR as a whole (like a second pair of eyes on it)? |
a084519
to
682d57f
Compare
This comment has been minimized.
This comment has been minimized.
The latter, just to make sure someone else agrees it's going in the right direction |
682d57f
to
07d1c0a
Compare
This comment has been minimized.
This comment has been minimized.
07d1c0a
to
5d168f2
Compare
This comment has been minimized.
This comment has been minimized.
} | ||
|
||
/// A recorded -Zopt_name=opt_value (or -Copt_name=opt_value) | ||
/// for ABI-changing or vulnerability-affecting options. |
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.
/// for ABI-changing or vulnerability-affecting options. | |
/// which alter the ABI or effectiveness of exploit mitigations. |
I don't think "vulnerability-affecting" is a good term for this. The usual term is "exploit mitigation".
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.
Fixed.
@@ -296,6 +300,83 @@ impl CStore { | |||
} | |||
} | |||
|
|||
pub fn report_incompatible_target_modifiers(&self, tcx: TyCtxt<'_>, krate: &Crate) { |
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 expected this function to just be something like
if !tcx.target_modifiers(LOCAL_CRATE) != tcx.target_modifiers(krate) {
tcx.emit_err(...
}
but instead, it's way more complicated. Why? What is it doing? It sort of looks like it's trying to come up with a good diagnostic, but I can't even tell if it does the equality check right. So if this is all just in the name of a good diagnostic, can you clearly separate the equality check from the diagnostic reporting? The failure case and this function as a whole is cold, there's no need to avoid looping over flags many times or something like that.
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.
Yes, it is for good diagnostic.
I have added such a code for clarity:
if mods != *data.target_modifiers() {
Self::report_target_modifiers_extended(tcx, krate, &mods, data);
}
Also, unsafe_allow_abi_mismatch
need to be taken into account to skip allowed mismatches.
-Cunsafe-allow-abi-mismatch=regparm,reg-struct-return
.
5d168f2
to
18e4b9f
Compare
@rustbot review |
18e4b9f
to
8e2f3d7
Compare
…d compared to be equal in different crates
8e2f3d7
to
2a544ab
Compare
Thanks! Sorry this PR spent a long time in review. We're still polishing the whole goals process, which should hopefully speed up review for goal-related PRs like this one. @bors r=davidtwco,saethlin |
…r=davidtwco,saethlin Target modifiers (special marked options) are recorded in metainfo Target modifiers (special marked options) are recorded in metainfo and compared to be equal in different linked crates. PR for this RFC: rust-lang/rfcs#3716 Option may be marked as `TARGET_MODIFIER`, example: `regparm: Option<u32> = (None, parse_opt_number, [TRACKED TARGET_MODIFIER]`. If an TARGET_MODIFIER-marked option has non-default value, it will be recorded in crate metainfo as a `Vec<TargetModifier>`: ``` pub struct TargetModifier { pub opt: OptionsTargetModifiers, pub value_name: String, } ``` OptionsTargetModifiers is a macro-generated enum. Option value code (for comparison) is generated using `Debug` trait. Error example: ``` error: mixing `-Zregparm` will cause an ABI mismatch in crate `incompatible_regparm` --> $DIR/incompatible_regparm.rs:10:1 | LL | #![crate_type = "lib"] | ^ | = help: the `-Zregparm` flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely = note: `-Zregparm=1` in this crate is incompatible with `-Zregparm=2` in dependency `wrong_regparm` = help: set `-Zregparm=2` in this crate or `-Zregparm=1` in `wrong_regparm` = help: if you are sure this will not cause problems, use `-Cunsafe-allow-abi-mismatch=regparm` to silence this error error: aborting due to 1 previous error ``` `-Cunsafe-allow-abi-mismatch=regparm,reg-struct-return` to disable list of flags.
Rollup of 9 pull requests Successful merges: - rust-lang#133138 (Target modifiers (special marked options) are recorded in metainfo) - rust-lang#133154 (Reword resolve errors caused by likely missing crate in dep tree) - rust-lang#135366 (Enable `unreachable_pub` lint in `test` and `proc_macro` crates) - rust-lang#135638 (Make it possible to build GCC on CI) - rust-lang#135648 (support wasm inline assembly in `naked_asm!`) - rust-lang#135827 (CI: free disk with in-tree script instead of GitHub Action) - rust-lang#135855 (Only assert the `Parser` size on specific arches) - rust-lang#135878 (ci: use 8 core arm runner for dist-aarch64-linux) - rust-lang#135905 (Enable kernel sanitizers for aarch64-unknown-none-softfloat) r? `@ghost` `@rustbot` modify labels: rollup
Target modifiers (special marked options) are recorded in metainfo and compared to be equal in different linked crates.
PR for this RFC: rust-lang/rfcs#3716
Option may be marked as
TARGET_MODIFIER
, example:regparm: Option<u32> = (None, parse_opt_number, [TRACKED TARGET_MODIFIER]
.If an TARGET_MODIFIER-marked option has non-default value, it will be recorded in crate metainfo as a
Vec<TargetModifier>
:OptionsTargetModifiers is a macro-generated enum.
Option value code (for comparison) is generated using
Debug
trait.Error example:
-Cunsafe-allow-abi-mismatch=regparm,reg-struct-return
to disable list of flags.