@@ -16,7 +16,6 @@ use rustc_middle::middle::exported_symbols::{ExportedSymbol, SymbolExportInfo, S
1616use rustc_middle:: ty:: TyCtxt ;
1717use rustc_session:: config:: { self , CrateType , DebugInfo , LinkerPluginLto , Lto , OptLevel , Strip } ;
1818use rustc_session:: Session ;
19- use rustc_span:: symbol:: Symbol ;
2019use rustc_target:: spec:: { LinkOutputKind , LinkerFlavor , LldFlavor } ;
2120
2221use cc:: windows_registry;
@@ -163,13 +162,13 @@ pub fn get_linker<'a>(
163162pub trait Linker {
164163 fn cmd ( & mut self ) -> & mut Command ;
165164 fn set_output_kind ( & mut self , output_kind : LinkOutputKind , out_filename : & Path ) ;
166- fn link_dylib ( & mut self , lib : Symbol , verbatim : bool , as_needed : bool ) ;
167- fn link_rust_dylib ( & mut self , lib : Symbol , path : & Path ) ;
168- fn link_framework ( & mut self , framework : Symbol , as_needed : bool ) ;
169- fn link_staticlib ( & mut self , lib : Symbol , verbatim : bool ) ;
165+ fn link_dylib ( & mut self , lib : & str , verbatim : bool , as_needed : bool ) ;
166+ fn link_rust_dylib ( & mut self , lib : & str , path : & Path ) ;
167+ fn link_framework ( & mut self , framework : & str , as_needed : bool ) ;
168+ fn link_staticlib ( & mut self , lib : & str , verbatim : bool ) ;
170169 fn link_rlib ( & mut self , lib : & Path ) ;
171170 fn link_whole_rlib ( & mut self , lib : & Path ) ;
172- fn link_whole_staticlib ( & mut self , lib : Symbol , verbatim : bool , search_path : & [ PathBuf ] ) ;
171+ fn link_whole_staticlib ( & mut self , lib : & str , verbatim : bool , search_path : & [ PathBuf ] ) ;
173172 fn include_path ( & mut self , path : & Path ) ;
174173 fn framework_path ( & mut self , path : & Path ) ;
175174 fn output_filename ( & mut self , path : & Path ) ;
@@ -423,8 +422,8 @@ impl<'a> Linker for GccLinker<'a> {
423422 }
424423 }
425424
426- fn link_dylib ( & mut self , lib : Symbol , verbatim : bool , as_needed : bool ) {
427- if self . sess . target . os == "illumos" && lib. as_str ( ) == "c" {
425+ fn link_dylib ( & mut self , lib : & str , verbatim : bool , as_needed : bool ) {
426+ if self . sess . target . os == "illumos" && lib == "c" {
428427 // libc will be added via late_link_args on illumos so that it will
429428 // appear last in the library search order.
430429 // FIXME: This should be replaced by a more complete and generic
@@ -454,7 +453,7 @@ impl<'a> Linker for GccLinker<'a> {
454453 }
455454 }
456455 }
457- fn link_staticlib ( & mut self , lib : Symbol , verbatim : bool ) {
456+ fn link_staticlib ( & mut self , lib : & str , verbatim : bool ) {
458457 self . hint_static ( ) ;
459458 self . cmd . arg ( format ! ( "-l{}{}" , if verbatim { ":" } else { "" } , lib) ) ;
460459 }
@@ -484,20 +483,20 @@ impl<'a> Linker for GccLinker<'a> {
484483 self . linker_arg ( "-znorelro" ) ;
485484 }
486485
487- fn link_rust_dylib ( & mut self , lib : Symbol , _path : & Path ) {
486+ fn link_rust_dylib ( & mut self , lib : & str , _path : & Path ) {
488487 self . hint_dynamic ( ) ;
489488 self . cmd . arg ( format ! ( "-l{}" , lib) ) ;
490489 }
491490
492- fn link_framework ( & mut self , framework : Symbol , as_needed : bool ) {
491+ fn link_framework ( & mut self , framework : & str , as_needed : bool ) {
493492 self . hint_dynamic ( ) ;
494493 if !as_needed {
495494 // FIXME(81490): ld64 as of macOS 11 supports the -needed_framework
496495 // flag but we have no way to detect that here.
497- // self.cmd.arg("-needed_framework").sym_arg (framework);
496+ // self.cmd.arg("-needed_framework").arg (framework);
498497 self . sess . warn ( "`as-needed` modifier not implemented yet for ld64" ) ;
499498 }
500- self . cmd . arg ( "-framework" ) . sym_arg ( framework) ;
499+ self . cmd . arg ( "-framework" ) . arg ( framework) ;
501500 }
502501
503502 // Here we explicitly ask that the entire archive is included into the
@@ -506,7 +505,7 @@ impl<'a> Linker for GccLinker<'a> {
506505 // don't otherwise explicitly reference them. This can occur for
507506 // libraries which are just providing bindings, libraries with generic
508507 // functions, etc.
509- fn link_whole_staticlib ( & mut self , lib : Symbol , verbatim : bool , search_path : & [ PathBuf ] ) {
508+ fn link_whole_staticlib ( & mut self , lib : & str , verbatim : bool , search_path : & [ PathBuf ] ) {
510509 self . hint_static ( ) ;
511510 let target = & self . sess . target ;
512511 if !target. is_like_osx {
@@ -836,11 +835,11 @@ impl<'a> Linker for MsvcLinker<'a> {
836835 self . cmd . arg ( "/OPT:NOREF,NOICF" ) ;
837836 }
838837
839- fn link_dylib ( & mut self , lib : Symbol , verbatim : bool , _as_needed : bool ) {
838+ fn link_dylib ( & mut self , lib : & str , verbatim : bool , _as_needed : bool ) {
840839 self . cmd . arg ( format ! ( "{}{}" , lib, if verbatim { "" } else { ".lib" } ) ) ;
841840 }
842841
843- fn link_rust_dylib ( & mut self , lib : Symbol , path : & Path ) {
842+ fn link_rust_dylib ( & mut self , lib : & str , path : & Path ) {
844843 // When producing a dll, the MSVC linker may not actually emit a
845844 // `foo.lib` file if the dll doesn't actually export any symbols, so we
846845 // check to see if the file is there and just omit linking to it if it's
@@ -851,7 +850,7 @@ impl<'a> Linker for MsvcLinker<'a> {
851850 }
852851 }
853852
854- fn link_staticlib ( & mut self , lib : Symbol , verbatim : bool ) {
853+ fn link_staticlib ( & mut self , lib : & str , verbatim : bool ) {
855854 self . cmd . arg ( format ! ( "{}{}" , lib, if verbatim { "" } else { ".lib" } ) ) ;
856855 }
857856
@@ -890,11 +889,11 @@ impl<'a> Linker for MsvcLinker<'a> {
890889 fn framework_path ( & mut self , _path : & Path ) {
891890 bug ! ( "frameworks are not supported on windows" )
892891 }
893- fn link_framework ( & mut self , _framework : Symbol , _as_needed : bool ) {
892+ fn link_framework ( & mut self , _framework : & str , _as_needed : bool ) {
894893 bug ! ( "frameworks are not supported on windows" )
895894 }
896895
897- fn link_whole_staticlib ( & mut self , lib : Symbol , verbatim : bool , _search_path : & [ PathBuf ] ) {
896+ fn link_whole_staticlib ( & mut self , lib : & str , verbatim : bool , _search_path : & [ PathBuf ] ) {
898897 self . cmd . arg ( format ! ( "/WHOLEARCHIVE:{}{}" , lib, if verbatim { "" } else { ".lib" } ) ) ;
899898 }
900899 fn link_whole_rlib ( & mut self , path : & Path ) {
@@ -1047,8 +1046,8 @@ impl<'a> Linker for EmLinker<'a> {
10471046 self . cmd . arg ( "-L" ) . arg ( path) ;
10481047 }
10491048
1050- fn link_staticlib ( & mut self , lib : Symbol , _verbatim : bool ) {
1051- self . cmd . arg ( "-l" ) . sym_arg ( lib) ;
1049+ fn link_staticlib ( & mut self , lib : & str , _verbatim : bool ) {
1050+ self . cmd . arg ( "-l" ) . arg ( lib) ;
10521051 }
10531052
10541053 fn output_filename ( & mut self , path : & Path ) {
@@ -1059,12 +1058,12 @@ impl<'a> Linker for EmLinker<'a> {
10591058 self . cmd . arg ( path) ;
10601059 }
10611060
1062- fn link_dylib ( & mut self , lib : Symbol , verbatim : bool , _as_needed : bool ) {
1061+ fn link_dylib ( & mut self , lib : & str , verbatim : bool , _as_needed : bool ) {
10631062 // Emscripten always links statically
10641063 self . link_staticlib ( lib, verbatim) ;
10651064 }
10661065
1067- fn link_whole_staticlib ( & mut self , lib : Symbol , verbatim : bool , _search_path : & [ PathBuf ] ) {
1066+ fn link_whole_staticlib ( & mut self , lib : & str , verbatim : bool , _search_path : & [ PathBuf ] ) {
10681067 // not supported?
10691068 self . link_staticlib ( lib, verbatim) ;
10701069 }
@@ -1074,7 +1073,7 @@ impl<'a> Linker for EmLinker<'a> {
10741073 self . link_rlib ( lib) ;
10751074 }
10761075
1077- fn link_rust_dylib ( & mut self , lib : Symbol , _path : & Path ) {
1076+ fn link_rust_dylib ( & mut self , lib : & str , _path : & Path ) {
10781077 self . link_dylib ( lib, false , true ) ;
10791078 }
10801079
@@ -1098,7 +1097,7 @@ impl<'a> Linker for EmLinker<'a> {
10981097 bug ! ( "frameworks are not supported on Emscripten" )
10991098 }
11001099
1101- fn link_framework ( & mut self , _framework : Symbol , _as_needed : bool ) {
1100+ fn link_framework ( & mut self , _framework : & str , _as_needed : bool ) {
11021101 bug ! ( "frameworks are not supported on Emscripten" )
11031102 }
11041103
@@ -1237,12 +1236,12 @@ impl<'a> Linker for WasmLd<'a> {
12371236 }
12381237 }
12391238
1240- fn link_dylib ( & mut self , lib : Symbol , _verbatim : bool , _as_needed : bool ) {
1241- self . cmd . arg ( "-l" ) . sym_arg ( lib) ;
1239+ fn link_dylib ( & mut self , lib : & str , _verbatim : bool , _as_needed : bool ) {
1240+ self . cmd . arg ( "-l" ) . arg ( lib) ;
12421241 }
12431242
1244- fn link_staticlib ( & mut self , lib : Symbol , _verbatim : bool ) {
1245- self . cmd . arg ( "-l" ) . sym_arg ( lib) ;
1243+ fn link_staticlib ( & mut self , lib : & str , _verbatim : bool ) {
1244+ self . cmd . arg ( "-l" ) . arg ( lib) ;
12461245 }
12471246
12481247 fn link_rlib ( & mut self , lib : & Path ) {
@@ -1271,16 +1270,16 @@ impl<'a> Linker for WasmLd<'a> {
12711270
12721271 fn no_relro ( & mut self ) { }
12731272
1274- fn link_rust_dylib ( & mut self , lib : Symbol , _path : & Path ) {
1275- self . cmd . arg ( "-l" ) . sym_arg ( lib) ;
1273+ fn link_rust_dylib ( & mut self , lib : & str , _path : & Path ) {
1274+ self . cmd . arg ( "-l" ) . arg ( lib) ;
12761275 }
12771276
1278- fn link_framework ( & mut self , _framework : Symbol , _as_needed : bool ) {
1277+ fn link_framework ( & mut self , _framework : & str , _as_needed : bool ) {
12791278 panic ! ( "frameworks not supported" )
12801279 }
12811280
1282- fn link_whole_staticlib ( & mut self , lib : Symbol , _verbatim : bool , _search_path : & [ PathBuf ] ) {
1283- self . cmd . arg ( "-l" ) . sym_arg ( lib) ;
1281+ fn link_whole_staticlib ( & mut self , lib : & str , _verbatim : bool , _search_path : & [ PathBuf ] ) {
1282+ self . cmd . arg ( "-l" ) . arg ( lib) ;
12841283 }
12851284
12861285 fn link_whole_rlib ( & mut self , lib : & Path ) {
@@ -1360,10 +1359,10 @@ pub struct L4Bender<'a> {
13601359}
13611360
13621361impl < ' a > Linker for L4Bender < ' a > {
1363- fn link_dylib ( & mut self , _lib : Symbol , _verbatim : bool , _as_needed : bool ) {
1362+ fn link_dylib ( & mut self , _lib : & str , _verbatim : bool , _as_needed : bool ) {
13641363 bug ! ( "dylibs are not supported on L4Re" ) ;
13651364 }
1366- fn link_staticlib ( & mut self , lib : Symbol , _verbatim : bool ) {
1365+ fn link_staticlib ( & mut self , lib : & str , _verbatim : bool ) {
13671366 self . hint_static ( ) ;
13681367 self . cmd . arg ( format ! ( "-PC{}" , lib) ) ;
13691368 }
@@ -1404,15 +1403,15 @@ impl<'a> Linker for L4Bender<'a> {
14041403
14051404 fn set_output_kind ( & mut self , _output_kind : LinkOutputKind , _out_filename : & Path ) { }
14061405
1407- fn link_rust_dylib ( & mut self , _: Symbol , _: & Path ) {
1406+ fn link_rust_dylib ( & mut self , _: & str , _: & Path ) {
14081407 panic ! ( "Rust dylibs not supported" ) ;
14091408 }
14101409
1411- fn link_framework ( & mut self , _framework : Symbol , _as_needed : bool ) {
1410+ fn link_framework ( & mut self , _framework : & str , _as_needed : bool ) {
14121411 bug ! ( "frameworks not supported on L4Re" ) ;
14131412 }
14141413
1415- fn link_whole_staticlib ( & mut self , lib : Symbol , _verbatim : bool , _search_path : & [ PathBuf ] ) {
1414+ fn link_whole_staticlib ( & mut self , lib : & str , _verbatim : bool , _search_path : & [ PathBuf ] ) {
14161415 self . hint_static ( ) ;
14171416 self . cmd . arg ( "--whole-archive" ) . arg ( format ! ( "-l{}" , lib) ) ;
14181417 self . cmd . arg ( "--no-whole-archive" ) ;
@@ -1617,27 +1616,27 @@ impl<'a> Linker for PtxLinker<'a> {
16171616 self . cmd . arg ( "-o" ) . arg ( path) ;
16181617 }
16191618
1620- fn link_dylib ( & mut self , _lib : Symbol , _verbatim : bool , _as_needed : bool ) {
1619+ fn link_dylib ( & mut self , _lib : & str , _verbatim : bool , _as_needed : bool ) {
16211620 panic ! ( "external dylibs not supported" )
16221621 }
16231622
1624- fn link_rust_dylib ( & mut self , _lib : Symbol , _path : & Path ) {
1623+ fn link_rust_dylib ( & mut self , _lib : & str , _path : & Path ) {
16251624 panic ! ( "external dylibs not supported" )
16261625 }
16271626
1628- fn link_staticlib ( & mut self , _lib : Symbol , _verbatim : bool ) {
1627+ fn link_staticlib ( & mut self , _lib : & str , _verbatim : bool ) {
16291628 panic ! ( "staticlibs not supported" )
16301629 }
16311630
1632- fn link_whole_staticlib ( & mut self , _lib : Symbol , _verbatim : bool , _search_path : & [ PathBuf ] ) {
1631+ fn link_whole_staticlib ( & mut self , _lib : & str , _verbatim : bool , _search_path : & [ PathBuf ] ) {
16331632 panic ! ( "staticlibs not supported" )
16341633 }
16351634
16361635 fn framework_path ( & mut self , _path : & Path ) {
16371636 panic ! ( "frameworks not supported" )
16381637 }
16391638
1640- fn link_framework ( & mut self , _framework : Symbol , _as_needed : bool ) {
1639+ fn link_framework ( & mut self , _framework : & str , _as_needed : bool ) {
16411640 panic ! ( "frameworks not supported" )
16421641 }
16431642
@@ -1717,27 +1716,27 @@ impl<'a> Linker for BpfLinker<'a> {
17171716 self . cmd . arg ( "-o" ) . arg ( path) ;
17181717 }
17191718
1720- fn link_dylib ( & mut self , _lib : Symbol , _verbatim : bool , _as_needed : bool ) {
1719+ fn link_dylib ( & mut self , _lib : & str , _verbatim : bool , _as_needed : bool ) {
17211720 panic ! ( "external dylibs not supported" )
17221721 }
17231722
1724- fn link_rust_dylib ( & mut self , _lib : Symbol , _path : & Path ) {
1723+ fn link_rust_dylib ( & mut self , _lib : & str , _path : & Path ) {
17251724 panic ! ( "external dylibs not supported" )
17261725 }
17271726
1728- fn link_staticlib ( & mut self , _lib : Symbol , _verbatim : bool ) {
1727+ fn link_staticlib ( & mut self , _lib : & str , _verbatim : bool ) {
17291728 panic ! ( "staticlibs not supported" )
17301729 }
17311730
1732- fn link_whole_staticlib ( & mut self , _lib : Symbol , _verbatim : bool , _search_path : & [ PathBuf ] ) {
1731+ fn link_whole_staticlib ( & mut self , _lib : & str , _verbatim : bool , _search_path : & [ PathBuf ] ) {
17331732 panic ! ( "staticlibs not supported" )
17341733 }
17351734
17361735 fn framework_path ( & mut self , _path : & Path ) {
17371736 panic ! ( "frameworks not supported" )
17381737 }
17391738
1740- fn link_framework ( & mut self , _framework : Symbol , _as_needed : bool ) {
1739+ fn link_framework ( & mut self , _framework : & str , _as_needed : bool ) {
17411740 panic ! ( "frameworks not supported" )
17421741 }
17431742
0 commit comments