11use std:: iter;
22
3- use super :: { LinkerFlavor , PanicStrategy , Target , TargetOptions } ;
3+ use super :: { LinkerFlavor , LldFlavor , PanicStrategy , Target , TargetOptions } ;
44
55pub fn target ( ) -> Result < Target , String > {
66 const PRE_LINK_ARGS : & [ & str ] = & [
7- "-Wl,--as-needed" ,
8- "-Wl,-z,noexecstack" ,
9- "-m64" ,
10- "-fuse-ld=gold" ,
11- "-nostdlib" ,
12- "-shared" ,
13- "-Wl,-e,sgx_entry" ,
14- "-Wl,-Bstatic" ,
15- "-Wl,--gc-sections" ,
16- "-Wl,-z,text" ,
17- "-Wl,-z,norelro" ,
18- "-Wl,--rosegment" ,
19- "-Wl,--no-undefined" ,
20- "-Wl,--error-unresolved-symbols" ,
21- "-Wl,--no-undefined-version" ,
22- "-Wl,-Bsymbolic" ,
23- "-Wl,--export-dynamic" ,
7+ "--as-needed" ,
8+ "--eh-frame-hdr" ,
9+ "-z" , "noexecstack" ,
10+ "-e" , "sgx_entry" ,
11+ "-Bstatic" ,
12+ "--gc-sections" ,
13+ "-z" , "text" ,
14+ "-z" , "norelro" ,
15+ "--no-undefined" ,
16+ "--error-unresolved-symbols" ,
17+ "--no-undefined-version" ,
18+ "-Bsymbolic" ,
19+ "--export-dynamic" ,
2420 // The following symbols are needed by libunwind, which is linked after
2521 // libstd. Make sure they're included in the link.
26- "-Wl,-u, __rust_abort" ,
27- "-Wl,-u, __rust_c_alloc" ,
28- "-Wl,-u, __rust_c_dealloc" ,
29- "-Wl,-u, __rust_print_err" ,
30- "-Wl,-u, __rust_rwlock_rdlock" ,
31- "-Wl,-u, __rust_rwlock_unlock" ,
32- "-Wl,-u, __rust_rwlock_wrlock" ,
22+ "-u" , " __rust_abort",
23+ "-u" , " __rust_c_alloc",
24+ "-u" , " __rust_c_dealloc",
25+ "-u" , " __rust_print_err",
26+ "-u" , " __rust_rwlock_rdlock",
27+ "-u" , " __rust_rwlock_unlock",
28+ "-u" , " __rust_rwlock_wrlock"
3329 ] ;
3430
3531 const EXPORT_SYMBOLS : & [ & str ] = & [
@@ -50,18 +46,20 @@ pub fn target() -> Result<Target, String> {
5046 dynamic_linking : false ,
5147 executables : true ,
5248 linker_is_gnu : true ,
49+ linker : Some ( "rust-lld" . to_owned ( ) ) ,
5350 max_atomic_width : Some ( 64 ) ,
5451 panic_strategy : PanicStrategy :: Unwind ,
5552 cpu : "x86-64" . into ( ) ,
5653 features : "+rdrnd,+rdseed" . into ( ) ,
5754 position_independent_executables : true ,
5855 pre_link_args : iter:: once ( (
59- LinkerFlavor :: Gcc ,
56+ LinkerFlavor :: Lld ( LldFlavor :: Ld ) ,
6057 PRE_LINK_ARGS . iter ( ) . cloned ( ) . map ( String :: from) . collect ( ) ,
6158 ) )
6259 . collect ( ) ,
6360 post_link_objects : vec ! [ "libunwind.a" . into( ) ] ,
6461 override_export_symbols : Some ( EXPORT_SYMBOLS . iter ( ) . cloned ( ) . map ( String :: from) . collect ( ) ) ,
62+ relax_elf_relocations : true ,
6563 ..Default :: default ( )
6664 } ;
6765 Ok ( Target {
@@ -74,7 +72,7 @@ pub fn target() -> Result<Target, String> {
7472 target_vendor : "fortanix" . into ( ) ,
7573 data_layout : "e-m:e-i64:64-f80:128-n8:16:32:64-S128" . into ( ) ,
7674 arch : "x86_64" . into ( ) ,
77- linker_flavor : LinkerFlavor :: Gcc ,
75+ linker_flavor : LinkerFlavor :: Lld ( LldFlavor :: Ld ) ,
7876 options : opts,
7977 } )
8078}
0 commit comments