@@ -5,8 +5,8 @@ use std::time::{Duration, Instant};
55
66use itertools:: Itertools ;
77use rustc_abi:: FIRST_VARIANT ;
8- use rustc_ast:: expand:: allocator:: { ALLOCATOR_METHODS , AllocatorKind , global_fn_name } ;
9- use rustc_data_structures:: fx:: { FxHashMap , FxIndexSet } ;
8+ use rustc_ast:: expand:: allocator:: AllocatorKind ;
9+ use rustc_data_structures:: fx:: FxHashMap ;
1010use rustc_data_structures:: profiling:: { get_resident_set_size, print_time_passes_entry} ;
1111use rustc_data_structures:: sync:: par_map;
1212use rustc_data_structures:: unord:: UnordMap ;
@@ -16,23 +16,21 @@ use rustc_metadata::EncodedMetadata;
1616use rustc_middle:: bug;
1717use rustc_middle:: middle:: codegen_fn_attrs:: CodegenFnAttrs ;
1818use rustc_middle:: middle:: debugger_visualizer:: { DebuggerVisualizerFile , DebuggerVisualizerType } ;
19- use rustc_middle:: middle:: exported_symbols:: SymbolExportKind ;
20- use rustc_middle:: middle:: { exported_symbols, lang_items} ;
19+ use rustc_middle:: middle:: exported_symbols;
2120use rustc_middle:: mir:: BinOp ;
2221use rustc_middle:: mir:: mono:: { CodegenUnit , CodegenUnitNameBuilder , MonoItem , MonoItemPartitions } ;
2322use rustc_middle:: query:: Providers ;
2423use rustc_middle:: ty:: layout:: { HasTyCtxt , HasTypingEnv , LayoutOf , TyAndLayout } ;
2524use rustc_middle:: ty:: { self , Instance , Ty , TyCtxt } ;
2625use rustc_session:: Session ;
2726use rustc_session:: config:: { self , CrateType , EntryFnType , OutputType } ;
28- use rustc_span:: { DUMMY_SP , Symbol , sym} ;
27+ use rustc_span:: { DUMMY_SP , sym} ;
2928use rustc_trait_selection:: infer:: { BoundRegionConversionTime , TyCtxtInferExt } ;
3029use rustc_trait_selection:: traits:: { ObligationCause , ObligationCtxt } ;
3130use tracing:: { debug, info} ;
3231use { rustc_ast as ast, rustc_attr_parsing as attr} ;
3332
3433use crate :: assert_module_sources:: CguReuse ;
35- use crate :: back:: link:: are_upstream_rust_objects_already_included;
3634use crate :: back:: metadata:: create_compressed_metadata_file;
3735use crate :: back:: write:: {
3836 ComputedLtoType , OngoingCodegen , compute_per_cgu_lto_type, start_async_codegen,
@@ -872,8 +870,6 @@ impl CrateInfo {
872870 . iter ( )
873871 . map ( |& c| ( c, crate :: back:: linker:: exported_symbols ( tcx, c) ) )
874872 . collect ( ) ;
875- let linked_symbols =
876- crate_types. iter ( ) . map ( |& c| ( c, crate :: back:: linker:: linked_symbols ( tcx, c) ) ) . collect ( ) ;
877873 let local_crate_name = tcx. crate_name ( LOCAL_CRATE ) ;
878874 let crate_attrs = tcx. hir ( ) . attrs ( rustc_hir:: CRATE_HIR_ID ) ;
879875 let subsystem =
@@ -918,7 +914,6 @@ impl CrateInfo {
918914 target_features : tcx. global_backend_features ( ( ) ) . clone ( ) ,
919915 crate_types,
920916 exported_symbols,
921- linked_symbols,
922917 local_crate_name,
923918 compiler_builtins,
924919 profiler_runtime : None ,
@@ -960,55 +955,6 @@ impl CrateInfo {
960955 // and we assume that they cannot define weak lang items. This is not currently enforced
961956 // by the compiler, but that's ok because all this stuff is unstable anyway.
962957 let target = & tcx. sess . target ;
963- if !are_upstream_rust_objects_already_included ( tcx. sess ) {
964- let missing_weak_lang_items: FxIndexSet < Symbol > = info
965- . used_crates
966- . iter ( )
967- . flat_map ( |& cnum| tcx. missing_lang_items ( cnum) )
968- . filter ( |l| l. is_weak ( ) )
969- . filter_map ( |& l| {
970- let name = l. link_name ( ) ?;
971- lang_items:: required ( tcx, l) . then_some ( name)
972- } )
973- . collect ( ) ;
974- let prefix = match ( target. is_like_windows , target. arch . as_ref ( ) ) {
975- ( true , "x86" ) => "_" ,
976- ( true , "arm64ec" ) => "#" ,
977- _ => "" ,
978- } ;
979-
980- // This loop only adds new items to values of the hash map, so the order in which we
981- // iterate over the values is not important.
982- #[ allow( rustc:: potential_query_instability) ]
983- info. linked_symbols
984- . iter_mut ( )
985- . filter ( |( crate_type, _) | {
986- !matches ! ( crate_type, CrateType :: Rlib | CrateType :: Staticlib )
987- } )
988- . for_each ( |( _, linked_symbols) | {
989- let mut symbols = missing_weak_lang_items
990- . iter ( )
991- . map ( |item| ( format ! ( "{prefix}{item}" ) , SymbolExportKind :: Text ) )
992- . collect :: < Vec < _ > > ( ) ;
993- symbols. sort_unstable_by ( |a, b| a. 0 . cmp ( & b. 0 ) ) ;
994- linked_symbols. extend ( symbols) ;
995- if tcx. allocator_kind ( ( ) ) . is_some ( ) {
996- // At least one crate needs a global allocator. This crate may be placed
997- // after the crate that defines it in the linker order, in which case some
998- // linkers return an error. By adding the global allocator shim methods to
999- // the linked_symbols list, linking the generated symbols.o will ensure that
1000- // circular dependencies involving the global allocator don't lead to linker
1001- // errors.
1002- linked_symbols. extend ( ALLOCATOR_METHODS . iter ( ) . map ( |method| {
1003- (
1004- format ! ( "{prefix}{}" , global_fn_name( method. name) . as_str( ) ) ,
1005- SymbolExportKind :: Text ,
1006- )
1007- } ) ) ;
1008- }
1009- } ) ;
1010- }
1011-
1012958 let embed_visualizers = tcx. crate_types ( ) . iter ( ) . any ( |& crate_type| match crate_type {
1013959 CrateType :: Executable | CrateType :: Dylib | CrateType :: Cdylib => {
1014960 // These are crate types for which we invoke the linker and can embed
0 commit comments