@@ -16,7 +16,6 @@ use rustc_middle::middle::exported_symbols::{ExportedSymbol, SymbolExportInfo, S
16
16
use rustc_middle:: ty:: TyCtxt ;
17
17
use rustc_session:: config:: { self , CrateType , DebugInfo , LinkerPluginLto , Lto , OptLevel , Strip } ;
18
18
use rustc_session:: Session ;
19
- use rustc_span:: symbol:: Symbol ;
20
19
use rustc_target:: spec:: { LinkOutputKind , LinkerFlavor , LldFlavor } ;
21
20
22
21
use cc:: windows_registry;
@@ -163,13 +162,13 @@ pub fn get_linker<'a>(
163
162
pub trait Linker {
164
163
fn cmd ( & mut self ) -> & mut Command ;
165
164
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 ) ;
170
169
fn link_rlib ( & mut self , lib : & Path ) ;
171
170
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 ] ) ;
173
172
fn include_path ( & mut self , path : & Path ) ;
174
173
fn framework_path ( & mut self , path : & Path ) ;
175
174
fn output_filename ( & mut self , path : & Path ) ;
@@ -423,8 +422,8 @@ impl<'a> Linker for GccLinker<'a> {
423
422
}
424
423
}
425
424
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" {
428
427
// libc will be added via late_link_args on illumos so that it will
429
428
// appear last in the library search order.
430
429
// FIXME: This should be replaced by a more complete and generic
@@ -454,7 +453,7 @@ impl<'a> Linker for GccLinker<'a> {
454
453
}
455
454
}
456
455
}
457
- fn link_staticlib ( & mut self , lib : Symbol , verbatim : bool ) {
456
+ fn link_staticlib ( & mut self , lib : & str , verbatim : bool ) {
458
457
self . hint_static ( ) ;
459
458
self . cmd . arg ( format ! ( "-l{}{}" , if verbatim { ":" } else { "" } , lib) ) ;
460
459
}
@@ -484,20 +483,20 @@ impl<'a> Linker for GccLinker<'a> {
484
483
self . linker_arg ( "-znorelro" ) ;
485
484
}
486
485
487
- fn link_rust_dylib ( & mut self , lib : Symbol , _path : & Path ) {
486
+ fn link_rust_dylib ( & mut self , lib : & str , _path : & Path ) {
488
487
self . hint_dynamic ( ) ;
489
488
self . cmd . arg ( format ! ( "-l{}" , lib) ) ;
490
489
}
491
490
492
- fn link_framework ( & mut self , framework : Symbol , as_needed : bool ) {
491
+ fn link_framework ( & mut self , framework : & str , as_needed : bool ) {
493
492
self . hint_dynamic ( ) ;
494
493
if !as_needed {
495
494
// FIXME(81490): ld64 as of macOS 11 supports the -needed_framework
496
495
// 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);
498
497
self . sess . warn ( "`as-needed` modifier not implemented yet for ld64" ) ;
499
498
}
500
- self . cmd . arg ( "-framework" ) . sym_arg ( framework) ;
499
+ self . cmd . arg ( "-framework" ) . arg ( framework) ;
501
500
}
502
501
503
502
// Here we explicitly ask that the entire archive is included into the
@@ -506,7 +505,7 @@ impl<'a> Linker for GccLinker<'a> {
506
505
// don't otherwise explicitly reference them. This can occur for
507
506
// libraries which are just providing bindings, libraries with generic
508
507
// 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 ] ) {
510
509
self . hint_static ( ) ;
511
510
let target = & self . sess . target ;
512
511
if !target. is_like_osx {
@@ -836,11 +835,11 @@ impl<'a> Linker for MsvcLinker<'a> {
836
835
self . cmd . arg ( "/OPT:NOREF,NOICF" ) ;
837
836
}
838
837
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 ) {
840
839
self . cmd . arg ( format ! ( "{}{}" , lib, if verbatim { "" } else { ".lib" } ) ) ;
841
840
}
842
841
843
- fn link_rust_dylib ( & mut self , lib : Symbol , path : & Path ) {
842
+ fn link_rust_dylib ( & mut self , lib : & str , path : & Path ) {
844
843
// When producing a dll, the MSVC linker may not actually emit a
845
844
// `foo.lib` file if the dll doesn't actually export any symbols, so we
846
845
// 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> {
851
850
}
852
851
}
853
852
854
- fn link_staticlib ( & mut self , lib : Symbol , verbatim : bool ) {
853
+ fn link_staticlib ( & mut self , lib : & str , verbatim : bool ) {
855
854
self . cmd . arg ( format ! ( "{}{}" , lib, if verbatim { "" } else { ".lib" } ) ) ;
856
855
}
857
856
@@ -890,11 +889,11 @@ impl<'a> Linker for MsvcLinker<'a> {
890
889
fn framework_path ( & mut self , _path : & Path ) {
891
890
bug ! ( "frameworks are not supported on windows" )
892
891
}
893
- fn link_framework ( & mut self , _framework : Symbol , _as_needed : bool ) {
892
+ fn link_framework ( & mut self , _framework : & str , _as_needed : bool ) {
894
893
bug ! ( "frameworks are not supported on windows" )
895
894
}
896
895
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 ] ) {
898
897
self . cmd . arg ( format ! ( "/WHOLEARCHIVE:{}{}" , lib, if verbatim { "" } else { ".lib" } ) ) ;
899
898
}
900
899
fn link_whole_rlib ( & mut self , path : & Path ) {
@@ -1047,8 +1046,8 @@ impl<'a> Linker for EmLinker<'a> {
1047
1046
self . cmd . arg ( "-L" ) . arg ( path) ;
1048
1047
}
1049
1048
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) ;
1052
1051
}
1053
1052
1054
1053
fn output_filename ( & mut self , path : & Path ) {
@@ -1059,12 +1058,12 @@ impl<'a> Linker for EmLinker<'a> {
1059
1058
self . cmd . arg ( path) ;
1060
1059
}
1061
1060
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 ) {
1063
1062
// Emscripten always links statically
1064
1063
self . link_staticlib ( lib, verbatim) ;
1065
1064
}
1066
1065
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 ] ) {
1068
1067
// not supported?
1069
1068
self . link_staticlib ( lib, verbatim) ;
1070
1069
}
@@ -1074,7 +1073,7 @@ impl<'a> Linker for EmLinker<'a> {
1074
1073
self . link_rlib ( lib) ;
1075
1074
}
1076
1075
1077
- fn link_rust_dylib ( & mut self , lib : Symbol , _path : & Path ) {
1076
+ fn link_rust_dylib ( & mut self , lib : & str , _path : & Path ) {
1078
1077
self . link_dylib ( lib, false , true ) ;
1079
1078
}
1080
1079
@@ -1098,7 +1097,7 @@ impl<'a> Linker for EmLinker<'a> {
1098
1097
bug ! ( "frameworks are not supported on Emscripten" )
1099
1098
}
1100
1099
1101
- fn link_framework ( & mut self , _framework : Symbol , _as_needed : bool ) {
1100
+ fn link_framework ( & mut self , _framework : & str , _as_needed : bool ) {
1102
1101
bug ! ( "frameworks are not supported on Emscripten" )
1103
1102
}
1104
1103
@@ -1237,12 +1236,12 @@ impl<'a> Linker for WasmLd<'a> {
1237
1236
}
1238
1237
}
1239
1238
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) ;
1242
1241
}
1243
1242
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) ;
1246
1245
}
1247
1246
1248
1247
fn link_rlib ( & mut self , lib : & Path ) {
@@ -1271,16 +1270,16 @@ impl<'a> Linker for WasmLd<'a> {
1271
1270
1272
1271
fn no_relro ( & mut self ) { }
1273
1272
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) ;
1276
1275
}
1277
1276
1278
- fn link_framework ( & mut self , _framework : Symbol , _as_needed : bool ) {
1277
+ fn link_framework ( & mut self , _framework : & str , _as_needed : bool ) {
1279
1278
panic ! ( "frameworks not supported" )
1280
1279
}
1281
1280
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) ;
1284
1283
}
1285
1284
1286
1285
fn link_whole_rlib ( & mut self , lib : & Path ) {
@@ -1360,10 +1359,10 @@ pub struct L4Bender<'a> {
1360
1359
}
1361
1360
1362
1361
impl < ' 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 ) {
1364
1363
bug ! ( "dylibs are not supported on L4Re" ) ;
1365
1364
}
1366
- fn link_staticlib ( & mut self , lib : Symbol , _verbatim : bool ) {
1365
+ fn link_staticlib ( & mut self , lib : & str , _verbatim : bool ) {
1367
1366
self . hint_static ( ) ;
1368
1367
self . cmd . arg ( format ! ( "-PC{}" , lib) ) ;
1369
1368
}
@@ -1404,15 +1403,15 @@ impl<'a> Linker for L4Bender<'a> {
1404
1403
1405
1404
fn set_output_kind ( & mut self , _output_kind : LinkOutputKind , _out_filename : & Path ) { }
1406
1405
1407
- fn link_rust_dylib ( & mut self , _: Symbol , _: & Path ) {
1406
+ fn link_rust_dylib ( & mut self , _: & str , _: & Path ) {
1408
1407
panic ! ( "Rust dylibs not supported" ) ;
1409
1408
}
1410
1409
1411
- fn link_framework ( & mut self , _framework : Symbol , _as_needed : bool ) {
1410
+ fn link_framework ( & mut self , _framework : & str , _as_needed : bool ) {
1412
1411
bug ! ( "frameworks not supported on L4Re" ) ;
1413
1412
}
1414
1413
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 ] ) {
1416
1415
self . hint_static ( ) ;
1417
1416
self . cmd . arg ( "--whole-archive" ) . arg ( format ! ( "-l{}" , lib) ) ;
1418
1417
self . cmd . arg ( "--no-whole-archive" ) ;
@@ -1617,27 +1616,27 @@ impl<'a> Linker for PtxLinker<'a> {
1617
1616
self . cmd . arg ( "-o" ) . arg ( path) ;
1618
1617
}
1619
1618
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 ) {
1621
1620
panic ! ( "external dylibs not supported" )
1622
1621
}
1623
1622
1624
- fn link_rust_dylib ( & mut self , _lib : Symbol , _path : & Path ) {
1623
+ fn link_rust_dylib ( & mut self , _lib : & str , _path : & Path ) {
1625
1624
panic ! ( "external dylibs not supported" )
1626
1625
}
1627
1626
1628
- fn link_staticlib ( & mut self , _lib : Symbol , _verbatim : bool ) {
1627
+ fn link_staticlib ( & mut self , _lib : & str , _verbatim : bool ) {
1629
1628
panic ! ( "staticlibs not supported" )
1630
1629
}
1631
1630
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 ] ) {
1633
1632
panic ! ( "staticlibs not supported" )
1634
1633
}
1635
1634
1636
1635
fn framework_path ( & mut self , _path : & Path ) {
1637
1636
panic ! ( "frameworks not supported" )
1638
1637
}
1639
1638
1640
- fn link_framework ( & mut self , _framework : Symbol , _as_needed : bool ) {
1639
+ fn link_framework ( & mut self , _framework : & str , _as_needed : bool ) {
1641
1640
panic ! ( "frameworks not supported" )
1642
1641
}
1643
1642
@@ -1717,27 +1716,27 @@ impl<'a> Linker for BpfLinker<'a> {
1717
1716
self . cmd . arg ( "-o" ) . arg ( path) ;
1718
1717
}
1719
1718
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 ) {
1721
1720
panic ! ( "external dylibs not supported" )
1722
1721
}
1723
1722
1724
- fn link_rust_dylib ( & mut self , _lib : Symbol , _path : & Path ) {
1723
+ fn link_rust_dylib ( & mut self , _lib : & str , _path : & Path ) {
1725
1724
panic ! ( "external dylibs not supported" )
1726
1725
}
1727
1726
1728
- fn link_staticlib ( & mut self , _lib : Symbol , _verbatim : bool ) {
1727
+ fn link_staticlib ( & mut self , _lib : & str , _verbatim : bool ) {
1729
1728
panic ! ( "staticlibs not supported" )
1730
1729
}
1731
1730
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 ] ) {
1733
1732
panic ! ( "staticlibs not supported" )
1734
1733
}
1735
1734
1736
1735
fn framework_path ( & mut self , _path : & Path ) {
1737
1736
panic ! ( "frameworks not supported" )
1738
1737
}
1739
1738
1740
- fn link_framework ( & mut self , _framework : Symbol , _as_needed : bool ) {
1739
+ fn link_framework ( & mut self , _framework : & str , _as_needed : bool ) {
1741
1740
panic ! ( "frameworks not supported" )
1742
1741
}
1743
1742
0 commit comments