@@ -23,7 +23,7 @@ use crate::{prelude::*, BackendConfig};
23
23
struct ModuleCodegenResult {
24
24
module_regular : CompiledModule ,
25
25
module_global_asm : Option < CompiledModule > ,
26
- work_product : Option < ( WorkProductId , WorkProduct ) > ,
26
+ existing_work_product : Option < ( WorkProductId , WorkProduct ) > ,
27
27
}
28
28
29
29
impl < HCX > HashStable < HCX > for ModuleCodegenResult {
@@ -41,16 +41,44 @@ pub(crate) struct OngoingCodegen {
41
41
}
42
42
43
43
impl OngoingCodegen {
44
- pub ( crate ) fn join ( self ) -> ( CodegenResults , FxHashMap < WorkProductId , WorkProduct > ) {
44
+ pub ( crate ) fn join (
45
+ self ,
46
+ sess : & Session ,
47
+ backend_config : & BackendConfig ,
48
+ ) -> ( CodegenResults , FxHashMap < WorkProductId , WorkProduct > ) {
45
49
let mut work_products = FxHashMap :: default ( ) ;
46
50
let mut modules = vec ! [ ] ;
47
51
48
52
for module_codegen_result in self . modules {
49
- let ModuleCodegenResult { module_regular, module_global_asm, work_product } =
53
+ let ModuleCodegenResult { module_regular, module_global_asm, existing_work_product } =
50
54
module_codegen_result;
51
- if let Some ( ( work_product_id, work_product) ) = work_product {
55
+
56
+ if let Some ( ( work_product_id, work_product) ) = existing_work_product {
52
57
work_products. insert ( work_product_id, work_product) ;
58
+ } else {
59
+ let work_product = if backend_config. disable_incr_cache {
60
+ None
61
+ } else if let Some ( module_global_asm) = & module_global_asm {
62
+ rustc_incremental:: copy_cgu_workproduct_to_incr_comp_cache_dir (
63
+ sess,
64
+ & module_regular. name ,
65
+ & [
66
+ ( "o" , & module_regular. object . as_ref ( ) . unwrap ( ) ) ,
67
+ ( "asm.o" , & module_global_asm. object . as_ref ( ) . unwrap ( ) ) ,
68
+ ] ,
69
+ )
70
+ } else {
71
+ rustc_incremental:: copy_cgu_workproduct_to_incr_comp_cache_dir (
72
+ sess,
73
+ & module_regular. name ,
74
+ & [ ( "o" , & module_regular. object . as_ref ( ) . unwrap ( ) ) ] ,
75
+ )
76
+ } ;
77
+ if let Some ( ( work_product_id, work_product) ) = work_product {
78
+ work_products. insert ( work_product_id, work_product) ;
79
+ }
53
80
}
81
+
54
82
modules. push ( module_regular) ;
55
83
if let Some ( module_global_asm) = module_global_asm {
56
84
modules. push ( module_global_asm) ;
@@ -84,7 +112,6 @@ fn make_module(sess: &Session, backend_config: &BackendConfig, name: String) ->
84
112
85
113
fn emit_cgu (
86
114
tcx : TyCtxt < ' _ > ,
87
- backend_config : & BackendConfig ,
88
115
name : String ,
89
116
module : ObjectModule ,
90
117
debug : Option < DebugContext < ' _ > > ,
@@ -101,22 +128,6 @@ fn emit_cgu(
101
128
102
129
let module_regular = emit_module ( tcx, product. object , ModuleKind :: Regular , name. clone ( ) ) ;
103
130
104
- let work_product = if backend_config. disable_incr_cache {
105
- None
106
- } else if let Some ( global_asm_object_file) = & global_asm_object_file {
107
- rustc_incremental:: copy_cgu_workproduct_to_incr_comp_cache_dir (
108
- tcx. sess ,
109
- & name,
110
- & [ ( "o" , & module_regular. object . as_ref ( ) . unwrap ( ) ) , ( "asm.o" , global_asm_object_file) ] ,
111
- )
112
- } else {
113
- rustc_incremental:: copy_cgu_workproduct_to_incr_comp_cache_dir (
114
- tcx. sess ,
115
- & name,
116
- & [ ( "o" , & module_regular. object . as_ref ( ) . unwrap ( ) ) ] ,
117
- )
118
- } ;
119
-
120
131
ModuleCodegenResult {
121
132
module_regular,
122
133
module_global_asm : global_asm_object_file. map ( |global_asm_object_file| CompiledModule {
@@ -126,7 +137,7 @@ fn emit_cgu(
126
137
dwarf_object : None ,
127
138
bytecode : None ,
128
139
} ) ,
129
- work_product ,
140
+ existing_work_product : None ,
130
141
}
131
142
}
132
143
@@ -205,7 +216,7 @@ fn reuse_workproduct_for_cgu(tcx: TyCtxt<'_>, cgu: &CodegenUnit<'_>) -> ModuleCo
205
216
} else {
206
217
None
207
218
} ,
208
- work_product : Some ( ( cgu. work_product_id ( ) , work_product) ) ,
219
+ existing_work_product : Some ( ( cgu. work_product_id ( ) , work_product) ) ,
209
220
}
210
221
}
211
222
@@ -271,7 +282,6 @@ fn module_codegen(
271
282
let codegen_result = tcx. sess . time ( "write object file" , || {
272
283
emit_cgu (
273
284
tcx,
274
- & backend_config,
275
285
cgu. name ( ) . as_str ( ) . to_string ( ) ,
276
286
module,
277
287
debug_context,
0 commit comments