17
17
18
18
//@ ignore-cross-compile
19
19
20
- use run_make_support:: artifact_names:: bin_name;
21
20
use run_make_support:: env:: no_debug_assertions;
22
- use run_make_support:: rustc;
23
21
use run_make_support:: symbols:: any_symbol_contains;
22
+ use run_make_support:: { bin_name, is_msvc, pdb, rustc, target} ;
24
23
25
24
fn main ( ) {
26
25
rustc ( ) . input ( "main.rs" ) . opt ( ) . run ( ) ;
@@ -31,8 +30,40 @@ fn main() {
31
30
// otherwise, add them to the list of symbols to deny.
32
31
panic_syms. extend_from_slice ( & [ "panicking" , "panic_fmt" , "pad_integral" , "Display" ] ) ;
33
32
}
34
- // Make sure we at least have the `main` symbol itself, otherwise even no symbols can trivially
35
- // satisfy the "no panic symbol" assertion.
36
- assert ! ( any_symbol_contains( bin_name( "main" ) , & [ "main" ] ) ) ;
37
- assert ! ( !any_symbol_contains( bin_name( "main" ) , & panic_syms) ) ;
33
+
34
+ if is_msvc ( ) {
35
+ use pdb:: FallibleIterator ;
36
+
37
+ let file = std:: fs:: File :: open ( "main.pdb" ) . expect ( "failed to open `main.pdb`" ) ;
38
+ let mut pdb = pdb:: PDB :: open ( file) . expect ( "failed to parse `main.pdb`" ) ;
39
+
40
+ let symbol_table = pdb. global_symbols ( ) . expect ( "failed to parse PDB global symbols" ) ;
41
+ let mut symbols = symbol_table. iter ( ) ;
42
+
43
+ let mut found_symbols = vec ! [ ] ;
44
+
45
+ while let Some ( symbol) = symbols. next ( ) . expect ( "failed to parse symbol" ) {
46
+ match symbol. parse ( ) {
47
+ Ok ( pdb:: SymbolData :: Public ( data) ) => {
48
+ found_symbols. push ( data. name . to_string ( ) ) ;
49
+ }
50
+ _ => { }
51
+ }
52
+ }
53
+
54
+ // Make sure we at least have the `main` symbol itself, otherwise even no symbols can
55
+ // trivially satisfy the "no panic symbol" assertion.
56
+ assert ! ( found_symbols. iter( ) . any( |sym| sym == "main" ) , "expected `main` symbol" ) ;
57
+
58
+ for found_symbol in found_symbols {
59
+ for panic_symbol in & panic_syms {
60
+ assert_ne ! ( found_symbol, * panic_symbol, "found unexpected panic machinery symbol" ) ;
61
+ }
62
+ }
63
+ } else {
64
+ // Make sure we at least have the `main` symbol itself, otherwise even no symbols can
65
+ // trivially satisfy the "no panic symbol" assertion.
66
+ assert ! ( any_symbol_contains( bin_name( "main" ) , & [ "main" ] ) ) ;
67
+ assert ! ( !any_symbol_contains( bin_name( "main" ) , & panic_syms) ) ;
68
+ }
38
69
}
0 commit comments