@@ -11,10 +11,10 @@ use tracing::*;
1111use crate :: common:: { Config , Debugger , FailMode , Mode , PassMode } ;
1212use crate :: header:: cfg:: parse_cfg_name_directive;
1313use crate :: header:: cfg:: MatchOutcome ;
14- use crate :: util;
1514use crate :: { extract_cdb_version, extract_gdb_version} ;
1615
1716mod cfg;
17+ mod needs;
1818#[ cfg( test) ]
1919mod tests;
2020
@@ -660,14 +660,6 @@ impl Config {
660660 }
661661 }
662662
663- fn parse_needs_matching_clang ( & self , line : & str ) -> bool {
664- self . parse_name_directive ( line, "needs-matching-clang" )
665- }
666-
667- fn parse_needs_profiler_support ( & self , line : & str ) -> bool {
668- self . parse_name_directive ( line, "needs-profiler-support" )
669- }
670-
671663 fn has_cfg_prefix ( & self , line : & str , prefix : & str ) -> bool {
672664 // returns whether this line contains this prefix or not. For prefix
673665 // "ignore", returns true if line says "ignore-x86_64", "ignore-arch",
@@ -871,69 +863,13 @@ pub fn make_test_description<R: Read>(
871863 let mut ignore_message = None ;
872864 let mut should_fail = false ;
873865
874- let rustc_has_profiler_support = env:: var_os ( "RUSTC_PROFILER_SUPPORT" ) . is_some ( ) ;
875- let rustc_has_sanitizer_support = env:: var_os ( "RUSTC_SANITIZER_SUPPORT" ) . is_some ( ) ;
876- let has_asm_support = config. has_asm_support ( ) ;
877- let has_asan = util:: ASAN_SUPPORTED_TARGETS . contains ( & & * config. target ) ;
878- let has_cfi = util:: CFI_SUPPORTED_TARGETS . contains ( & & * config. target ) ;
879- let has_kcfi = util:: KCFI_SUPPORTED_TARGETS . contains ( & & * config. target ) ;
880- let has_kasan = util:: KASAN_SUPPORTED_TARGETS . contains ( & & * config. target ) ;
881- let has_lsan = util:: LSAN_SUPPORTED_TARGETS . contains ( & & * config. target ) ;
882- let has_msan = util:: MSAN_SUPPORTED_TARGETS . contains ( & & * config. target ) ;
883- let has_tsan = util:: TSAN_SUPPORTED_TARGETS . contains ( & & * config. target ) ;
884- let has_hwasan = util:: HWASAN_SUPPORTED_TARGETS . contains ( & & * config. target ) ;
885- let has_memtag = util:: MEMTAG_SUPPORTED_TARGETS . contains ( & & * config. target ) ;
886- let has_shadow_call_stack = util:: SHADOWCALLSTACK_SUPPORTED_TARGETS . contains ( & & * config. target ) ;
887- let has_xray = util:: XRAY_SUPPORTED_TARGETS . contains ( & & * config. target ) ;
888-
889- // For tests using the `needs-rust-lld` directive (e.g. for `-Zgcc-ld=lld`), we need to find
890- // whether `rust-lld` is present in the compiler under test.
891- //
892- // The --compile-lib-path is the path to host shared libraries, but depends on the OS. For
893- // example:
894- // - on linux, it can be <sysroot>/lib
895- // - on windows, it can be <sysroot>/bin
896- //
897- // However, `rust-lld` is only located under the lib path, so we look for it there.
898- let has_rust_lld = config
899- . compile_lib_path
900- . parent ( )
901- . expect ( "couldn't traverse to the parent of the specified --compile-lib-path" )
902- . join ( "lib" )
903- . join ( "rustlib" )
904- . join ( & config. target )
905- . join ( "bin" )
906- . join ( if config. host . contains ( "windows" ) { "rust-lld.exe" } else { "rust-lld" } )
907- . exists ( ) ;
908-
909- fn is_on_path ( file : & ' static str ) -> impl Fn ( ) -> bool {
910- move || env:: split_paths ( & env:: var_os ( "PATH" ) . unwrap ( ) ) . any ( |dir| dir. join ( file) . is_file ( ) )
911- }
912-
913- // On Windows, dlltool.exe is used for all architectures.
914- #[ cfg( windows) ]
915- let ( has_i686_dlltool, has_x86_64_dlltool) =
916- ( is_on_path ( "dlltool.exe" ) , is_on_path ( "dlltool.exe" ) ) ;
917- // For non-Windows, there are architecture specific dlltool binaries.
918- #[ cfg( not( windows) ) ]
919- let ( has_i686_dlltool, has_x86_64_dlltool) =
920- ( is_on_path ( "i686-w64-mingw32-dlltool" ) , is_on_path ( "x86_64-w64-mingw32-dlltool" ) ) ;
866+ let needs_cache = needs:: CachedNeedsConditions :: load ( config) ;
921867
922868 iter_header ( path, src, & mut |revision, ln| {
923869 if revision. is_some ( ) && revision != cfg {
924870 return ;
925871 }
926- macro_rules! reason {
927- ( $e: expr) => {
928- ignore |= match $e {
929- true => {
930- ignore_message = Some ( stringify!( $e) ) ;
931- true
932- }
933- false => ignore,
934- }
935- } ;
936- }
872+
937873 macro_rules! decision {
938874 ( $e: expr) => {
939875 match $e {
@@ -944,6 +880,10 @@ pub fn make_test_description<R: Read>(
944880 // compiletest so it won't grow indefinitely.
945881 ignore_message = Some ( Box :: leak( Box :: <str >:: from( reason) ) ) ;
946882 }
883+ IgnoreDecision :: Error { message } => {
884+ eprintln!( "error: {}: {message}" , path. display( ) ) ;
885+ panic!( ) ;
886+ }
947887 IgnoreDecision :: Continue => { }
948888 }
949889 } ;
@@ -989,48 +929,27 @@ pub fn make_test_description<R: Read>(
989929 } ;
990930 }
991931
932+ decision ! ( needs:: handle_needs( & needs_cache, config, ln) ) ;
992933 decision ! ( ignore_llvm( config, ln) ) ;
993934 decision ! ( ignore_cdb( config, ln) ) ;
994935 decision ! ( ignore_gdb( config, ln) ) ;
995936 decision ! ( ignore_lldb( config, ln) ) ;
996937
997- reason ! (
998- config. run_clang_based_tests_with. is_none( ) && config. parse_needs_matching_clang( ln)
999- ) ;
1000- reason ! ( !has_asm_support && config. parse_name_directive( ln, "needs-asm-support" ) ) ;
1001- reason ! ( !rustc_has_profiler_support && config. parse_needs_profiler_support( ln) ) ;
1002- reason ! ( !config. run_enabled( ) && config. parse_name_directive( ln, "needs-run-enabled" ) ) ;
1003- reason ! (
1004- !rustc_has_sanitizer_support
1005- && config. parse_name_directive( ln, "needs-sanitizer-support" )
1006- ) ;
1007- reason ! ( !has_asan && config. parse_name_directive( ln, "needs-sanitizer-address" ) ) ;
1008- reason ! ( !has_cfi && config. parse_name_directive( ln, "needs-sanitizer-cfi" ) ) ;
1009- reason ! ( !has_kcfi && config. parse_name_directive( ln, "needs-sanitizer-kcfi" ) ) ;
1010- reason ! ( !has_kasan && config. parse_name_directive( ln, "needs-sanitizer-kasan" ) ) ;
1011- reason ! ( !has_lsan && config. parse_name_directive( ln, "needs-sanitizer-leak" ) ) ;
1012- reason ! ( !has_msan && config. parse_name_directive( ln, "needs-sanitizer-memory" ) ) ;
1013- reason ! ( !has_tsan && config. parse_name_directive( ln, "needs-sanitizer-thread" ) ) ;
1014- reason ! ( !has_hwasan && config. parse_name_directive( ln, "needs-sanitizer-hwaddress" ) ) ;
1015- reason ! ( !has_memtag && config. parse_name_directive( ln, "needs-sanitizer-memtag" ) ) ;
1016- reason ! (
1017- !has_shadow_call_stack
1018- && config. parse_name_directive( ln, "needs-sanitizer-shadow-call-stack" )
1019- ) ;
1020- reason ! ( !config. can_unwind( ) && config. parse_name_directive( ln, "needs-unwind" ) ) ;
1021- reason ! ( !has_xray && config. parse_name_directive( ln, "needs-xray" ) ) ;
1022- reason ! (
1023- config. target == "wasm32-unknown-unknown"
1024- && config. parse_name_directive( ln, directives:: CHECK_RUN_RESULTS )
1025- ) ;
1026- reason ! ( !has_rust_lld && config. parse_name_directive( ln, "needs-rust-lld" ) ) ;
1027- reason ! ( config. parse_name_directive( ln, "needs-i686-dlltool" ) && !has_i686_dlltool( ) ) ;
1028- reason ! ( config. parse_name_directive( ln, "needs-x86_64-dlltool" ) && !has_x86_64_dlltool( ) ) ;
1029- reason ! (
1030- config. parse_name_directive( ln, "rust-lldb" )
1031- && config. debugger == Some ( Debugger :: Lldb )
1032- && !config. lldb_native_rust
1033- ) ;
938+ if config. target == "wasm32-unknown-unknown" {
939+ if config. parse_name_directive ( ln, directives:: CHECK_RUN_RESULTS ) {
940+ decision ! ( IgnoreDecision :: Ignore {
941+ reason: "ignored when checking the run results on WASM" . into( ) ,
942+ } ) ;
943+ }
944+ }
945+
946+ if config. debugger == Some ( Debugger :: Lldb ) && !config. lldb_native_rust {
947+ if config. parse_name_directive ( ln, "rust-lldb" ) {
948+ decision ! ( IgnoreDecision :: Ignore {
949+ reason: "ignored on targets wihtout Rust's LLDB" . into( )
950+ } ) ;
951+ }
952+ }
1034953
1035954 should_fail |= config. parse_name_directive ( ln, "should-fail" ) ;
1036955 } ) ;
@@ -1226,4 +1145,5 @@ fn ignore_llvm(config: &Config, line: &str) -> IgnoreDecision {
12261145enum IgnoreDecision {
12271146 Ignore { reason : String } ,
12281147 Continue ,
1148+ Error { message : String } ,
12291149}
0 commit comments