@@ -1517,59 +1517,22 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
15171517 ) ;
15181518 }
15191519
1520- const ASAN_SUPPORTED_TARGETS : & [ & str ] = & [
1521- "aarch64-apple-darwin" ,
1522- "aarch64-fuchsia" ,
1523- "aarch64-unknown-linux-gnu" ,
1524- "x86_64-apple-darwin" ,
1525- "x86_64-fuchsia" ,
1526- "x86_64-unknown-freebsd" ,
1527- "x86_64-unknown-linux-gnu" ,
1528- ] ;
1529- const LSAN_SUPPORTED_TARGETS : & [ & str ] = & [
1530- "aarch64-apple-darwin" ,
1531- "aarch64-unknown-linux-gnu" ,
1532- "x86_64-apple-darwin" ,
1533- "x86_64-unknown-linux-gnu" ,
1534- ] ;
1535- const MSAN_SUPPORTED_TARGETS : & [ & str ] =
1536- & [ "aarch64-unknown-linux-gnu" , "x86_64-unknown-freebsd" , "x86_64-unknown-linux-gnu" ] ;
1537- const TSAN_SUPPORTED_TARGETS : & [ & str ] = & [
1538- "aarch64-apple-darwin" ,
1539- "aarch64-unknown-linux-gnu" ,
1540- "x86_64-apple-darwin" ,
1541- "x86_64-unknown-freebsd" ,
1542- "x86_64-unknown-linux-gnu" ,
1543- ] ;
1544- const HWASAN_SUPPORTED_TARGETS : & [ & str ] =
1545- & [ "aarch64-linux-android" , "aarch64-unknown-linux-gnu" ] ;
1546-
1547- // Sanitizers can only be used on some tested platforms.
1548- for s in sess. opts . debugging_opts . sanitizer {
1549- let supported_targets = match s {
1550- SanitizerSet :: ADDRESS => ASAN_SUPPORTED_TARGETS ,
1551- SanitizerSet :: LEAK => LSAN_SUPPORTED_TARGETS ,
1552- SanitizerSet :: MEMORY => MSAN_SUPPORTED_TARGETS ,
1553- SanitizerSet :: THREAD => TSAN_SUPPORTED_TARGETS ,
1554- SanitizerSet :: HWADDRESS => HWASAN_SUPPORTED_TARGETS ,
1555- _ => panic ! ( "unrecognized sanitizer {}" , s) ,
1556- } ;
1557- if !supported_targets. contains ( & & * sess. opts . target_triple . triple ( ) ) {
1558- sess. err ( & format ! (
1559- "`-Zsanitizer={}` only works with targets: {}" ,
1560- s,
1561- supported_targets. join( ", " )
1562- ) ) ;
1563- }
1564- let conflicting = sess. opts . debugging_opts . sanitizer - s;
1565- if !conflicting. is_empty ( ) {
1566- sess. err ( & format ! (
1567- "`-Zsanitizer={}` is incompatible with `-Zsanitizer={}`" ,
1568- s, conflicting,
1569- ) ) ;
1570- // Don't report additional errors.
1571- break ;
1572- }
1520+ // Sanitizers can only be used on platforms that we know have working sanitizer codegen.
1521+ let supported_sanitizers = sess. target . options . supported_sanitizers ;
1522+ let unsupported_sanitizers = sess. opts . debugging_opts . sanitizer - supported_sanitizers;
1523+ match unsupported_sanitizers. into_iter ( ) . count ( ) {
1524+ 0 => { }
1525+ 1 => sess
1526+ . err ( & format ! ( "{} sanitizer is not supported for this target" , unsupported_sanitizers) ) ,
1527+ _ => sess. err ( & format ! (
1528+ "{} sanitizers are not supported for this target" ,
1529+ unsupported_sanitizers
1530+ ) ) ,
1531+ }
1532+ // Cannot mix and match sanitizers.
1533+ let mut sanitizer_iter = sess. opts . debugging_opts . sanitizer . into_iter ( ) ;
1534+ if let ( Some ( first) , Some ( second) ) = ( sanitizer_iter. next ( ) , sanitizer_iter. next ( ) ) {
1535+ sess. err ( & format ! ( "`-Zsanitizer={}` is incompatible with `-Zsanitizer={}`" , first, second) ) ;
15731536 }
15741537}
15751538
0 commit comments