@@ -17,6 +17,7 @@ use rustc::session::config::{self, CrateType, OptLevel, DebugInfo,
17
17
use rustc:: ty:: TyCtxt ;
18
18
use rustc_target:: spec:: { LinkerFlavor , LldFlavor } ;
19
19
use rustc_serialize:: { json, Encoder } ;
20
+ use syntax:: symbol:: Symbol ;
20
21
21
22
/// For all the linkers we support, and information they might
22
23
/// need out of the shared crate context before we get rid of it.
@@ -99,13 +100,13 @@ impl LinkerInfo {
99
100
/// used to dispatch on whether a GNU-like linker (generally `ld.exe`) or an
100
101
/// MSVC linker (e.g., `link.exe`) is being used.
101
102
pub trait Linker {
102
- fn link_dylib ( & mut self , lib : & str ) ;
103
- fn link_rust_dylib ( & mut self , lib : & str , path : & Path ) ;
104
- fn link_framework ( & mut self , framework : & str ) ;
105
- fn link_staticlib ( & mut self , lib : & str ) ;
103
+ fn link_dylib ( & mut self , lib : Symbol ) ;
104
+ fn link_rust_dylib ( & mut self , lib : Symbol , path : & Path ) ;
105
+ fn link_framework ( & mut self , framework : Symbol ) ;
106
+ fn link_staticlib ( & mut self , lib : Symbol ) ;
106
107
fn link_rlib ( & mut self , lib : & Path ) ;
107
108
fn link_whole_rlib ( & mut self , lib : & Path ) ;
108
- fn link_whole_staticlib ( & mut self , lib : & str , search_path : & [ PathBuf ] ) ;
109
+ fn link_whole_staticlib ( & mut self , lib : Symbol , search_path : & [ PathBuf ] ) ;
109
110
fn include_path ( & mut self , path : & Path ) ;
110
111
fn framework_path ( & mut self , path : & Path ) ;
111
112
fn output_filename ( & mut self , path : & Path ) ;
@@ -215,9 +216,13 @@ impl<'a> GccLinker<'a> {
215
216
}
216
217
217
218
impl < ' a > Linker for GccLinker < ' a > {
218
- fn link_dylib ( & mut self , lib : & str ) { self . hint_dynamic ( ) ; self . cmd . arg ( format ! ( "-l{}" , lib) ) ; }
219
- fn link_staticlib ( & mut self , lib : & str ) {
220
- self . hint_static ( ) ; self . cmd . arg ( format ! ( "-l{}" , lib) ) ;
219
+ fn link_dylib ( & mut self , lib : Symbol ) {
220
+ self . hint_dynamic ( ) ;
221
+ self . cmd . arg ( format ! ( "-l{}" , lib) ) ;
222
+ }
223
+ fn link_staticlib ( & mut self , lib : Symbol ) {
224
+ self . hint_static ( ) ;
225
+ self . cmd . arg ( format ! ( "-l{}" , lib) ) ;
221
226
}
222
227
fn link_rlib ( & mut self , lib : & Path ) { self . hint_static ( ) ; self . cmd . arg ( lib) ; }
223
228
fn include_path ( & mut self , path : & Path ) { self . cmd . arg ( "-L" ) . arg ( path) ; }
@@ -232,14 +237,14 @@ impl<'a> Linker for GccLinker<'a> {
232
237
fn build_static_executable ( & mut self ) { self . cmd . arg ( "-static" ) ; }
233
238
fn args ( & mut self , args : & [ String ] ) { self . cmd . args ( args) ; }
234
239
235
- fn link_rust_dylib ( & mut self , lib : & str , _path : & Path ) {
240
+ fn link_rust_dylib ( & mut self , lib : Symbol , _path : & Path ) {
236
241
self . hint_dynamic ( ) ;
237
242
self . cmd . arg ( format ! ( "-l{}" , lib) ) ;
238
243
}
239
244
240
- fn link_framework ( & mut self , framework : & str ) {
245
+ fn link_framework ( & mut self , framework : Symbol ) {
241
246
self . hint_dynamic ( ) ;
242
- self . cmd . arg ( "-framework" ) . arg ( framework) ;
247
+ self . cmd . arg ( "-framework" ) . sym_arg ( framework) ;
243
248
}
244
249
245
250
// Here we explicitly ask that the entire archive is included into the
@@ -248,7 +253,7 @@ impl<'a> Linker for GccLinker<'a> {
248
253
// don't otherwise explicitly reference them. This can occur for
249
254
// libraries which are just providing bindings, libraries with generic
250
255
// functions, etc.
251
- fn link_whole_staticlib ( & mut self , lib : & str , search_path : & [ PathBuf ] ) {
256
+ fn link_whole_staticlib ( & mut self , lib : Symbol , search_path : & [ PathBuf ] ) {
252
257
self . hint_static ( ) ;
253
258
let target = & self . sess . target . target ;
254
259
if !target. options . is_like_osx {
@@ -539,11 +544,11 @@ impl<'a> Linker for MsvcLinker<'a> {
539
544
}
540
545
}
541
546
542
- fn link_dylib ( & mut self , lib : & str ) {
547
+ fn link_dylib ( & mut self , lib : Symbol ) {
543
548
self . cmd . arg ( & format ! ( "{}.lib" , lib) ) ;
544
549
}
545
550
546
- fn link_rust_dylib ( & mut self , lib : & str , path : & Path ) {
551
+ fn link_rust_dylib ( & mut self , lib : Symbol , path : & Path ) {
547
552
// When producing a dll, the MSVC linker may not actually emit a
548
553
// `foo.lib` file if the dll doesn't actually export any symbols, so we
549
554
// check to see if the file is there and just omit linking to it if it's
@@ -554,7 +559,7 @@ impl<'a> Linker for MsvcLinker<'a> {
554
559
}
555
560
}
556
561
557
- fn link_staticlib ( & mut self , lib : & str ) {
562
+ fn link_staticlib ( & mut self , lib : Symbol ) {
558
563
self . cmd . arg ( & format ! ( "{}.lib" , lib) ) ;
559
564
}
560
565
@@ -605,11 +610,11 @@ impl<'a> Linker for MsvcLinker<'a> {
605
610
fn framework_path ( & mut self , _path : & Path ) {
606
611
bug ! ( "frameworks are not supported on windows" )
607
612
}
608
- fn link_framework ( & mut self , _framework : & str ) {
613
+ fn link_framework ( & mut self , _framework : Symbol ) {
609
614
bug ! ( "frameworks are not supported on windows" )
610
615
}
611
616
612
- fn link_whole_staticlib ( & mut self , lib : & str , _search_path : & [ PathBuf ] ) {
617
+ fn link_whole_staticlib ( & mut self , lib : Symbol , _search_path : & [ PathBuf ] ) {
613
618
// not supported?
614
619
self . link_staticlib ( lib) ;
615
620
}
@@ -740,8 +745,8 @@ impl<'a> Linker for EmLinker<'a> {
740
745
self . cmd . arg ( "-L" ) . arg ( path) ;
741
746
}
742
747
743
- fn link_staticlib ( & mut self , lib : & str ) {
744
- self . cmd . arg ( "-l" ) . arg ( lib) ;
748
+ fn link_staticlib ( & mut self , lib : Symbol ) {
749
+ self . cmd . arg ( "-l" ) . sym_arg ( lib) ;
745
750
}
746
751
747
752
fn output_filename ( & mut self , path : & Path ) {
@@ -752,12 +757,12 @@ impl<'a> Linker for EmLinker<'a> {
752
757
self . cmd . arg ( path) ;
753
758
}
754
759
755
- fn link_dylib ( & mut self , lib : & str ) {
760
+ fn link_dylib ( & mut self , lib : Symbol ) {
756
761
// Emscripten always links statically
757
762
self . link_staticlib ( lib) ;
758
763
}
759
764
760
- fn link_whole_staticlib ( & mut self , lib : & str , _search_path : & [ PathBuf ] ) {
765
+ fn link_whole_staticlib ( & mut self , lib : Symbol , _search_path : & [ PathBuf ] ) {
761
766
// not supported?
762
767
self . link_staticlib ( lib) ;
763
768
}
@@ -767,7 +772,7 @@ impl<'a> Linker for EmLinker<'a> {
767
772
self . link_rlib ( lib) ;
768
773
}
769
774
770
- fn link_rust_dylib ( & mut self , lib : & str , _path : & Path ) {
775
+ fn link_rust_dylib ( & mut self , lib : Symbol , _path : & Path ) {
771
776
self . link_dylib ( lib) ;
772
777
}
773
778
@@ -803,7 +808,7 @@ impl<'a> Linker for EmLinker<'a> {
803
808
bug ! ( "frameworks are not supported on Emscripten" )
804
809
}
805
810
806
- fn link_framework ( & mut self , _framework : & str ) {
811
+ fn link_framework ( & mut self , _framework : Symbol ) {
807
812
bug ! ( "frameworks are not supported on Emscripten" )
808
813
}
809
814
@@ -948,12 +953,12 @@ impl<'a> WasmLd<'a> {
948
953
}
949
954
950
955
impl < ' a > Linker for WasmLd < ' a > {
951
- fn link_dylib ( & mut self , lib : & str ) {
952
- self . cmd . arg ( "-l" ) . arg ( lib) ;
956
+ fn link_dylib ( & mut self , lib : Symbol ) {
957
+ self . cmd . arg ( "-l" ) . sym_arg ( lib) ;
953
958
}
954
959
955
- fn link_staticlib ( & mut self , lib : & str ) {
956
- self . cmd . arg ( "-l" ) . arg ( lib) ;
960
+ fn link_staticlib ( & mut self , lib : Symbol ) {
961
+ self . cmd . arg ( "-l" ) . sym_arg ( lib) ;
957
962
}
958
963
959
964
fn link_rlib ( & mut self , lib : & Path ) {
@@ -995,16 +1000,16 @@ impl<'a> Linker for WasmLd<'a> {
995
1000
self . cmd . args ( args) ;
996
1001
}
997
1002
998
- fn link_rust_dylib ( & mut self , lib : & str , _path : & Path ) {
999
- self . cmd . arg ( "-l" ) . arg ( lib) ;
1003
+ fn link_rust_dylib ( & mut self , lib : Symbol , _path : & Path ) {
1004
+ self . cmd . arg ( "-l" ) . sym_arg ( lib) ;
1000
1005
}
1001
1006
1002
- fn link_framework ( & mut self , _framework : & str ) {
1007
+ fn link_framework ( & mut self , _framework : Symbol ) {
1003
1008
panic ! ( "frameworks not supported" )
1004
1009
}
1005
1010
1006
- fn link_whole_staticlib ( & mut self , lib : & str , _search_path : & [ PathBuf ] ) {
1007
- self . cmd . arg ( "-l" ) . arg ( lib) ;
1011
+ fn link_whole_staticlib ( & mut self , lib : Symbol , _search_path : & [ PathBuf ] ) {
1012
+ self . cmd . arg ( "-l" ) . sym_arg ( lib) ;
1008
1013
}
1009
1014
1010
1015
fn link_whole_rlib ( & mut self , lib : & Path ) {
@@ -1162,27 +1167,27 @@ impl<'a> Linker for PtxLinker<'a> {
1162
1167
:: std:: mem:: replace ( & mut self . cmd , Command :: new ( "" ) )
1163
1168
}
1164
1169
1165
- fn link_dylib ( & mut self , _lib : & str ) {
1170
+ fn link_dylib ( & mut self , _lib : Symbol ) {
1166
1171
panic ! ( "external dylibs not supported" )
1167
1172
}
1168
1173
1169
- fn link_rust_dylib ( & mut self , _lib : & str , _path : & Path ) {
1174
+ fn link_rust_dylib ( & mut self , _lib : Symbol , _path : & Path ) {
1170
1175
panic ! ( "external dylibs not supported" )
1171
1176
}
1172
1177
1173
- fn link_staticlib ( & mut self , _lib : & str ) {
1178
+ fn link_staticlib ( & mut self , _lib : Symbol ) {
1174
1179
panic ! ( "staticlibs not supported" )
1175
1180
}
1176
1181
1177
- fn link_whole_staticlib ( & mut self , _lib : & str , _search_path : & [ PathBuf ] ) {
1182
+ fn link_whole_staticlib ( & mut self , _lib : Symbol , _search_path : & [ PathBuf ] ) {
1178
1183
panic ! ( "staticlibs not supported" )
1179
1184
}
1180
1185
1181
1186
fn framework_path ( & mut self , _path : & Path ) {
1182
1187
panic ! ( "frameworks not supported" )
1183
1188
}
1184
1189
1185
- fn link_framework ( & mut self , _framework : & str ) {
1190
+ fn link_framework ( & mut self , _framework : Symbol ) {
1186
1191
panic ! ( "frameworks not supported" )
1187
1192
}
1188
1193
0 commit comments