1- // Dynamic libraries on Rust used to export a very high amount of symbols,
2- // going as far as filling the output with mangled names and generic function
3- // names. After the rework of #38117, this test checks that no mangled Rust symbols
4- // are exported, and that generics are only shown if explicitely requested.
5- // See https://github.com/rust-lang/rust/issues/37530
1+ //! Dynamic libraries on Rust used to export a very high amount of symbols, going as far as filling
2+ //! the output with mangled names and generic function names. After the rework in #38117, this test
3+ //! checks that no mangled Rust symbols are exported, and that generics are only shown if explicitly
4+ //! requested.
5+ //!
6+ //! See <https://github.com/rust-lang/rust/issues/37530>.
67
78//@ ignore-windows-msvc
9+ // FIXME(jieyouxu): unknown reason why this test fails on msvc, likely because certain assertions
10+ // fail.
811
912use run_make_support:: { bin_name, dynamic_lib_name, is_windows, llvm_readobj, regex, rustc} ;
1013
@@ -143,13 +146,19 @@ fn main() {
143146#[ track_caller]
144147fn symbols_check ( path : & str , symbol_check_type : SymbolCheckType , exists_once : bool ) {
145148 let out = llvm_readobj ( ) . arg ( "--dyn-symbols" ) . input ( path) . run ( ) . invalid_stdout_utf8 ( ) ;
146- assert_eq ! (
147- out. lines( )
148- . filter( |& line| !line. contains( "__imp_" ) && has_symbol( line, symbol_check_type) )
149- . count( )
150- == 1 ,
151- exists_once
152- ) ;
149+
150+ let matched_lines = out
151+ . lines ( )
152+ . filter ( |& line| !line. contains ( "__imp_" ) && has_symbol ( line, symbol_check_type) )
153+ . collect :: < Vec < _ > > ( ) ;
154+
155+ if exists_once && matched_lines. len ( ) != 1 {
156+ eprintln ! ( "symbol_check_type: {:?}" , symbol_check_type) ;
157+ eprintln ! ( "exists_once: {}" , exists_once) ;
158+ eprintln ! ( "matched_lines:\n {:#?}" , matched_lines) ;
159+ }
160+
161+ assert_eq ! ( matched_lines. len( ) == 1 , exists_once) ;
153162}
154163
155164fn has_symbol ( line : & str , symbol_check_type : SymbolCheckType ) -> bool {
@@ -161,7 +170,7 @@ fn has_symbol(line: &str, symbol_check_type: SymbolCheckType) -> bool {
161170 }
162171}
163172
164- #[ derive( Clone , Copy ) ]
173+ #[ derive( Debug , Clone , Copy ) ]
165174enum SymbolCheckType {
166175 StrSymbol ( & ' static str ) ,
167176 AnyRustSymbol ,
0 commit comments