File tree Expand file tree Collapse file tree 4 files changed +31
-2
lines changed
compiler/rustc_codegen_ssa/src/back
tests/run-make/used-proc-macro Expand file tree Collapse file tree 4 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -1778,8 +1778,13 @@ pub(crate) fn linked_symbols(
1778
1778
crate_type : CrateType ,
1779
1779
) -> Vec < ( String , SymbolExportKind ) > {
1780
1780
match crate_type {
1781
- CrateType :: Executable | CrateType :: Cdylib | CrateType :: Dylib | CrateType :: Sdylib => ( ) ,
1782
- CrateType :: Staticlib | CrateType :: ProcMacro | CrateType :: Rlib => {
1781
+ CrateType :: Executable
1782
+ | CrateType :: ProcMacro
1783
+ | CrateType :: Cdylib
1784
+ | CrateType :: Dylib
1785
+ | CrateType :: Sdylib => ( ) ,
1786
+ CrateType :: Staticlib | CrateType :: Rlib => {
1787
+ // These are not linked, so no need to generate symbols.o for them.
1783
1788
return Vec :: new ( ) ;
1784
1789
}
1785
1790
}
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
+ //@ ignore-cross-compile
4
+ //@ needs-crate-type: proc-macro
5
+ //@ ignore-musl (FIXME: can't find `-lunwind`)
6
+
7
+ use run_make_support:: { dynamic_lib_name, llvm_readobj, rustc} ;
8
+
9
+ fn main ( ) {
10
+ rustc ( ) . input ( "dep.rs" ) . run ( ) ;
11
+ rustc ( ) . input ( "proc_macro.rs" ) . run ( ) ;
12
+ llvm_readobj ( )
13
+ . input ( dynamic_lib_name ( "proc_macro" ) )
14
+ . arg ( "--all" )
15
+ . run ( )
16
+ . assert_stdout_contains ( "VERY_IMPORTANT_SYMBOL" ) ;
17
+ }
You can’t perform that action at this time.
0 commit comments