@@ -251,6 +251,8 @@ pub struct Target {
251
251
pub ranlib : Option < PathBuf > ,
252
252
pub linker : Option < PathBuf > ,
253
253
pub ndk : Option < PathBuf > ,
254
+ pub sanitizers : bool ,
255
+ pub profiler : bool ,
254
256
pub crt_static : Option < bool > ,
255
257
pub musl_root : Option < PathBuf > ,
256
258
pub musl_libdir : Option < PathBuf > ,
@@ -474,6 +476,8 @@ struct TomlTarget {
474
476
llvm_config : Option < String > ,
475
477
llvm_filecheck : Option < String > ,
476
478
android_ndk : Option < String > ,
479
+ sanitizers : Option < bool > ,
480
+ profiler : Option < bool > ,
477
481
crt_static : Option < bool > ,
478
482
musl_root : Option < String > ,
479
483
musl_libdir : Option < String > ,
@@ -857,6 +861,8 @@ impl Config {
857
861
target. musl_libdir = cfg. musl_libdir . map ( PathBuf :: from) ;
858
862
target. wasi_root = cfg. wasi_root . map ( PathBuf :: from) ;
859
863
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 ( ) ) ;
860
866
861
867
config. target_config . insert ( TargetSelection :: from_user ( & triple) , target) ;
862
868
}
@@ -959,6 +965,22 @@ impl Config {
959
965
self . verbose > 1
960
966
}
961
967
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
+
962
984
pub fn llvm_enabled ( & self ) -> bool {
963
985
self . rust_codegen_backends . contains ( & INTERNER . intern_str ( "llvm" ) )
964
986
}
0 commit comments