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 ( ) {
7- rustc ( ) . input ( "main.rs" ) . opt ( ) . function_sections ( true ) . run ( ) ;
8-
98 let bin = bin_name ( "main" ) ;
109
10+ rustc ( ) . input ( "main.rs" ) . opt ( ) . function_sections ( false ) . run ( ) ;
11+
12+ // Check that the naked symbol is eliminated when the "clothed" one is.
13+
14+ assert_eq ! (
15+ object_contains_any_symbol( & bin, & [ "unused_clothed" ] ) ,
16+ object_contains_any_symbol( & bin, & [ "unused" ] )
17+ ) ;
18+
19+ assert_eq ! (
20+ object_contains_any_symbol( & bin, & [ "unused_link_section_clothed" ] ) ,
21+ object_contains_any_symbol( & bin, & [ "unused_link_section" ] )
22+ ) ;
23+
24+ // ---
25+
26+ rustc ( ) . input ( "main.rs" ) . opt ( ) . function_sections ( true ) . run ( ) ;
27+
1128 // Check that the naked symbol is eliminated when the "clothed" one is.
1229
1330 assert_eq ! (
You can’t perform that action at this time.
0 commit comments