@@ -123,7 +123,7 @@ pub struct ModuleConfig {
123
123
impl ModuleConfig {
124
124
fn new (
125
125
kind : ModuleKind ,
126
- sess : & Session ,
126
+ tcx : TyCtxt < ' _ > ,
127
127
no_builtins : bool ,
128
128
is_compiler_builtins : bool ,
129
129
) -> ModuleConfig {
@@ -135,6 +135,7 @@ impl ModuleConfig {
135
135
} ;
136
136
}
137
137
138
+ let sess = tcx. sess ;
138
139
let opt_level_and_size = if_regular ! ( Some ( sess. opts. optimize) , None ) ;
139
140
140
141
let save_temps = sess. opts . cg . save_temps ;
@@ -166,7 +167,7 @@ impl ModuleConfig {
166
167
// `#![no_builtins]` is assumed to not participate in LTO and
167
168
// instead goes on to generate object code.
168
169
EmitObj :: Bitcode
169
- } else if need_bitcode_in_object ( sess ) {
170
+ } else if need_bitcode_in_object ( tcx ) {
170
171
EmitObj :: ObjectCode ( BitcodeSection :: Full )
171
172
} else {
172
173
EmitObj :: ObjectCode ( BitcodeSection :: None )
@@ -414,9 +415,10 @@ pub struct CompiledModules {
414
415
pub allocator_module : Option < CompiledModule > ,
415
416
}
416
417
417
- fn need_bitcode_in_object ( sess : & Session ) -> bool {
418
+ fn need_bitcode_in_object ( tcx : TyCtxt < ' _ > ) -> bool {
419
+ let sess = tcx. sess ;
418
420
let requested_for_rlib = sess. opts . cg . embed_bitcode
419
- && sess . crate_types ( ) . contains ( & CrateType :: Rlib )
421
+ && tcx . crate_types ( ) . contains ( & CrateType :: Rlib )
420
422
&& sess. opts . output_types . contains_key ( & OutputType :: Exe ) ;
421
423
let forced_by_target = sess. target . forces_embed_bitcode ;
422
424
requested_for_rlib || forced_by_target
@@ -450,11 +452,11 @@ pub fn start_async_codegen<B: ExtraBackendMethods>(
450
452
let crate_info = CrateInfo :: new ( tcx, target_cpu) ;
451
453
452
454
let regular_config =
453
- ModuleConfig :: new ( ModuleKind :: Regular , sess , no_builtins, is_compiler_builtins) ;
455
+ ModuleConfig :: new ( ModuleKind :: Regular , tcx , no_builtins, is_compiler_builtins) ;
454
456
let metadata_config =
455
- ModuleConfig :: new ( ModuleKind :: Metadata , sess , no_builtins, is_compiler_builtins) ;
457
+ ModuleConfig :: new ( ModuleKind :: Metadata , tcx , no_builtins, is_compiler_builtins) ;
456
458
let allocator_config =
457
- ModuleConfig :: new ( ModuleKind :: Allocator , sess , no_builtins, is_compiler_builtins) ;
459
+ ModuleConfig :: new ( ModuleKind :: Allocator , tcx , no_builtins, is_compiler_builtins) ;
458
460
459
461
let ( shared_emitter, shared_emitter_main) = SharedEmitter :: new ( ) ;
460
462
let ( codegen_worker_send, codegen_worker_receive) = channel ( ) ;
@@ -1092,7 +1094,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
1092
1094
} ;
1093
1095
1094
1096
let cgcx = CodegenContext :: < B > {
1095
- crate_types : sess . crate_types ( ) . to_vec ( ) ,
1097
+ crate_types : tcx . crate_types ( ) . to_vec ( ) ,
1096
1098
each_linked_rlib_for_lto,
1097
1099
lto : sess. lto ( ) ,
1098
1100
fewer_names : sess. fewer_names ( ) ,
@@ -2063,7 +2065,7 @@ fn msvc_imps_needed(tcx: TyCtxt<'_>) -> bool {
2063
2065
) ;
2064
2066
2065
2067
tcx. sess . target . is_like_windows &&
2066
- tcx. sess . crate_types ( ) . iter ( ) . any ( |ct| * ct == CrateType :: Rlib ) &&
2068
+ tcx. crate_types ( ) . iter ( ) . any ( |ct| * ct == CrateType :: Rlib ) &&
2067
2069
// ThinLTO can't handle this workaround in all cases, so we don't
2068
2070
// emit the `__imp_` symbols. Instead we make them unnecessary by disallowing
2069
2071
// dynamic linking when linker plugin LTO is enabled.
0 commit comments