Skip to content

Commit 2fabf16

Browse files
author
Ariel Ben-Yehuda
committed
use -Z deny-partial-mitigations=foo instead of -Z allow-partial-mitigations=!foo
1 parent 15207af commit 2fabf16

7 files changed

Lines changed: 48 additions & 33 deletions

compiler/rustc_session/src/options.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,8 @@ mod desc {
888888
pub(crate) const parse_align: &str = "a number that is a power of 2 between 1 and 2^29";
889889
pub(crate) const parse_allow_partial_mitigations: &str =
890890
super::enforcable_mitigations::DeniedPartialMitigationsKind::KINDS;
891+
pub(crate) const parse_deny_partial_mitigations: &str =
892+
super::enforcable_mitigations::DeniedPartialMitigationsKind::KINDS;
891893
}
892894

893895
pub mod parse {
@@ -2091,14 +2093,14 @@ pub mod parse {
20912093
}
20922094
}
20932095

2094-
fn parse_allow_partial_mitigations(
2096+
pub(crate) fn parse_allow_partial_mitigations(
20952097
slot: &mut Vec<MitigationEnablement>,
20962098
v: Option<&str>,
20972099
) -> bool {
20982100
parse_partial_mitigations(slot, v, true)
20992101
}
21002102

2101-
fn parse_deny_partial_mitigations(
2103+
pub(crate) fn parse_deny_partial_mitigations(
21022104
slot: &mut Vec<MitigationEnablement>,
21032105
v: Option<&str>,
21042106
) -> bool {
@@ -2331,6 +2333,8 @@ options! {
23312333
"deduplicate identical diagnostics (default: yes)"),
23322334
default_visibility: Option<SymbolVisibility> = (None, parse_opt_symbol_visibility, [TRACKED],
23332335
"overrides the `default_visibility` setting of the target"),
2336+
deny_partial_mitigations: Vec<MitigationEnablement> = (Vec::new(), parse_deny_partial_mitigations, [UNTRACKED],
2337+
"Deny mitigations not enabled for all dependency crates (comma separated list)"),
23342338
dep_info_omit_d_target: bool = (false, parse_bool, [TRACKED],
23352339
"in dep-info output, omit targets for tracking dependencies of the dep-info files \
23362340
themselves (default: no)"),

tests/ui/allow-partial-mitigations/err-allow-partial-mitigations.both.stderr

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled
2-
--> $DIR/err-allow-partial-mitigations.rs:13:1
2+
--> $DIR/err-allow-partial-mitigations.rs:14:1
33
|
44
LL | fn main() {}
55
| ^
@@ -8,7 +8,7 @@ LL | fn main() {}
88
= note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation only partially enabled
99

1010
error: your program uses the crate `std`, that is not compiled with `control-flow-guard` enabled
11-
--> $DIR/err-allow-partial-mitigations.rs:13:1
11+
--> $DIR/err-allow-partial-mitigations.rs:14:1
1212
|
1313
LL | fn main() {}
1414
| ^
@@ -17,7 +17,7 @@ LL | fn main() {}
1717
= note: recompile `std` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation only partially enabled
1818

1919
error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled
20-
--> $DIR/err-allow-partial-mitigations.rs:13:1
20+
--> $DIR/err-allow-partial-mitigations.rs:14:1
2121
|
2222
LL | fn main() {}
2323
| ^
@@ -26,7 +26,7 @@ LL | fn main() {}
2626
= note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation only partially enabled
2727

2828
error: your program uses the crate `core`, that is not compiled with `control-flow-guard` enabled
29-
--> $DIR/err-allow-partial-mitigations.rs:13:1
29+
--> $DIR/err-allow-partial-mitigations.rs:14:1
3030
|
3131
LL | fn main() {}
3232
| ^
@@ -35,7 +35,7 @@ LL | fn main() {}
3535
= note: recompile `core` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation only partially enabled
3636

3737
error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled
38-
--> $DIR/err-allow-partial-mitigations.rs:13:1
38+
--> $DIR/err-allow-partial-mitigations.rs:14:1
3939
|
4040
LL | fn main() {}
4141
| ^
@@ -44,7 +44,7 @@ LL | fn main() {}
4444
= note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation only partially enabled
4545

4646
error: your program uses the crate `alloc`, that is not compiled with `control-flow-guard` enabled
47-
--> $DIR/err-allow-partial-mitigations.rs:13:1
47+
--> $DIR/err-allow-partial-mitigations.rs:14:1
4848
|
4949
LL | fn main() {}
5050
| ^
@@ -53,7 +53,7 @@ LL | fn main() {}
5353
= note: recompile `alloc` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation only partially enabled
5454

5555
error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled
56-
--> $DIR/err-allow-partial-mitigations.rs:13:1
56+
--> $DIR/err-allow-partial-mitigations.rs:14:1
5757
|
5858
LL | fn main() {}
5959
| ^
@@ -62,7 +62,7 @@ LL | fn main() {}
6262
= note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation only partially enabled
6363

6464
error: your program uses the crate `compiler_builtins`, that is not compiled with `control-flow-guard` enabled
65-
--> $DIR/err-allow-partial-mitigations.rs:13:1
65+
--> $DIR/err-allow-partial-mitigations.rs:14:1
6666
|
6767
LL | fn main() {}
6868
| ^
@@ -71,7 +71,7 @@ LL | fn main() {}
7171
= note: recompile `compiler_builtins` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation only partially enabled
7272

7373
error: your program uses the crate `libc`, that is not compiled with `stack-protector=all` enabled
74-
--> $DIR/err-allow-partial-mitigations.rs:13:1
74+
--> $DIR/err-allow-partial-mitigations.rs:14:1
7575
|
7676
LL | fn main() {}
7777
| ^
@@ -80,7 +80,7 @@ LL | fn main() {}
8080
= note: recompile `libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation only partially enabled
8181

8282
error: your program uses the crate `libc`, that is not compiled with `control-flow-guard` enabled
83-
--> $DIR/err-allow-partial-mitigations.rs:13:1
83+
--> $DIR/err-allow-partial-mitigations.rs:14:1
8484
|
8585
LL | fn main() {}
8686
| ^

tests/ui/allow-partial-mitigations/err-allow-partial-mitigations.disable.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled
2-
--> $DIR/err-allow-partial-mitigations.rs:13:1
2+
--> $DIR/err-allow-partial-mitigations.rs:14:1
33
|
44
LL | fn main() {}
55
| ^
@@ -8,7 +8,7 @@ LL | fn main() {}
88
= note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation only partially enabled
99

1010
error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled
11-
--> $DIR/err-allow-partial-mitigations.rs:13:1
11+
--> $DIR/err-allow-partial-mitigations.rs:14:1
1212
|
1313
LL | fn main() {}
1414
| ^
@@ -17,7 +17,7 @@ LL | fn main() {}
1717
= note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation only partially enabled
1818

1919
error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled
20-
--> $DIR/err-allow-partial-mitigations.rs:13:1
20+
--> $DIR/err-allow-partial-mitigations.rs:14:1
2121
|
2222
LL | fn main() {}
2323
| ^
@@ -26,7 +26,7 @@ LL | fn main() {}
2626
= note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation only partially enabled
2727

2828
error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled
29-
--> $DIR/err-allow-partial-mitigations.rs:13:1
29+
--> $DIR/err-allow-partial-mitigations.rs:14:1
3030
|
3131
LL | fn main() {}
3232
| ^
@@ -35,7 +35,7 @@ LL | fn main() {}
3535
= note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation only partially enabled
3636

3737
error: your program uses the crate `libc`, that is not compiled with `stack-protector=all` enabled
38-
--> $DIR/err-allow-partial-mitigations.rs:13:1
38+
--> $DIR/err-allow-partial-mitigations.rs:14:1
3939
|
4040
LL | fn main() {}
4141
| ^

tests/ui/allow-partial-mitigations/err-allow-partial-mitigations.enable-disable.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled
2-
--> $DIR/err-allow-partial-mitigations.rs:13:1
2+
--> $DIR/err-allow-partial-mitigations.rs:14:1
33
|
44
LL | fn main() {}
55
| ^
@@ -8,7 +8,7 @@ LL | fn main() {}
88
= note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation only partially enabled
99

1010
error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled
11-
--> $DIR/err-allow-partial-mitigations.rs:13:1
11+
--> $DIR/err-allow-partial-mitigations.rs:14:1
1212
|
1313
LL | fn main() {}
1414
| ^
@@ -17,7 +17,7 @@ LL | fn main() {}
1717
= note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation only partially enabled
1818

1919
error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled
20-
--> $DIR/err-allow-partial-mitigations.rs:13:1
20+
--> $DIR/err-allow-partial-mitigations.rs:14:1
2121
|
2222
LL | fn main() {}
2323
| ^
@@ -26,7 +26,7 @@ LL | fn main() {}
2626
= note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation only partially enabled
2727

2828
error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled
29-
--> $DIR/err-allow-partial-mitigations.rs:13:1
29+
--> $DIR/err-allow-partial-mitigations.rs:14:1
3030
|
3131
LL | fn main() {}
3232
| ^
@@ -35,7 +35,7 @@ LL | fn main() {}
3535
= note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation only partially enabled
3636

3737
error: your program uses the crate `libc`, that is not compiled with `stack-protector=all` enabled
38-
--> $DIR/err-allow-partial-mitigations.rs:13:1
38+
--> $DIR/err-allow-partial-mitigations.rs:14:1
3939
|
4040
LL | fn main() {}
4141
| ^

tests/ui/allow-partial-mitigations/err-allow-partial-mitigations.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// ignore-tidy-linelength
2-
//@ revisions: sp both disable enable-disable wrong-enable
2+
//@ revisions: sp both disable enable-disable wrong-enable enable-separately-disable-together
33
//@ check-fail
44
//@ ignore-nvptx64 stack protector is not supported
55
//@ ignore-wasm32-unknown-unknown stack protector is not supported
@@ -9,6 +9,7 @@
99
//@ [disable] compile-flags: -Z unstable-options -Z deny-partial-mitigations=stack-protector -Z stack-protector=all
1010
//@ [enable-disable] compile-flags: -Z unstable-options -Z allow-partial-mitigations=stack-protector -Z deny-partial-mitigations=stack-protector -Z stack-protector=all
1111
//@ [wrong-enable] compile-flags: -Z unstable-options -Z allow-partial-mitigations=control-flow-guard -Z stack-protector=all
12+
//@ [enable-separately-disable-together] compile-flags: -Z unstable-options -Z allow-partial-mitigations=stack-protector -Z allow-partial-mitigations=control-flow-guard -Z deny-partial-mitigations=control-flow-guard,stack-protector -C control-flow-guard=on -Z stack-protector=all
1213

1314
fn main() {}
1415
//[both]~^ ERROR that is not compiled with
@@ -41,3 +42,13 @@ fn main() {}
4142
//[wrong-enable]~| ERROR that is not compiled with
4243
//[wrong-enable]~| ERROR that is not compiled with
4344
//[wrong-enable]~| ERROR that is not compiled with
45+
//[enable-separately-disable-together]~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ERROR that is not compiled with
46+
//[enable-separately-disable-together]~| ERROR that is not compiled with
47+
//[enable-separately-disable-together]~| ERROR that is not compiled with
48+
//[enable-separately-disable-together]~| ERROR that is not compiled with
49+
//[enable-separately-disable-together]~| ERROR that is not compiled with
50+
//[enable-separately-disable-together]~| ERROR that is not compiled with
51+
//[enable-separately-disable-together]~| ERROR that is not compiled with
52+
//[enable-separately-disable-together]~| ERROR that is not compiled with
53+
//[enable-separately-disable-together]~| ERROR that is not compiled with
54+
//[enable-separately-disable-together]~| ERROR that is not compiled with

tests/ui/allow-partial-mitigations/err-allow-partial-mitigations.sp.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled
2-
--> $DIR/err-allow-partial-mitigations.rs:13:1
2+
--> $DIR/err-allow-partial-mitigations.rs:14:1
33
|
44
LL | fn main() {}
55
| ^
@@ -8,7 +8,7 @@ LL | fn main() {}
88
= note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation only partially enabled
99

1010
error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled
11-
--> $DIR/err-allow-partial-mitigations.rs:13:1
11+
--> $DIR/err-allow-partial-mitigations.rs:14:1
1212
|
1313
LL | fn main() {}
1414
| ^
@@ -17,7 +17,7 @@ LL | fn main() {}
1717
= note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation only partially enabled
1818

1919
error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled
20-
--> $DIR/err-allow-partial-mitigations.rs:13:1
20+
--> $DIR/err-allow-partial-mitigations.rs:14:1
2121
|
2222
LL | fn main() {}
2323
| ^
@@ -26,7 +26,7 @@ LL | fn main() {}
2626
= note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation only partially enabled
2727

2828
error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled
29-
--> $DIR/err-allow-partial-mitigations.rs:13:1
29+
--> $DIR/err-allow-partial-mitigations.rs:14:1
3030
|
3131
LL | fn main() {}
3232
| ^
@@ -35,7 +35,7 @@ LL | fn main() {}
3535
= note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation only partially enabled
3636

3737
error: your program uses the crate `libc`, that is not compiled with `stack-protector=all` enabled
38-
--> $DIR/err-allow-partial-mitigations.rs:13:1
38+
--> $DIR/err-allow-partial-mitigations.rs:14:1
3939
|
4040
LL | fn main() {}
4141
| ^

tests/ui/allow-partial-mitigations/err-allow-partial-mitigations.wrong-enable.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled
2-
--> $DIR/err-allow-partial-mitigations.rs:13:1
2+
--> $DIR/err-allow-partial-mitigations.rs:14:1
33
|
44
LL | fn main() {}
55
| ^
@@ -8,7 +8,7 @@ LL | fn main() {}
88
= note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation only partially enabled
99

1010
error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled
11-
--> $DIR/err-allow-partial-mitigations.rs:13:1
11+
--> $DIR/err-allow-partial-mitigations.rs:14:1
1212
|
1313
LL | fn main() {}
1414
| ^
@@ -17,7 +17,7 @@ LL | fn main() {}
1717
= note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation only partially enabled
1818

1919
error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled
20-
--> $DIR/err-allow-partial-mitigations.rs:13:1
20+
--> $DIR/err-allow-partial-mitigations.rs:14:1
2121
|
2222
LL | fn main() {}
2323
| ^
@@ -26,7 +26,7 @@ LL | fn main() {}
2626
= note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation only partially enabled
2727

2828
error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled
29-
--> $DIR/err-allow-partial-mitigations.rs:13:1
29+
--> $DIR/err-allow-partial-mitigations.rs:14:1
3030
|
3131
LL | fn main() {}
3232
| ^
@@ -35,7 +35,7 @@ LL | fn main() {}
3535
= note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation only partially enabled
3636

3737
error: your program uses the crate `libc`, that is not compiled with `stack-protector=all` enabled
38-
--> $DIR/err-allow-partial-mitigations.rs:13:1
38+
--> $DIR/err-allow-partial-mitigations.rs:14:1
3939
|
4040
LL | fn main() {}
4141
| ^

0 commit comments

Comments
 (0)