@@ -263,6 +263,8 @@ macro_rules! options {
263
263
pub const parse_sanitizer_list: Option <& str > =
264
264
Some ( "comma separated list of sanitizers" ) ;
265
265
pub const parse_sanitizer_memory_track_origins: Option <& str > = None ;
266
+ pub const parse_cfguard: Option <& str > =
267
+ Some ( "either `disabled`, `nochecks`, or `checks`" ) ;
266
268
pub const parse_linker_flavor: Option <& str > =
267
269
Some ( :: rustc_target:: spec:: LinkerFlavor :: one_of( ) ) ;
268
270
pub const parse_optimization_fuel: Option <& str > =
@@ -288,7 +290,7 @@ macro_rules! options {
288
290
#[ allow( dead_code) ]
289
291
mod $mod_set {
290
292
use super :: { $struct_name, Passes , Sanitizer , LtoCli , LinkerPluginLto , SwitchWithOptPath ,
291
- SymbolManglingVersion } ;
293
+ SymbolManglingVersion , CFGuard } ;
292
294
use rustc_target:: spec:: { LinkerFlavor , MergeFunctions , PanicStrategy , RelroLevel } ;
293
295
use std:: path:: PathBuf ;
294
296
use std:: str :: FromStr ;
@@ -499,6 +501,16 @@ macro_rules! options {
499
501
}
500
502
}
501
503
504
+ fn parse_cfguard( slot: & mut CFGuard , v: Option <& str >) -> bool {
505
+ match v {
506
+ Some ( "disabled" ) => * slot = CFGuard :: Disabled ,
507
+ Some ( "nochecks" ) => * slot = CFGuard :: NoChecks ,
508
+ Some ( "checks" ) => * slot = CFGuard :: Checks ,
509
+ _ => return false ,
510
+ }
511
+ true
512
+ }
513
+
502
514
fn parse_linker_flavor( slote: & mut Option <LinkerFlavor >, v: Option <& str >) -> bool {
503
515
match v. and_then( LinkerFlavor :: from_str) {
504
516
Some ( lf) => * slote = Some ( lf) ,
@@ -950,6 +962,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
950
962
(such as entering an empty infinite loop) by inserting llvm.sideeffect") ,
951
963
deduplicate_diagnostics: Option <bool > = ( None , parse_opt_bool, [ UNTRACKED ] ,
952
964
"deduplicate identical diagnostics" ) ,
965
+ control_flow_guard: CFGuard = ( CFGuard :: Disabled , parse_cfguard, [ UNTRACKED ] ,
966
+ "use Windows Control Flow Guard (`disabled`, `nochecks` or `checks`)" ) ,
953
967
no_link: bool = ( false , parse_bool, [ TRACKED ] ,
954
968
"compile without linking" ) ,
955
969
}
0 commit comments