@@ -337,12 +337,7 @@ pub(crate) trait Linker {
337337 fn debuginfo ( & mut self , strip : Strip , natvis_debugger_visualizers : & [ PathBuf ] ) ;
338338 fn no_crt_objects ( & mut self ) ;
339339 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 ] ) ;
346341 fn subsystem ( & mut self , subsystem : & str ) ;
347342 fn linker_plugin_lto ( & mut self ) ;
348343 fn add_eh_frame_header ( & mut self ) { }
@@ -775,12 +770,7 @@ impl<'a> Linker for GccLinker<'a> {
775770 }
776771 }
777772
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 ] ) {
784774 // Symbol visibility in object files typically takes care of this.
785775 if crate_type == CrateType :: Executable {
786776 let should_export_executable_symbols =
@@ -809,7 +799,7 @@ impl<'a> Linker for GccLinker<'a> {
809799 // Write a plain, newline-separated list of symbols
810800 let res: io:: Result < ( ) > = try {
811801 let mut f = File :: create_buffered ( & path) ?;
812- for ( sym, _ ) in symbols {
802+ for sym in symbols {
813803 debug ! ( " _{sym}" ) ;
814804 writeln ! ( f, "_{sym}" ) ?;
815805 }
@@ -824,12 +814,11 @@ impl<'a> Linker for GccLinker<'a> {
824814 // .def file similar to MSVC one but without LIBRARY section
825815 // because LD doesn't like when it's empty
826816 writeln ! ( f, "EXPORTS" ) ?;
827- for ( symbol, kind) in symbols {
828- let kind_marker = if * kind == SymbolExportKind :: Data { " DATA" } else { "" } ;
817+ for symbol in symbols {
829818 debug ! ( " _{symbol}" ) ;
830819 // Quote the name in case it's reserved by linker in some way
831820 // (this accounts for names with dots in particular).
832- writeln ! ( f, " \" {symbol}\" {kind_marker} " ) ?;
821+ writeln ! ( f, " \" {symbol}\" " ) ?;
833822 }
834823 } ;
835824 if let Err ( error) = res {
@@ -842,7 +831,7 @@ impl<'a> Linker for GccLinker<'a> {
842831 writeln ! ( f, "{{" ) ?;
843832 if !symbols. is_empty ( ) {
844833 writeln ! ( f, " global:" ) ?;
845- for ( sym, _ ) in symbols {
834+ for sym in symbols {
846835 debug ! ( " {sym};" ) ;
847836 writeln ! ( f, " {sym};" ) ?;
848837 }
@@ -1109,12 +1098,7 @@ impl<'a> Linker for MsvcLinker<'a> {
11091098 // crates. Upstream rlibs may be linked statically to this dynamic library,
11101099 // in which case they may continue to transitively be used and hence need
11111100 // 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 ] ) {
11181102 // Symbol visibility takes care of this typically
11191103 if crate_type == CrateType :: Executable {
11201104 let should_export_executable_symbols =
@@ -1132,10 +1116,9 @@ impl<'a> Linker for MsvcLinker<'a> {
11321116 // straight to exports.
11331117 writeln ! ( f, "LIBRARY" ) ?;
11341118 writeln ! ( f, "EXPORTS" ) ?;
1135- for ( symbol, kind) in symbols {
1136- let kind_marker = if * kind == SymbolExportKind :: Data { " DATA" } else { "" } ;
1119+ for symbol in symbols {
11371120 debug ! ( " _{symbol}" ) ;
1138- writeln ! ( f, " {symbol}{kind_marker} " ) ?;
1121+ writeln ! ( f, " {symbol}" ) ?;
11391122 }
11401123 } ;
11411124 if let Err ( error) = res {
@@ -1276,19 +1259,14 @@ impl<'a> Linker for EmLinker<'a> {
12761259 self . cc_arg ( "-nodefaultlibs" ) ;
12771260 }
12781261
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 ] ) {
12851263 debug ! ( "EXPORTED SYMBOLS:" ) ;
12861264
12871265 self . cc_arg ( "-s" ) ;
12881266
12891267 let mut arg = OsString :: from ( "EXPORTED_FUNCTIONS=" ) ;
12901268 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 < _ > > ( ) ,
12921270 )
12931271 . unwrap ( ) ;
12941272 debug ! ( "{encoded}" ) ;
@@ -1450,13 +1428,8 @@ impl<'a> Linker for WasmLd<'a> {
14501428
14511429 fn no_default_libraries ( & mut self ) { }
14521430
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 {
14601433 self . link_args ( & [ "--export" , sym] ) ;
14611434 }
14621435
@@ -1590,7 +1563,7 @@ impl<'a> Linker for L4Bender<'a> {
15901563 self . cc_arg ( "-nostdlib" ) ;
15911564 }
15921565
1593- fn export_symbols ( & mut self , _: & Path , _: CrateType , _: & [ ( String , SymbolExportKind ) ] ) {
1566+ fn export_symbols ( & mut self , _: & Path , _: CrateType , _: & [ String ] ) {
15941567 // ToDo, not implemented, copy from GCC
15951568 self . sess . dcx ( ) . emit_warn ( errors:: L4BenderExportingSymbolsUnimplemented ) ;
15961569 }
@@ -1747,17 +1720,12 @@ impl<'a> Linker for AixLinker<'a> {
17471720
17481721 fn no_default_libraries ( & mut self ) { }
17491722
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 ] ) {
17561724 let path = tmpdir. join ( "list.exp" ) ;
17571725 let res: io:: Result < ( ) > = try {
17581726 let mut f = File :: create_buffered ( & path) ?;
17591727 // FIXME: use llvm-nm to generate export list.
1760- for ( symbol, _ ) in symbols {
1728+ for symbol in symbols {
17611729 debug ! ( " _{symbol}" ) ;
17621730 writeln ! ( f, " {symbol}" ) ?;
17631731 }
@@ -1801,12 +1769,9 @@ fn for_each_exported_symbols_include_dep<'tcx>(
18011769 }
18021770}
18031771
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 > {
18081773 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 ( ) ;
18101775 }
18111776
18121777 if let CrateType :: ProcMacro = crate_type {
@@ -1816,29 +1781,25 @@ pub(crate) fn exported_symbols(
18161781 }
18171782}
18181783
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 > {
18231785 let mut symbols = Vec :: new ( ) ;
18241786 let export_threshold = symbol_export:: crates_export_threshold ( & [ crate_type] ) ;
18251787 for_each_exported_symbols_include_dep ( tcx, crate_type, |symbol, info, cnum| {
18261788 // Do not export mangled symbols from cdylibs and don't attempt to export compiler-builtins
18271789 // from any cdylib. The latter doesn't work anyway as we use hidden visibility for
18281790 // compiler-builtins. Most linkers silently ignore it, but ld64 gives a warning.
18291791 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,
18331794 ) ) ;
1834- symbol_export:: extend_exported_symbols ( & mut symbols, tcx, symbol, info , cnum) ;
1795+ symbol_export:: extend_exported_symbols ( & mut symbols, tcx, symbol, cnum) ;
18351796 }
18361797 } ) ;
18371798
18381799 symbols
18391800}
18401801
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 > {
18421803 // `exported_symbols` will be empty when !should_codegen.
18431804 if !tcx. sess . opts . output_types . should_codegen ( ) {
18441805 return Vec :: new ( ) ;
@@ -1848,10 +1809,7 @@ fn exported_symbols_for_proc_macro_crate(tcx: TyCtxt<'_>) -> Vec<(String, Symbol
18481809 let proc_macro_decls_name = tcx. sess . generate_proc_macro_decls_symbol ( stable_crate_id) ;
18491810 let metadata_symbol_name = exported_symbols:: metadata_symbol_name ( tcx) ;
18501811
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]
18551813}
18561814
18571815pub ( crate ) fn linked_symbols (
@@ -1873,9 +1831,7 @@ pub(crate) fn linked_symbols(
18731831 || info. used
18741832 {
18751833 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) ,
18791835 info. kind ,
18801836 ) ) ;
18811837 }
@@ -1950,13 +1906,7 @@ impl<'a> Linker for PtxLinker<'a> {
19501906
19511907 fn ehcont_guard ( & mut self ) { }
19521908
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 ] ) { }
19601910
19611911 fn subsystem ( & mut self , _subsystem : & str ) { }
19621912
@@ -2025,15 +1975,10 @@ impl<'a> Linker for LlbcLinker<'a> {
20251975
20261976 fn ehcont_guard ( & mut self ) { }
20271977
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 ] ) {
20341979 match _crate_type {
20351980 CrateType :: Cdylib => {
2036- for ( sym, _ ) in symbols {
1981+ for sym in symbols {
20371982 self . link_args ( & [ "--export-symbol" , sym] ) ;
20381983 }
20391984 }
@@ -2107,16 +2052,11 @@ impl<'a> Linker for BpfLinker<'a> {
21072052
21082053 fn ehcont_guard ( & mut self ) { }
21092054
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 ] ) {
21162056 let path = tmpdir. join ( "symbols" ) ;
21172057 let res: io:: Result < ( ) > = try {
21182058 let mut f = File :: create_buffered ( & path) ?;
2119- for ( sym, _ ) in symbols {
2059+ for sym in symbols {
21202060 writeln ! ( f, "{sym}" ) ?;
21212061 }
21222062 } ;
0 commit comments