@@ -166,9 +166,10 @@ pub fn get_linker<'a>(
166
166
pub trait Linker {
167
167
fn cmd ( & mut self ) -> & mut Command ;
168
168
fn set_output_kind ( & mut self , output_kind : LinkOutputKind , out_filename : & Path ) ;
169
- fn link_dylib ( & mut self , lib : & str , verbatim : bool , as_needed : bool ) ;
170
- fn link_rust_dylib ( & mut self , lib : & str , path : & Path ) ;
171
- fn link_framework ( & mut self , framework : & str , as_needed : bool ) ;
169
+ fn link_dylib_by_name ( & mut self , name : & str , verbatim : bool , as_needed : bool ) ;
170
+ fn link_framework_by_name ( & mut self , _name : & str , _verbatim : bool , _as_needed : bool ) {
171
+ bug ! ( "framework linked with unsupported linker" )
172
+ }
172
173
fn link_staticlib ( & mut self , lib : & str , verbatim : bool ) ;
173
174
fn link_rlib ( & mut self , lib : & Path ) ;
174
175
fn link_whole_rlib ( & mut self , lib : & Path ) ;
@@ -432,8 +433,8 @@ impl<'a> Linker for GccLinker<'a> {
432
433
}
433
434
}
434
435
435
- fn link_dylib ( & mut self , lib : & str , verbatim : bool , as_needed : bool ) {
436
- if self . sess . target . os == "illumos" && lib == "c" {
436
+ fn link_dylib_by_name ( & mut self , name : & str , verbatim : bool , as_needed : bool ) {
437
+ if self . sess . target . os == "illumos" && name == "c" {
437
438
// libc will be added via late_link_args on illumos so that it will
438
439
// appear last in the library search order.
439
440
// FIXME: This should be replaced by a more complete and generic
@@ -454,7 +455,7 @@ impl<'a> Linker for GccLinker<'a> {
454
455
}
455
456
}
456
457
self . hint_dynamic ( ) ;
457
- self . cmd . arg ( format ! ( "-l{}{lib }" , if verbatim && self . is_gnu { ":" } else { "" } , ) ) ;
458
+ self . cmd . arg ( format ! ( "-l{}{name }" , if verbatim && self . is_gnu { ":" } else { "" } , ) ) ;
458
459
if !as_needed {
459
460
if self . sess . target . is_like_osx {
460
461
// See above FIXME comment
@@ -493,20 +494,15 @@ impl<'a> Linker for GccLinker<'a> {
493
494
self . linker_args ( & [ "-z" , "norelro" ] ) ;
494
495
}
495
496
496
- fn link_rust_dylib ( & mut self , lib : & str , _path : & Path ) {
497
- self . hint_dynamic ( ) ;
498
- self . cmd . arg ( format ! ( "-l{lib}" ) ) ;
499
- }
500
-
501
- fn link_framework ( & mut self , framework : & str , as_needed : bool ) {
497
+ fn link_framework_by_name ( & mut self , name : & str , _verbatim : bool , as_needed : bool ) {
502
498
self . hint_dynamic ( ) ;
503
499
if !as_needed {
504
500
// FIXME(81490): ld64 as of macOS 11 supports the -needed_framework
505
501
// flag but we have no way to detect that here.
506
- // self.cmd.arg("-needed_framework").arg(framework );
502
+ // self.cmd.arg("-needed_framework").arg(name );
507
503
self . sess . dcx ( ) . emit_warn ( errors:: Ld64UnimplementedModifier ) ;
508
504
}
509
- self . cmd . arg ( "-framework" ) . arg ( framework ) ;
505
+ self . cmd . arg ( "-framework" ) . arg ( name ) ;
510
506
}
511
507
512
508
// Here we explicitly ask that the entire archive is included into the
@@ -845,19 +841,8 @@ impl<'a> Linker for MsvcLinker<'a> {
845
841
self . cmd . arg ( "/OPT:NOREF,NOICF" ) ;
846
842
}
847
843
848
- fn link_dylib ( & mut self , lib : & str , verbatim : bool , _as_needed : bool ) {
849
- self . cmd . arg ( format ! ( "{}{}" , lib, if verbatim { "" } else { ".lib" } ) ) ;
850
- }
851
-
852
- fn link_rust_dylib ( & mut self , lib : & str , path : & Path ) {
853
- // When producing a dll, the MSVC linker may not actually emit a
854
- // `foo.lib` file if the dll doesn't actually export any symbols, so we
855
- // check to see if the file is there and just omit linking to it if it's
856
- // not present.
857
- let name = format ! ( "{lib}.dll.lib" ) ;
858
- if path. join ( & name) . exists ( ) {
859
- self . cmd . arg ( name) ;
860
- }
844
+ fn link_dylib_by_name ( & mut self , name : & str , verbatim : bool , _as_needed : bool ) {
845
+ self . cmd . arg ( format ! ( "{}{}" , name, if verbatim { "" } else { ".lib" } ) ) ;
861
846
}
862
847
863
848
fn link_staticlib ( & mut self , lib : & str , verbatim : bool ) {
@@ -899,9 +884,6 @@ impl<'a> Linker for MsvcLinker<'a> {
899
884
fn framework_path ( & mut self , _path : & Path ) {
900
885
bug ! ( "frameworks are not supported on windows" )
901
886
}
902
- fn link_framework ( & mut self , _framework : & str , _as_needed : bool ) {
903
- bug ! ( "frameworks are not supported on windows" )
904
- }
905
887
906
888
fn link_whole_staticlib ( & mut self , lib : & str , verbatim : bool , _search_path : & [ PathBuf ] ) {
907
889
self . cmd . arg ( format ! ( "/WHOLEARCHIVE:{}{}" , lib, if verbatim { "" } else { ".lib" } ) ) ;
@@ -1073,9 +1055,9 @@ impl<'a> Linker for EmLinker<'a> {
1073
1055
self . cmd . arg ( path) ;
1074
1056
}
1075
1057
1076
- fn link_dylib ( & mut self , lib : & str , verbatim : bool , _as_needed : bool ) {
1058
+ fn link_dylib_by_name ( & mut self , name : & str , verbatim : bool , _as_needed : bool ) {
1077
1059
// Emscripten always links statically
1078
- self . link_staticlib ( lib , verbatim) ;
1060
+ self . link_staticlib ( name , verbatim) ;
1079
1061
}
1080
1062
1081
1063
fn link_whole_staticlib ( & mut self , lib : & str , verbatim : bool , _search_path : & [ PathBuf ] ) {
@@ -1088,10 +1070,6 @@ impl<'a> Linker for EmLinker<'a> {
1088
1070
self . link_rlib ( lib) ;
1089
1071
}
1090
1072
1091
- fn link_rust_dylib ( & mut self , lib : & str , _path : & Path ) {
1092
- self . link_dylib ( lib, false , true ) ;
1093
- }
1094
-
1095
1073
fn link_rlib ( & mut self , lib : & Path ) {
1096
1074
self . add_object ( lib) ;
1097
1075
}
@@ -1112,10 +1090,6 @@ impl<'a> Linker for EmLinker<'a> {
1112
1090
bug ! ( "frameworks are not supported on Emscripten" )
1113
1091
}
1114
1092
1115
- fn link_framework ( & mut self , _framework : & str , _as_needed : bool ) {
1116
- bug ! ( "frameworks are not supported on Emscripten" )
1117
- }
1118
-
1119
1093
fn gc_sections ( & mut self , _keep_metadata : bool ) {
1120
1094
// noop
1121
1095
}
@@ -1249,8 +1223,8 @@ impl<'a> Linker for WasmLd<'a> {
1249
1223
}
1250
1224
}
1251
1225
1252
- fn link_dylib ( & mut self , lib : & str , _verbatim : bool , _as_needed : bool ) {
1253
- self . cmd . arg ( "-l" ) . arg ( lib ) ;
1226
+ fn link_dylib_by_name ( & mut self , name : & str , _verbatim : bool , _as_needed : bool ) {
1227
+ self . cmd . arg ( "-l" ) . arg ( name ) ;
1254
1228
}
1255
1229
1256
1230
fn link_staticlib ( & mut self , lib : & str , _verbatim : bool ) {
@@ -1283,14 +1257,6 @@ impl<'a> Linker for WasmLd<'a> {
1283
1257
1284
1258
fn no_relro ( & mut self ) { }
1285
1259
1286
- fn link_rust_dylib ( & mut self , lib : & str , _path : & Path ) {
1287
- self . cmd . arg ( "-l" ) . arg ( lib) ;
1288
- }
1289
-
1290
- fn link_framework ( & mut self , _framework : & str , _as_needed : bool ) {
1291
- panic ! ( "frameworks not supported" )
1292
- }
1293
-
1294
1260
fn link_whole_staticlib ( & mut self , lib : & str , _verbatim : bool , _search_path : & [ PathBuf ] ) {
1295
1261
self . cmd . arg ( "--whole-archive" ) . arg ( "-l" ) . arg ( lib) . arg ( "--no-whole-archive" ) ;
1296
1262
}
@@ -1398,7 +1364,7 @@ pub struct L4Bender<'a> {
1398
1364
}
1399
1365
1400
1366
impl < ' a > Linker for L4Bender < ' a > {
1401
- fn link_dylib ( & mut self , _lib : & str , _verbatim : bool , _as_needed : bool ) {
1367
+ fn link_dylib_by_name ( & mut self , _name : & str , _verbatim : bool , _as_needed : bool ) {
1402
1368
bug ! ( "dylibs are not supported on L4Re" ) ;
1403
1369
}
1404
1370
fn link_staticlib ( & mut self , lib : & str , _verbatim : bool ) {
@@ -1442,14 +1408,6 @@ impl<'a> Linker for L4Bender<'a> {
1442
1408
1443
1409
fn set_output_kind ( & mut self , _output_kind : LinkOutputKind , _out_filename : & Path ) { }
1444
1410
1445
- fn link_rust_dylib ( & mut self , _: & str , _: & Path ) {
1446
- panic ! ( "Rust dylibs not supported" ) ;
1447
- }
1448
-
1449
- fn link_framework ( & mut self , _framework : & str , _as_needed : bool ) {
1450
- bug ! ( "frameworks not supported on L4Re" ) ;
1451
- }
1452
-
1453
1411
fn link_whole_staticlib ( & mut self , lib : & str , _verbatim : bool , _search_path : & [ PathBuf ] ) {
1454
1412
self . hint_static ( ) ;
1455
1413
self . cmd . arg ( "--whole-archive" ) . arg ( format ! ( "-l{lib}" ) ) ;
@@ -1571,9 +1529,9 @@ impl<'a> AixLinker<'a> {
1571
1529
}
1572
1530
1573
1531
impl < ' a > Linker for AixLinker < ' a > {
1574
- fn link_dylib ( & mut self , lib : & str , _verbatim : bool , _as_needed : bool ) {
1532
+ fn link_dylib_by_name ( & mut self , name : & str , _verbatim : bool , _as_needed : bool ) {
1575
1533
self . hint_dynamic ( ) ;
1576
- self . cmd . arg ( format ! ( "-l{lib }" ) ) ;
1534
+ self . cmd . arg ( format ! ( "-l{name }" ) ) ;
1577
1535
}
1578
1536
1579
1537
fn link_staticlib ( & mut self , lib : & str , _verbatim : bool ) {
@@ -1626,15 +1584,6 @@ impl<'a> Linker for AixLinker<'a> {
1626
1584
}
1627
1585
}
1628
1586
1629
- fn link_rust_dylib ( & mut self , lib : & str , _: & Path ) {
1630
- self . hint_dynamic ( ) ;
1631
- self . cmd . arg ( format ! ( "-l{lib}" ) ) ;
1632
- }
1633
-
1634
- fn link_framework ( & mut self , _framework : & str , _as_needed : bool ) {
1635
- bug ! ( "frameworks not supported on AIX" ) ;
1636
- }
1637
-
1638
1587
fn link_whole_staticlib ( & mut self , lib : & str , verbatim : bool , search_path : & [ PathBuf ] ) {
1639
1588
self . hint_static ( ) ;
1640
1589
let lib = find_native_static_library ( lib, verbatim, search_path, self . sess ) ;
@@ -1844,11 +1793,7 @@ impl<'a> Linker for PtxLinker<'a> {
1844
1793
self . cmd . arg ( "-o" ) . arg ( path) ;
1845
1794
}
1846
1795
1847
- fn link_dylib ( & mut self , _lib : & str , _verbatim : bool , _as_needed : bool ) {
1848
- panic ! ( "external dylibs not supported" )
1849
- }
1850
-
1851
- fn link_rust_dylib ( & mut self , _lib : & str , _path : & Path ) {
1796
+ fn link_dylib_by_name ( & mut self , _name : & str , _verbatim : bool , _as_needed : bool ) {
1852
1797
panic ! ( "external dylibs not supported" )
1853
1798
}
1854
1799
@@ -1864,10 +1809,6 @@ impl<'a> Linker for PtxLinker<'a> {
1864
1809
panic ! ( "frameworks not supported" )
1865
1810
}
1866
1811
1867
- fn link_framework ( & mut self , _framework : & str , _as_needed : bool ) {
1868
- panic ! ( "frameworks not supported" )
1869
- }
1870
-
1871
1812
fn full_relro ( & mut self ) { }
1872
1813
1873
1814
fn partial_relro ( & mut self ) { }
@@ -1942,11 +1883,7 @@ impl<'a> Linker for BpfLinker<'a> {
1942
1883
self . cmd . arg ( "-o" ) . arg ( path) ;
1943
1884
}
1944
1885
1945
- fn link_dylib ( & mut self , _lib : & str , _verbatim : bool , _as_needed : bool ) {
1946
- panic ! ( "external dylibs not supported" )
1947
- }
1948
-
1949
- fn link_rust_dylib ( & mut self , _lib : & str , _path : & Path ) {
1886
+ fn link_dylib_by_name ( & mut self , _name : & str , _verbatim : bool , _as_needed : bool ) {
1950
1887
panic ! ( "external dylibs not supported" )
1951
1888
}
1952
1889
@@ -1962,10 +1899,6 @@ impl<'a> Linker for BpfLinker<'a> {
1962
1899
panic ! ( "frameworks not supported" )
1963
1900
}
1964
1901
1965
- fn link_framework ( & mut self , _framework : & str , _as_needed : bool ) {
1966
- panic ! ( "frameworks not supported" )
1967
- }
1968
-
1969
1902
fn full_relro ( & mut self ) { }
1970
1903
1971
1904
fn partial_relro ( & mut self ) { }
0 commit comments