@@ -23,18 +23,17 @@ use rustc_codegen_ssa::back::write::{CodegenContext, FatLTOInput, ModuleConfig};
23
23
use rustc_codegen_ssa:: traits:: * ;
24
24
use rustc_codegen_ssa:: ModuleCodegen ;
25
25
use rustc_codegen_ssa:: { CodegenResults , CompiledModule } ;
26
+ use rustc_data_structures:: fx:: FxHashMap ;
26
27
use rustc_errors:: { ErrorReported , FatalError , Handler } ;
27
- use rustc_middle:: dep_graph:: { DepGraph , WorkProduct } ;
28
+ use rustc_middle:: dep_graph:: { WorkProduct , WorkProductId } ;
28
29
use rustc_middle:: middle:: cstore:: { EncodedMetadata , MetadataLoaderDyn } ;
29
30
use rustc_middle:: ty:: { self , TyCtxt } ;
30
- use rustc_serialize:: json;
31
- use rustc_session:: config:: { self , OptLevel , OutputFilenames , PrintRequest } ;
31
+ use rustc_session:: config:: { OptLevel , OutputFilenames , PrintRequest } ;
32
32
use rustc_session:: Session ;
33
33
use rustc_span:: symbol:: Symbol ;
34
34
35
35
use std:: any:: Any ;
36
36
use std:: ffi:: CStr ;
37
- use std:: fs;
38
37
use std:: sync:: Arc ;
39
38
40
39
mod back {
@@ -249,11 +248,11 @@ impl CodegenBackend for LlvmCodegenBackend {
249
248
}
250
249
251
250
fn provide ( & self , providers : & mut ty:: query:: Providers ) {
252
- attributes:: provide ( providers) ;
251
+ attributes:: provide_both ( providers) ;
253
252
}
254
253
255
254
fn provide_extern ( & self , providers : & mut ty:: query:: Providers ) {
256
- attributes:: provide_extern ( providers) ;
255
+ attributes:: provide_both ( providers) ;
257
256
}
258
257
259
258
fn codegen_crate < ' tcx > (
@@ -274,47 +273,27 @@ impl CodegenBackend for LlvmCodegenBackend {
274
273
& self ,
275
274
ongoing_codegen : Box < dyn Any > ,
276
275
sess : & Session ,
277
- dep_graph : & DepGraph ,
278
- ) -> Result < Box < dyn Any > , ErrorReported > {
276
+ ) -> Result < ( CodegenResults , FxHashMap < WorkProductId , WorkProduct > ) , ErrorReported > {
279
277
let ( codegen_results, work_products) = ongoing_codegen
280
278
. downcast :: < rustc_codegen_ssa:: back:: write:: OngoingCodegen < LlvmCodegenBackend > > ( )
281
279
. expect ( "Expected LlvmCodegenBackend's OngoingCodegen, found Box<Any>" )
282
280
. join ( sess) ;
283
- if sess. opts . debugging_opts . incremental_info {
284
- rustc_codegen_ssa:: back:: write:: dump_incremental_data ( & codegen_results) ;
285
- }
286
281
287
- sess. time ( "serialize_work_products" , move || {
288
- rustc_incremental:: save_work_product_index ( sess, & dep_graph, work_products)
282
+ sess. time ( "llvm_dump_timing_file" , || {
283
+ if sess. opts . debugging_opts . llvm_time_trace {
284
+ llvm_util:: time_trace_profiler_finish ( "llvm_timings.json" ) ;
285
+ }
289
286
} ) ;
290
287
291
- sess. compile_status ( ) ?;
292
-
293
- Ok ( Box :: new ( codegen_results) )
288
+ Ok ( ( codegen_results, work_products) )
294
289
}
295
290
296
291
fn link (
297
292
& self ,
298
293
sess : & Session ,
299
- codegen_results : Box < dyn Any > ,
294
+ codegen_results : CodegenResults ,
300
295
outputs : & OutputFilenames ,
301
296
) -> Result < ( ) , ErrorReported > {
302
- let codegen_results = codegen_results
303
- . downcast :: < CodegenResults > ( )
304
- . expect ( "Expected CodegenResults, found Box<Any>" ) ;
305
-
306
- if sess. opts . debugging_opts . no_link {
307
- // FIXME: use a binary format to encode the `.rlink` file
308
- let rlink_data = json:: encode ( & codegen_results) . map_err ( |err| {
309
- sess. fatal ( & format ! ( "failed to encode rlink: {}" , err) ) ;
310
- } ) ?;
311
- let rlink_file = outputs. with_extension ( config:: RLINK_EXT ) ;
312
- fs:: write ( & rlink_file, rlink_data) . map_err ( |err| {
313
- sess. fatal ( & format ! ( "failed to write file {}: {}" , rlink_file. display( ) , err) ) ;
314
- } ) ?;
315
- return Ok ( ( ) ) ;
316
- }
317
-
318
297
// Run the linker on any artifacts that resulted from the LLVM run.
319
298
// This should produce either a finished executable or library.
320
299
sess. time ( "link_crate" , || {
@@ -331,16 +310,6 @@ impl CodegenBackend for LlvmCodegenBackend {
331
310
) ;
332
311
} ) ;
333
312
334
- // Now that we won't touch anything in the incremental compilation directory
335
- // any more, we can finalize it (which involves renaming it)
336
- rustc_incremental:: finalize_session_directory ( sess, codegen_results. crate_hash ) ;
337
-
338
- sess. time ( "llvm_dump_timing_file" , || {
339
- if sess. opts . debugging_opts . llvm_time_trace {
340
- llvm_util:: time_trace_profiler_finish ( "llvm_timings.json" ) ;
341
- }
342
- } ) ;
343
-
344
313
Ok ( ( ) )
345
314
}
346
315
}
0 commit comments