@@ -337,12 +337,7 @@ pub(crate) trait Linker {
337
337
fn debuginfo ( & mut self , strip : Strip , natvis_debugger_visualizers : & [ PathBuf ] ) ;
338
338
fn no_crt_objects ( & mut self ) ;
339
339
fn no_default_libraries ( & mut self ) ;
340
- fn export_symbols (
341
- & mut self ,
342
- tmpdir : & Path ,
343
- crate_type : CrateType ,
344
- symbols : & [ ( String , SymbolExportKind ) ] ,
345
- ) ;
340
+ fn export_symbols ( & mut self , tmpdir : & Path , crate_type : CrateType , symbols : & [ String ] ) ;
346
341
fn subsystem ( & mut self , subsystem : & str ) ;
347
342
fn linker_plugin_lto ( & mut self ) ;
348
343
fn add_eh_frame_header ( & mut self ) { }
@@ -775,12 +770,7 @@ impl<'a> Linker for GccLinker<'a> {
775
770
}
776
771
}
777
772
778
- fn export_symbols (
779
- & mut self ,
780
- tmpdir : & Path ,
781
- crate_type : CrateType ,
782
- symbols : & [ ( String , SymbolExportKind ) ] ,
783
- ) {
773
+ fn export_symbols ( & mut self , tmpdir : & Path , crate_type : CrateType , symbols : & [ String ] ) {
784
774
// Symbol visibility in object files typically takes care of this.
785
775
if crate_type == CrateType :: Executable {
786
776
let should_export_executable_symbols =
@@ -809,7 +799,7 @@ impl<'a> Linker for GccLinker<'a> {
809
799
// Write a plain, newline-separated list of symbols
810
800
let res: io:: Result < ( ) > = try {
811
801
let mut f = File :: create_buffered ( & path) ?;
812
- for ( sym, _ ) in symbols {
802
+ for sym in symbols {
813
803
debug ! ( " _{sym}" ) ;
814
804
writeln ! ( f, "_{sym}" ) ?;
815
805
}
@@ -824,12 +814,11 @@ impl<'a> Linker for GccLinker<'a> {
824
814
// .def file similar to MSVC one but without LIBRARY section
825
815
// because LD doesn't like when it's empty
826
816
writeln ! ( f, "EXPORTS" ) ?;
827
- for ( symbol, kind) in symbols {
828
- let kind_marker = if * kind == SymbolExportKind :: Data { " DATA" } else { "" } ;
817
+ for symbol in symbols {
829
818
debug ! ( " _{symbol}" ) ;
830
819
// Quote the name in case it's reserved by linker in some way
831
820
// (this accounts for names with dots in particular).
832
- writeln ! ( f, " \" {symbol}\" {kind_marker} " ) ?;
821
+ writeln ! ( f, " \" {symbol}\" " ) ?;
833
822
}
834
823
} ;
835
824
if let Err ( error) = res {
@@ -842,7 +831,7 @@ impl<'a> Linker for GccLinker<'a> {
842
831
writeln ! ( f, "{{" ) ?;
843
832
if !symbols. is_empty ( ) {
844
833
writeln ! ( f, " global:" ) ?;
845
- for ( sym, _ ) in symbols {
834
+ for sym in symbols {
846
835
debug ! ( " {sym};" ) ;
847
836
writeln ! ( f, " {sym};" ) ?;
848
837
}
@@ -1109,12 +1098,7 @@ impl<'a> Linker for MsvcLinker<'a> {
1109
1098
// crates. Upstream rlibs may be linked statically to this dynamic library,
1110
1099
// in which case they may continue to transitively be used and hence need
1111
1100
// their symbols exported.
1112
- fn export_symbols (
1113
- & mut self ,
1114
- tmpdir : & Path ,
1115
- crate_type : CrateType ,
1116
- symbols : & [ ( String , SymbolExportKind ) ] ,
1117
- ) {
1101
+ fn export_symbols ( & mut self , tmpdir : & Path , crate_type : CrateType , symbols : & [ String ] ) {
1118
1102
// Symbol visibility takes care of this typically
1119
1103
if crate_type == CrateType :: Executable {
1120
1104
let should_export_executable_symbols =
@@ -1132,10 +1116,9 @@ impl<'a> Linker for MsvcLinker<'a> {
1132
1116
// straight to exports.
1133
1117
writeln ! ( f, "LIBRARY" ) ?;
1134
1118
writeln ! ( f, "EXPORTS" ) ?;
1135
- for ( symbol, kind) in symbols {
1136
- let kind_marker = if * kind == SymbolExportKind :: Data { " DATA" } else { "" } ;
1119
+ for symbol in symbols {
1137
1120
debug ! ( " _{symbol}" ) ;
1138
- writeln ! ( f, " {symbol}{kind_marker} " ) ?;
1121
+ writeln ! ( f, " {symbol}" ) ?;
1139
1122
}
1140
1123
} ;
1141
1124
if let Err ( error) = res {
@@ -1276,19 +1259,14 @@ impl<'a> Linker for EmLinker<'a> {
1276
1259
self . cc_arg ( "-nodefaultlibs" ) ;
1277
1260
}
1278
1261
1279
- fn export_symbols (
1280
- & mut self ,
1281
- _tmpdir : & Path ,
1282
- _crate_type : CrateType ,
1283
- symbols : & [ ( String , SymbolExportKind ) ] ,
1284
- ) {
1262
+ fn export_symbols ( & mut self , _tmpdir : & Path , _crate_type : CrateType , symbols : & [ String ] ) {
1285
1263
debug ! ( "EXPORTED SYMBOLS:" ) ;
1286
1264
1287
1265
self . cc_arg ( "-s" ) ;
1288
1266
1289
1267
let mut arg = OsString :: from ( "EXPORTED_FUNCTIONS=" ) ;
1290
1268
let encoded = serde_json:: to_string (
1291
- & symbols. iter ( ) . map ( |( sym, _ ) | "_" . to_owned ( ) + sym) . collect :: < Vec < _ > > ( ) ,
1269
+ & symbols. iter ( ) . map ( |sym| "_" . to_owned ( ) + sym) . collect :: < Vec < _ > > ( ) ,
1292
1270
)
1293
1271
. unwrap ( ) ;
1294
1272
debug ! ( "{encoded}" ) ;
@@ -1450,13 +1428,8 @@ impl<'a> Linker for WasmLd<'a> {
1450
1428
1451
1429
fn no_default_libraries ( & mut self ) { }
1452
1430
1453
- fn export_symbols (
1454
- & mut self ,
1455
- _tmpdir : & Path ,
1456
- _crate_type : CrateType ,
1457
- symbols : & [ ( String , SymbolExportKind ) ] ,
1458
- ) {
1459
- for ( sym, _) in symbols {
1431
+ fn export_symbols ( & mut self , _tmpdir : & Path , _crate_type : CrateType , symbols : & [ String ] ) {
1432
+ for sym in symbols {
1460
1433
self . link_args ( & [ "--export" , sym] ) ;
1461
1434
}
1462
1435
@@ -1590,7 +1563,7 @@ impl<'a> Linker for L4Bender<'a> {
1590
1563
self . cc_arg ( "-nostdlib" ) ;
1591
1564
}
1592
1565
1593
- fn export_symbols ( & mut self , _: & Path , _: CrateType , _: & [ ( String , SymbolExportKind ) ] ) {
1566
+ fn export_symbols ( & mut self , _: & Path , _: CrateType , _: & [ String ] ) {
1594
1567
// ToDo, not implemented, copy from GCC
1595
1568
self . sess . dcx ( ) . emit_warn ( errors:: L4BenderExportingSymbolsUnimplemented ) ;
1596
1569
}
@@ -1747,17 +1720,12 @@ impl<'a> Linker for AixLinker<'a> {
1747
1720
1748
1721
fn no_default_libraries ( & mut self ) { }
1749
1722
1750
- fn export_symbols (
1751
- & mut self ,
1752
- tmpdir : & Path ,
1753
- _crate_type : CrateType ,
1754
- symbols : & [ ( String , SymbolExportKind ) ] ,
1755
- ) {
1723
+ fn export_symbols ( & mut self , tmpdir : & Path , _crate_type : CrateType , symbols : & [ String ] ) {
1756
1724
let path = tmpdir. join ( "list.exp" ) ;
1757
1725
let res: io:: Result < ( ) > = try {
1758
1726
let mut f = File :: create_buffered ( & path) ?;
1759
1727
// FIXME: use llvm-nm to generate export list.
1760
- for ( symbol, _ ) in symbols {
1728
+ for symbol in symbols {
1761
1729
debug ! ( " _{symbol}" ) ;
1762
1730
writeln ! ( f, " {symbol}" ) ?;
1763
1731
}
@@ -1801,12 +1769,9 @@ fn for_each_exported_symbols_include_dep<'tcx>(
1801
1769
}
1802
1770
}
1803
1771
1804
- pub ( crate ) fn exported_symbols (
1805
- tcx : TyCtxt < ' _ > ,
1806
- crate_type : CrateType ,
1807
- ) -> Vec < ( String , SymbolExportKind ) > {
1772
+ pub ( crate ) fn exported_symbols ( tcx : TyCtxt < ' _ > , crate_type : CrateType ) -> Vec < String > {
1808
1773
if let Some ( ref exports) = tcx. sess . target . override_export_symbols {
1809
- return exports. iter ( ) . map ( |name| ( name . to_string ( ) , SymbolExportKind :: Text ) ) . collect ( ) ;
1774
+ return exports. iter ( ) . map ( ToString :: to_string ) . collect ( ) ;
1810
1775
}
1811
1776
1812
1777
if let CrateType :: ProcMacro = crate_type {
@@ -1816,29 +1781,25 @@ pub(crate) fn exported_symbols(
1816
1781
}
1817
1782
}
1818
1783
1819
- fn exported_symbols_for_non_proc_macro (
1820
- tcx : TyCtxt < ' _ > ,
1821
- crate_type : CrateType ,
1822
- ) -> Vec < ( String , SymbolExportKind ) > {
1784
+ fn exported_symbols_for_non_proc_macro ( tcx : TyCtxt < ' _ > , crate_type : CrateType ) -> Vec < String > {
1823
1785
let mut symbols = Vec :: new ( ) ;
1824
1786
let export_threshold = symbol_export:: crates_export_threshold ( & [ crate_type] ) ;
1825
1787
for_each_exported_symbols_include_dep ( tcx, crate_type, |symbol, info, cnum| {
1826
1788
// Do not export mangled symbols from cdylibs and don't attempt to export compiler-builtins
1827
1789
// from any cdylib. The latter doesn't work anyway as we use hidden visibility for
1828
1790
// compiler-builtins. Most linkers silently ignore it, but ld64 gives a warning.
1829
1791
if info. level . is_below_threshold ( export_threshold) && !tcx. is_compiler_builtins ( cnum) {
1830
- symbols. push ( (
1831
- symbol_export:: exporting_symbol_name_for_instance_in_crate ( tcx, symbol, cnum) ,
1832
- info. kind ,
1792
+ symbols. push ( symbol_export:: exporting_symbol_name_for_instance_in_crate (
1793
+ tcx, symbol, cnum,
1833
1794
) ) ;
1834
- symbol_export:: extend_exported_symbols ( & mut symbols, tcx, symbol, info , cnum) ;
1795
+ symbol_export:: extend_exported_symbols ( & mut symbols, tcx, symbol, cnum) ;
1835
1796
}
1836
1797
} ) ;
1837
1798
1838
1799
symbols
1839
1800
}
1840
1801
1841
- fn exported_symbols_for_proc_macro_crate ( tcx : TyCtxt < ' _ > ) -> Vec < ( String , SymbolExportKind ) > {
1802
+ fn exported_symbols_for_proc_macro_crate ( tcx : TyCtxt < ' _ > ) -> Vec < String > {
1842
1803
// `exported_symbols` will be empty when !should_codegen.
1843
1804
if !tcx. sess . opts . output_types . should_codegen ( ) {
1844
1805
return Vec :: new ( ) ;
@@ -1848,10 +1809,7 @@ fn exported_symbols_for_proc_macro_crate(tcx: TyCtxt<'_>) -> Vec<(String, Symbol
1848
1809
let proc_macro_decls_name = tcx. sess . generate_proc_macro_decls_symbol ( stable_crate_id) ;
1849
1810
let metadata_symbol_name = exported_symbols:: metadata_symbol_name ( tcx) ;
1850
1811
1851
- vec ! [
1852
- ( proc_macro_decls_name, SymbolExportKind :: Text ) ,
1853
- ( metadata_symbol_name, SymbolExportKind :: Text ) ,
1854
- ]
1812
+ vec ! [ proc_macro_decls_name, metadata_symbol_name]
1855
1813
}
1856
1814
1857
1815
pub ( crate ) fn linked_symbols (
@@ -1873,9 +1831,7 @@ pub(crate) fn linked_symbols(
1873
1831
|| info. used
1874
1832
{
1875
1833
symbols. push ( (
1876
- symbol_export:: linking_symbol_name_for_instance_in_crate (
1877
- tcx, symbol, info. kind , cnum,
1878
- ) ,
1834
+ symbol_export:: linking_symbol_name_for_instance_in_crate ( tcx, symbol, cnum) ,
1879
1835
info. kind ,
1880
1836
) ) ;
1881
1837
}
@@ -1950,13 +1906,7 @@ impl<'a> Linker for PtxLinker<'a> {
1950
1906
1951
1907
fn ehcont_guard ( & mut self ) { }
1952
1908
1953
- fn export_symbols (
1954
- & mut self ,
1955
- _tmpdir : & Path ,
1956
- _crate_type : CrateType ,
1957
- _symbols : & [ ( String , SymbolExportKind ) ] ,
1958
- ) {
1959
- }
1909
+ fn export_symbols ( & mut self , _tmpdir : & Path , _crate_type : CrateType , _symbols : & [ String ] ) { }
1960
1910
1961
1911
fn subsystem ( & mut self , _subsystem : & str ) { }
1962
1912
@@ -2025,15 +1975,10 @@ impl<'a> Linker for LlbcLinker<'a> {
2025
1975
2026
1976
fn ehcont_guard ( & mut self ) { }
2027
1977
2028
- fn export_symbols (
2029
- & mut self ,
2030
- _tmpdir : & Path ,
2031
- _crate_type : CrateType ,
2032
- symbols : & [ ( String , SymbolExportKind ) ] ,
2033
- ) {
1978
+ fn export_symbols ( & mut self , _tmpdir : & Path , _crate_type : CrateType , symbols : & [ String ] ) {
2034
1979
match _crate_type {
2035
1980
CrateType :: Cdylib => {
2036
- for ( sym, _ ) in symbols {
1981
+ for sym in symbols {
2037
1982
self . link_args ( & [ "--export-symbol" , sym] ) ;
2038
1983
}
2039
1984
}
@@ -2107,16 +2052,11 @@ impl<'a> Linker for BpfLinker<'a> {
2107
2052
2108
2053
fn ehcont_guard ( & mut self ) { }
2109
2054
2110
- fn export_symbols (
2111
- & mut self ,
2112
- tmpdir : & Path ,
2113
- _crate_type : CrateType ,
2114
- symbols : & [ ( String , SymbolExportKind ) ] ,
2115
- ) {
2055
+ fn export_symbols ( & mut self , tmpdir : & Path , _crate_type : CrateType , symbols : & [ String ] ) {
2116
2056
let path = tmpdir. join ( "symbols" ) ;
2117
2057
let res: io:: Result < ( ) > = try {
2118
2058
let mut f = File :: create_buffered ( & path) ?;
2119
- for ( sym, _ ) in symbols {
2059
+ for sym in symbols {
2120
2060
writeln ! ( f, "{sym}" ) ?;
2121
2061
}
2122
2062
} ;
0 commit comments