@@ -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 {
@@ -252,11 +251,11 @@ impl CodegenBackend for LlvmCodegenBackend {
252
251
}
253
252
254
253
fn provide ( & self , providers : & mut ty:: query:: Providers ) {
255
- attributes:: provide ( providers) ;
254
+ attributes:: provide_both ( providers) ;
256
255
}
257
256
258
257
fn provide_extern ( & self , providers : & mut ty:: query:: Providers ) {
259
- attributes:: provide_extern ( providers) ;
258
+ attributes:: provide_both ( providers) ;
260
259
}
261
260
262
261
fn codegen_crate < ' tcx > (
@@ -277,47 +276,27 @@ impl CodegenBackend for LlvmCodegenBackend {
277
276
& self ,
278
277
ongoing_codegen : Box < dyn Any > ,
279
278
sess : & Session ,
280
- dep_graph : & DepGraph ,
281
- ) -> Result < Box < dyn Any > , ErrorReported > {
279
+ ) -> Result < ( CodegenResults , FxHashMap < WorkProductId , WorkProduct > ) , ErrorReported > {
282
280
let ( codegen_results, work_products) = ongoing_codegen
283
281
. downcast :: < rustc_codegen_ssa:: back:: write:: OngoingCodegen < LlvmCodegenBackend > > ( )
284
282
. expect ( "Expected LlvmCodegenBackend's OngoingCodegen, found Box<Any>" )
285
283
. join ( sess) ;
286
- if sess. opts . debugging_opts . incremental_info {
287
- rustc_codegen_ssa:: back:: write:: dump_incremental_data ( & codegen_results) ;
288
- }
289
284
290
- sess. time ( "serialize_work_products" , move || {
291
- rustc_incremental:: save_work_product_index ( sess, & dep_graph, work_products)
285
+ sess. time ( "llvm_dump_timing_file" , || {
286
+ if sess. opts . debugging_opts . llvm_time_trace {
287
+ llvm_util:: time_trace_profiler_finish ( "llvm_timings.json" ) ;
288
+ }
292
289
} ) ;
293
290
294
- sess. compile_status ( ) ?;
295
-
296
- Ok ( Box :: new ( codegen_results) )
291
+ Ok ( ( codegen_results, work_products) )
297
292
}
298
293
299
294
fn link (
300
295
& self ,
301
296
sess : & Session ,
302
- codegen_results : Box < dyn Any > ,
297
+ codegen_results : CodegenResults ,
303
298
outputs : & OutputFilenames ,
304
299
) -> Result < ( ) , ErrorReported > {
305
- let codegen_results = codegen_results
306
- . downcast :: < CodegenResults > ( )
307
- . expect ( "Expected CodegenResults, found Box<Any>" ) ;
308
-
309
- if sess. opts . debugging_opts . no_link {
310
- // FIXME: use a binary format to encode the `.rlink` file
311
- let rlink_data = json:: encode ( & codegen_results) . map_err ( |err| {
312
- sess. fatal ( & format ! ( "failed to encode rlink: {}" , err) ) ;
313
- } ) ?;
314
- let rlink_file = outputs. with_extension ( config:: RLINK_EXT ) ;
315
- fs:: write ( & rlink_file, rlink_data) . map_err ( |err| {
316
- sess. fatal ( & format ! ( "failed to write file {}: {}" , rlink_file. display( ) , err) ) ;
317
- } ) ?;
318
- return Ok ( ( ) ) ;
319
- }
320
-
321
300
// Run the linker on any artifacts that resulted from the LLVM run.
322
301
// This should produce either a finished executable or library.
323
302
sess. time ( "link_crate" , || {
@@ -334,16 +313,6 @@ impl CodegenBackend for LlvmCodegenBackend {
334
313
) ;
335
314
} ) ;
336
315
337
- // Now that we won't touch anything in the incremental compilation directory
338
- // any more, we can finalize it (which involves renaming it)
339
- rustc_incremental:: finalize_session_directory ( sess, codegen_results. crate_hash ) ;
340
-
341
- sess. time ( "llvm_dump_timing_file" , || {
342
- if sess. opts . debugging_opts . llvm_time_trace {
343
- llvm_util:: time_trace_profiler_finish ( "llvm_timings.json" ) ;
344
- }
345
- } ) ;
346
-
347
316
Ok ( ( ) )
348
317
}
349
318
}
0 commit comments