1
1
use std:: iter;
2
2
3
- use super :: { LinkerFlavor , PanicStrategy , Target , TargetOptions } ;
3
+ use super :: { LinkerFlavor , LldFlavor , PanicStrategy , Target , TargetOptions } ;
4
4
5
5
pub fn target ( ) -> Result < Target , String > {
6
6
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" ,
24
20
// The following symbols are needed by libunwind, which is linked after
25
21
// 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"
33
29
] ;
34
30
35
31
const EXPORT_SYMBOLS : & [ & str ] = & [
@@ -50,18 +46,20 @@ pub fn target() -> Result<Target, String> {
50
46
dynamic_linking : false ,
51
47
executables : true ,
52
48
linker_is_gnu : true ,
49
+ linker : Some ( "rust-lld" . to_owned ( ) ) ,
53
50
max_atomic_width : Some ( 64 ) ,
54
51
panic_strategy : PanicStrategy :: Unwind ,
55
52
cpu : "x86-64" . into ( ) ,
56
53
features : "+rdrnd,+rdseed" . into ( ) ,
57
54
position_independent_executables : true ,
58
55
pre_link_args : iter:: once ( (
59
- LinkerFlavor :: Gcc ,
56
+ LinkerFlavor :: Lld ( LldFlavor :: Ld ) ,
60
57
PRE_LINK_ARGS . iter ( ) . cloned ( ) . map ( String :: from) . collect ( ) ,
61
58
) )
62
59
. collect ( ) ,
63
60
post_link_objects : vec ! [ "libunwind.a" . into( ) ] ,
64
61
override_export_symbols : Some ( EXPORT_SYMBOLS . iter ( ) . cloned ( ) . map ( String :: from) . collect ( ) ) ,
62
+ relax_elf_relocations : true ,
65
63
..Default :: default ( )
66
64
} ;
67
65
Ok ( Target {
@@ -74,7 +72,7 @@ pub fn target() -> Result<Target, String> {
74
72
target_vendor : "fortanix" . into ( ) ,
75
73
data_layout : "e-m:e-i64:64-f80:128-n8:16:32:64-S128" . into ( ) ,
76
74
arch : "x86_64" . into ( ) ,
77
- linker_flavor : LinkerFlavor :: Gcc ,
75
+ linker_flavor : LinkerFlavor :: Lld ( LldFlavor :: Ld ) ,
78
76
options : opts,
79
77
} )
80
78
}
0 commit comments