@@ -69,7 +69,7 @@ use common::{node_id_type, fulfill_obligation};
69
69
use common:: { type_is_immediate, type_is_zero_size, val_ty} ;
70
70
use common;
71
71
use consts;
72
- use context:: SharedCrateContext ;
72
+ use context:: { SharedCrateContext , CrateContextList } ;
73
73
use controlflow;
74
74
use datum;
75
75
use debuginfo:: { self , DebugLoc , ToDebugLoc } ;
@@ -2523,7 +2523,7 @@ pub fn write_metadata<'a, 'tcx>(cx: &SharedCrateContext<'a, 'tcx>,
2523
2523
2524
2524
/// Find any symbols that are defined in one compilation unit, but not declared
2525
2525
/// in any other compilation unit. Give these symbols internal linkage.
2526
- fn internalize_symbols ( cx : & SharedCrateContext , reachable : & HashSet < & str > ) {
2526
+ fn internalize_symbols ( cx : & CrateContextList , reachable : & HashSet < & str > ) {
2527
2527
unsafe {
2528
2528
let mut declared = HashSet :: new ( ) ;
2529
2529
@@ -2578,12 +2578,12 @@ fn internalize_symbols(cx: &SharedCrateContext, reachable: &HashSet<&str>) {
2578
2578
// when using MSVC linker. We do this only for data, as linker can fix up
2579
2579
// code references on its own.
2580
2580
// See #26591, #27438
2581
- fn create_imps ( cx : & SharedCrateContext ) {
2581
+ fn create_imps ( cx : & CrateContextList ) {
2582
2582
// The x86 ABI seems to require that leading underscores are added to symbol
2583
2583
// names, so we need an extra underscore on 32-bit. There's also a leading
2584
2584
// '\x01' here which disables LLVM's symbol mangling (e.g. no extra
2585
2585
// underscores added in front).
2586
- let prefix = if cx. sess ( ) . target . target . target_pointer_width == "32" {
2586
+ let prefix = if cx. shared ( ) . sess ( ) . target . target . target_pointer_width == "32" {
2587
2587
"\x01 __imp__"
2588
2588
} else {
2589
2589
"\x01 __imp_"
@@ -2715,10 +2715,7 @@ pub fn trans_crate<'tcx>(tcx: &TyCtxt<'tcx>,
2715
2715
2716
2716
let link_meta = link:: build_link_meta ( & tcx, name) ;
2717
2717
2718
- let codegen_units = tcx. sess . opts . cg . codegen_units ;
2719
- let shared_ccx = SharedCrateContext :: new ( & link_meta. crate_name ,
2720
- codegen_units,
2721
- tcx,
2718
+ let shared_ccx = SharedCrateContext :: new ( tcx,
2722
2719
& mir_map,
2723
2720
export_map,
2724
2721
Sha256 :: new ( ) ,
@@ -2727,8 +2724,11 @@ pub fn trans_crate<'tcx>(tcx: &TyCtxt<'tcx>,
2727
2724
check_overflow,
2728
2725
check_dropflag) ;
2729
2726
2727
+ let codegen_units = tcx. sess . opts . cg . codegen_units ;
2728
+ let crate_context_list = CrateContextList :: new ( & shared_ccx, codegen_units) ;
2729
+
2730
2730
{
2731
- let ccx = shared_ccx . get_ccx ( 0 ) ;
2731
+ let ccx = crate_context_list . get_ccx ( 0 ) ;
2732
2732
collect_translation_items ( & ccx) ;
2733
2733
2734
2734
// Translate all items. See `TransModVisitor` for
@@ -2744,7 +2744,7 @@ pub fn trans_crate<'tcx>(tcx: &TyCtxt<'tcx>,
2744
2744
symbol_names_test:: report_symbol_names ( & ccx) ;
2745
2745
}
2746
2746
2747
- for ccx in shared_ccx . iter ( ) {
2747
+ for ccx in crate_context_list . iter ( ) {
2748
2748
if ccx. sess ( ) . opts . debuginfo != NoDebugInfo {
2749
2749
debuginfo:: finalize ( & ccx) ;
2750
2750
}
@@ -2793,7 +2793,7 @@ pub fn trans_crate<'tcx>(tcx: &TyCtxt<'tcx>,
2793
2793
}
2794
2794
}
2795
2795
2796
- let modules = shared_ccx . iter ( )
2796
+ let modules = crate_context_list . iter ( )
2797
2797
. map ( |ccx| ModuleTranslation { llcx : ccx. llcx ( ) , llmod : ccx. llmod ( ) } )
2798
2798
. collect ( ) ;
2799
2799
@@ -2820,13 +2820,13 @@ pub fn trans_crate<'tcx>(tcx: &TyCtxt<'tcx>,
2820
2820
}
2821
2821
2822
2822
if codegen_units > 1 {
2823
- internalize_symbols ( & shared_ccx ,
2823
+ internalize_symbols ( & crate_context_list ,
2824
2824
& reachable_symbols. iter ( ) . map ( |x| & x[ ..] ) . collect ( ) ) ;
2825
2825
}
2826
2826
2827
2827
if sess. target . target . options . is_like_msvc &&
2828
2828
sess. crate_types . borrow ( ) . iter ( ) . any ( |ct| * ct == config:: CrateTypeRlib ) {
2829
- create_imps ( & shared_ccx ) ;
2829
+ create_imps ( & crate_context_list ) ;
2830
2830
}
2831
2831
2832
2832
let metadata_module = ModuleTranslation {
0 commit comments