@@ -251,6 +251,8 @@ pub struct Target {
251251 pub ranlib : Option < PathBuf > ,
252252 pub linker : Option < PathBuf > ,
253253 pub ndk : Option < PathBuf > ,
254+ pub sanitizers : bool ,
255+ pub profiler : bool ,
254256 pub crt_static : Option < bool > ,
255257 pub musl_root : Option < PathBuf > ,
256258 pub musl_libdir : Option < PathBuf > ,
@@ -474,6 +476,8 @@ struct TomlTarget {
474476 llvm_config : Option < String > ,
475477 llvm_filecheck : Option < String > ,
476478 android_ndk : Option < String > ,
479+ sanitizers : Option < bool > ,
480+ profiler : Option < bool > ,
477481 crt_static : Option < bool > ,
478482 musl_root : Option < String > ,
479483 musl_libdir : Option < String > ,
@@ -857,6 +861,8 @@ impl Config {
857861 target. musl_libdir = cfg. musl_libdir . map ( PathBuf :: from) ;
858862 target. wasi_root = cfg. wasi_root . map ( PathBuf :: from) ;
859863 target. qemu_rootfs = cfg. qemu_rootfs . map ( PathBuf :: from) ;
864+ target. sanitizers = cfg. sanitizers . unwrap_or ( build. sanitizers . unwrap_or_default ( ) ) ;
865+ target. profiler = cfg. profiler . unwrap_or ( build. profiler . unwrap_or_default ( ) ) ;
860866
861867 config. target_config . insert ( TargetSelection :: from_user ( & triple) , target) ;
862868 }
@@ -959,6 +965,22 @@ impl Config {
959965 self . verbose > 1
960966 }
961967
968+ pub fn sanitizers_enabled ( & self , target : TargetSelection ) -> bool {
969+ self . target_config . get ( & target) . map ( |t| t. sanitizers ) . unwrap_or ( self . sanitizers )
970+ }
971+
972+ pub fn any_sanitizers_enabled ( & self ) -> bool {
973+ self . target_config . values ( ) . any ( |t| t. sanitizers ) || self . sanitizers
974+ }
975+
976+ pub fn profiler_enabled ( & self , target : TargetSelection ) -> bool {
977+ self . target_config . get ( & target) . map ( |t| t. profiler ) . unwrap_or ( self . profiler )
978+ }
979+
980+ pub fn any_profiler_enabled ( & self ) -> bool {
981+ self . target_config . values ( ) . any ( |t| t. profiler ) || self . profiler
982+ }
983+
962984 pub fn llvm_enabled ( & self ) -> bool {
963985 self . rust_codegen_backends . contains ( & INTERNER . intern_str ( "llvm" ) )
964986 }
0 commit comments