@@ -17,6 +17,7 @@ use rustc::session::config::{self, CrateType, OptLevel, DebugInfo,
1717use rustc:: ty:: TyCtxt ;
1818use rustc_target:: spec:: { LinkerFlavor , LldFlavor } ;
1919use rustc_serialize:: { json, Encoder } ;
20+ use syntax:: symbol:: Symbol ;
2021
2122/// For all the linkers we support, and information they might
2223/// need out of the shared crate context before we get rid of it.
@@ -99,13 +100,13 @@ impl LinkerInfo {
99100/// used to dispatch on whether a GNU-like linker (generally `ld.exe`) or an
100101/// MSVC linker (e.g., `link.exe`) is being used.
101102pub 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 ) ;
106107 fn link_rlib ( & mut self , lib : & Path ) ;
107108 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 ] ) ;
109110 fn include_path ( & mut self , path : & Path ) ;
110111 fn framework_path ( & mut self , path : & Path ) ;
111112 fn output_filename ( & mut self , path : & Path ) ;
@@ -215,9 +216,13 @@ impl<'a> GccLinker<'a> {
215216}
216217
217218impl < ' 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) ) ;
221226 }
222227 fn link_rlib ( & mut self , lib : & Path ) { self . hint_static ( ) ; self . cmd . arg ( lib) ; }
223228 fn include_path ( & mut self , path : & Path ) { self . cmd . arg ( "-L" ) . arg ( path) ; }
@@ -232,14 +237,14 @@ impl<'a> Linker for GccLinker<'a> {
232237 fn build_static_executable ( & mut self ) { self . cmd . arg ( "-static" ) ; }
233238 fn args ( & mut self , args : & [ String ] ) { self . cmd . args ( args) ; }
234239
235- fn link_rust_dylib ( & mut self , lib : & str , _path : & Path ) {
240+ fn link_rust_dylib ( & mut self , lib : Symbol , _path : & Path ) {
236241 self . hint_dynamic ( ) ;
237242 self . cmd . arg ( format ! ( "-l{}" , lib) ) ;
238243 }
239244
240- fn link_framework ( & mut self , framework : & str ) {
245+ fn link_framework ( & mut self , framework : Symbol ) {
241246 self . hint_dynamic ( ) ;
242- self . cmd . arg ( "-framework" ) . arg ( framework) ;
247+ self . cmd . arg ( "-framework" ) . sym_arg ( framework) ;
243248 }
244249
245250 // Here we explicitly ask that the entire archive is included into the
@@ -248,7 +253,7 @@ impl<'a> Linker for GccLinker<'a> {
248253 // don't otherwise explicitly reference them. This can occur for
249254 // libraries which are just providing bindings, libraries with generic
250255 // 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 ] ) {
252257 self . hint_static ( ) ;
253258 let target = & self . sess . target . target ;
254259 if !target. options . is_like_osx {
@@ -539,11 +544,11 @@ impl<'a> Linker for MsvcLinker<'a> {
539544 }
540545 }
541546
542- fn link_dylib ( & mut self , lib : & str ) {
547+ fn link_dylib ( & mut self , lib : Symbol ) {
543548 self . cmd . arg ( & format ! ( "{}.lib" , lib) ) ;
544549 }
545550
546- fn link_rust_dylib ( & mut self , lib : & str , path : & Path ) {
551+ fn link_rust_dylib ( & mut self , lib : Symbol , path : & Path ) {
547552 // When producing a dll, the MSVC linker may not actually emit a
548553 // `foo.lib` file if the dll doesn't actually export any symbols, so we
549554 // 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> {
554559 }
555560 }
556561
557- fn link_staticlib ( & mut self , lib : & str ) {
562+ fn link_staticlib ( & mut self , lib : Symbol ) {
558563 self . cmd . arg ( & format ! ( "{}.lib" , lib) ) ;
559564 }
560565
@@ -605,11 +610,11 @@ impl<'a> Linker for MsvcLinker<'a> {
605610 fn framework_path ( & mut self , _path : & Path ) {
606611 bug ! ( "frameworks are not supported on windows" )
607612 }
608- fn link_framework ( & mut self , _framework : & str ) {
613+ fn link_framework ( & mut self , _framework : Symbol ) {
609614 bug ! ( "frameworks are not supported on windows" )
610615 }
611616
612- fn link_whole_staticlib ( & mut self , lib : & str , _search_path : & [ PathBuf ] ) {
617+ fn link_whole_staticlib ( & mut self , lib : Symbol , _search_path : & [ PathBuf ] ) {
613618 // not supported?
614619 self . link_staticlib ( lib) ;
615620 }
@@ -740,8 +745,8 @@ impl<'a> Linker for EmLinker<'a> {
740745 self . cmd . arg ( "-L" ) . arg ( path) ;
741746 }
742747
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) ;
745750 }
746751
747752 fn output_filename ( & mut self , path : & Path ) {
@@ -752,12 +757,12 @@ impl<'a> Linker for EmLinker<'a> {
752757 self . cmd . arg ( path) ;
753758 }
754759
755- fn link_dylib ( & mut self , lib : & str ) {
760+ fn link_dylib ( & mut self , lib : Symbol ) {
756761 // Emscripten always links statically
757762 self . link_staticlib ( lib) ;
758763 }
759764
760- fn link_whole_staticlib ( & mut self , lib : & str , _search_path : & [ PathBuf ] ) {
765+ fn link_whole_staticlib ( & mut self , lib : Symbol , _search_path : & [ PathBuf ] ) {
761766 // not supported?
762767 self . link_staticlib ( lib) ;
763768 }
@@ -767,7 +772,7 @@ impl<'a> Linker for EmLinker<'a> {
767772 self . link_rlib ( lib) ;
768773 }
769774
770- fn link_rust_dylib ( & mut self , lib : & str , _path : & Path ) {
775+ fn link_rust_dylib ( & mut self , lib : Symbol , _path : & Path ) {
771776 self . link_dylib ( lib) ;
772777 }
773778
@@ -803,7 +808,7 @@ impl<'a> Linker for EmLinker<'a> {
803808 bug ! ( "frameworks are not supported on Emscripten" )
804809 }
805810
806- fn link_framework ( & mut self , _framework : & str ) {
811+ fn link_framework ( & mut self , _framework : Symbol ) {
807812 bug ! ( "frameworks are not supported on Emscripten" )
808813 }
809814
@@ -948,12 +953,12 @@ impl<'a> WasmLd<'a> {
948953}
949954
950955impl < ' 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) ;
953958 }
954959
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) ;
957962 }
958963
959964 fn link_rlib ( & mut self , lib : & Path ) {
@@ -995,16 +1000,16 @@ impl<'a> Linker for WasmLd<'a> {
9951000 self . cmd . args ( args) ;
9961001 }
9971002
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) ;
10001005 }
10011006
1002- fn link_framework ( & mut self , _framework : & str ) {
1007+ fn link_framework ( & mut self , _framework : Symbol ) {
10031008 panic ! ( "frameworks not supported" )
10041009 }
10051010
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) ;
10081013 }
10091014
10101015 fn link_whole_rlib ( & mut self , lib : & Path ) {
@@ -1162,27 +1167,27 @@ impl<'a> Linker for PtxLinker<'a> {
11621167 :: std:: mem:: replace ( & mut self . cmd , Command :: new ( "" ) )
11631168 }
11641169
1165- fn link_dylib ( & mut self , _lib : & str ) {
1170+ fn link_dylib ( & mut self , _lib : Symbol ) {
11661171 panic ! ( "external dylibs not supported" )
11671172 }
11681173
1169- fn link_rust_dylib ( & mut self , _lib : & str , _path : & Path ) {
1174+ fn link_rust_dylib ( & mut self , _lib : Symbol , _path : & Path ) {
11701175 panic ! ( "external dylibs not supported" )
11711176 }
11721177
1173- fn link_staticlib ( & mut self , _lib : & str ) {
1178+ fn link_staticlib ( & mut self , _lib : Symbol ) {
11741179 panic ! ( "staticlibs not supported" )
11751180 }
11761181
1177- fn link_whole_staticlib ( & mut self , _lib : & str , _search_path : & [ PathBuf ] ) {
1182+ fn link_whole_staticlib ( & mut self , _lib : Symbol , _search_path : & [ PathBuf ] ) {
11781183 panic ! ( "staticlibs not supported" )
11791184 }
11801185
11811186 fn framework_path ( & mut self , _path : & Path ) {
11821187 panic ! ( "frameworks not supported" )
11831188 }
11841189
1185- fn link_framework ( & mut self , _framework : & str ) {
1190+ fn link_framework ( & mut self , _framework : Symbol ) {
11861191 panic ! ( "frameworks not supported" )
11871192 }
11881193
0 commit comments