File tree Expand file tree Collapse file tree 4 files changed +30
-2
lines changed 
compiler/rustc_codegen_ssa/src/back 
tests/run-make/used-proc-macro Expand file tree Collapse file tree 4 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -1817,8 +1817,13 @@ pub(crate) fn linked_symbols(
18171817    crate_type :  CrateType , 
18181818)  -> Vec < ( String ,  SymbolExportKind ) >  { 
18191819    match  crate_type { 
1820-         CrateType :: Executable  | CrateType :: Cdylib  | CrateType :: Dylib  | CrateType :: Sdylib  => ( ) , 
1821-         CrateType :: Staticlib  | CrateType :: ProcMacro  | CrateType :: Rlib  => { 
1820+         CrateType :: Executable 
1821+         | CrateType :: ProcMacro 
1822+         | CrateType :: Cdylib 
1823+         | CrateType :: Dylib 
1824+         | CrateType :: Sdylib  => ( ) , 
1825+         CrateType :: Staticlib  | CrateType :: Rlib  => { 
1826+             // These are not linked, so no need to generate symbols.o for them. 
18221827            return  Vec :: new ( ) ; 
18231828        } 
18241829    } 
Original file line number Diff line number Diff line change 1+ #![ crate_type = "lib" ]  
2+ 
3+ #[ used]  
4+ static  VERY_IMPORTANT_SYMBOL :  u32  = 12345 ; 
Original file line number Diff line number Diff line change 1+ #![ crate_type = "proc-macro" ]  
2+ 
3+ extern  crate  dep as  _; 
Original file line number Diff line number Diff line change 1+ // Test that #[used] statics are included in the final dylib for proc-macros too. 
2+ 
3+ //@ needs-target-std 
4+ //@ needs-crate-type: proc-macro 
5+ 
6+ use  run_make_support:: { dynamic_lib_name,  llvm_readobj,  rustc} ; 
7+ 
8+ fn  main ( )  { 
9+     rustc ( ) . input ( "dep.rs" ) . run ( ) ; 
10+     rustc ( ) . input ( "proc_macro.rs" ) . run ( ) ; 
11+     llvm_readobj ( ) 
12+         . input ( dynamic_lib_name ( "proc_macro" ) ) 
13+         . arg ( "--all" ) 
14+         . run ( ) 
15+         . assert_stdout_contains ( "VERY_IMPORTANT_SYMBOL" ) ; 
16+ } 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments