@@ -263,6 +263,8 @@ macro_rules! options {
263263 pub const parse_sanitizer_list: Option <& str > =
264264 Some ( "comma separated list of sanitizers" ) ;
265265 pub const parse_sanitizer_memory_track_origins: Option <& str > = None ;
266+ pub const parse_cfguard: Option <& str > =
267+ Some ( "either `disabled`, `nochecks`, or `checks`" ) ;
266268 pub const parse_linker_flavor: Option <& str > =
267269 Some ( :: rustc_target:: spec:: LinkerFlavor :: one_of( ) ) ;
268270 pub const parse_optimization_fuel: Option <& str > =
@@ -288,7 +290,7 @@ macro_rules! options {
288290 #[ allow( dead_code) ]
289291 mod $mod_set {
290292 use super :: { $struct_name, Passes , Sanitizer , LtoCli , LinkerPluginLto , SwitchWithOptPath ,
291- SymbolManglingVersion } ;
293+ SymbolManglingVersion , CFGuard } ;
292294 use rustc_target:: spec:: { LinkerFlavor , MergeFunctions , PanicStrategy , RelroLevel } ;
293295 use std:: path:: PathBuf ;
294296 use std:: str :: FromStr ;
@@ -499,6 +501,16 @@ macro_rules! options {
499501 }
500502 }
501503
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+
502514 fn parse_linker_flavor( slote: & mut Option <LinkerFlavor >, v: Option <& str >) -> bool {
503515 match v. and_then( LinkerFlavor :: from_str) {
504516 Some ( lf) => * slote = Some ( lf) ,
@@ -950,6 +962,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
950962 (such as entering an empty infinite loop) by inserting llvm.sideeffect") ,
951963 deduplicate_diagnostics: Option <bool > = ( None , parse_opt_bool, [ UNTRACKED ] ,
952964 "deduplicate identical diagnostics" ) ,
965+ control_flow_guard: CFGuard = ( CFGuard :: Disabled , parse_cfguard, [ UNTRACKED ] ,
966+ "use Windows Control Flow Guard (`disabled`, `nochecks` or `checks`)" ) ,
953967 no_link: bool = ( false , parse_bool, [ TRACKED ] ,
954968 "compile without linking" ) ,
955969}
0 commit comments