File tree Expand file tree Collapse file tree
tests/run-make/naked-dead-code-elimination Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,6 +7,16 @@ extern "C" fn used() {
77 naked_asm ! ( "ret" )
88}
99
10+ #[ unsafe( no_mangle) ]
11+ extern "C" fn used_clothed ( ) -> i32 {
12+ 41
13+ }
14+
15+ pub fn main ( ) {
16+ std:: hint:: black_box ( used ( ) ) ;
17+ std:: hint:: black_box ( used_clothed ( ) ) ;
18+ }
19+
1020#[ unsafe( no_mangle) ]
1121extern "C" fn unused_clothed ( ) -> i32 {
1222 42
@@ -36,7 +46,3 @@ extern "C" fn unused_link_section() {
3646extern "C" fn unused_link_section_clothed ( ) -> i32 {
3747 43
3848}
39-
40- fn main ( ) {
41- used ( ) ;
42- }
Original file line number Diff line number Diff line change 1+ //@ ignore-cross-compile
12//@ needs-asm-support
23
34use run_make_support:: symbols:: object_contains_any_symbol;
45use run_make_support:: { bin_name, rustc} ;
56
67fn main ( ) {
8+ let bin = bin_name ( "main" ) ;
9+
10+ rustc ( ) . input ( "main.rs" ) . opt ( ) . function_sections ( false ) . run ( ) ;
11+
12+ assert ! ( object_contains_any_symbol( & bin, & [ "used" ] ) ) ;
13+
14+ // Check that the naked symbol is eliminated when the "clothed" one is.
15+
16+ assert_eq ! (
17+ object_contains_any_symbol( & bin, & [ "unused_clothed" ] ) ,
18+ object_contains_any_symbol( & bin, & [ "unused" ] )
19+ ) ;
20+
21+ assert_eq ! (
22+ object_contains_any_symbol( & bin, & [ "unused_link_section_clothed" ] ) ,
23+ object_contains_any_symbol( & bin, & [ "unused_link_section" ] )
24+ ) ;
25+
26+ // ---
27+
728 rustc ( ) . input ( "main.rs" ) . opt ( ) . function_sections ( true ) . run ( ) ;
829
9- let bin = bin_name ( "main" ) ;
30+ assert ! ( object_contains_any_symbol ( & bin, & [ "used" ] ) ) ;
1031
1132 // Check that the naked symbol is eliminated when the "clothed" one is.
1233
You can’t perform that action at this time.
0 commit comments