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