@@ -23,18 +23,17 @@ use rustc_codegen_ssa::back::write::{CodegenContext, FatLTOInput, ModuleConfig};
2323use rustc_codegen_ssa:: traits:: * ;
2424use rustc_codegen_ssa:: ModuleCodegen ;
2525use rustc_codegen_ssa:: { CodegenResults , CompiledModule } ;
26+ use rustc_data_structures:: fx:: FxHashMap ;
2627use rustc_errors:: { ErrorReported , FatalError , Handler } ;
27- use rustc_middle:: dep_graph:: { DepGraph , WorkProduct } ;
28+ use rustc_middle:: dep_graph:: { WorkProduct , WorkProductId } ;
2829use rustc_middle:: middle:: cstore:: { EncodedMetadata , MetadataLoaderDyn } ;
2930use 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 } ;
3232use rustc_session:: Session ;
3333use rustc_span:: symbol:: Symbol ;
3434
3535use std:: any:: Any ;
3636use std:: ffi:: CStr ;
37- use std:: fs;
3837use std:: sync:: Arc ;
3938
4039mod back {
@@ -252,11 +251,11 @@ impl CodegenBackend for LlvmCodegenBackend {
252251 }
253252
254253 fn provide ( & self , providers : & mut ty:: query:: Providers ) {
255- attributes:: provide ( providers) ;
254+ attributes:: provide_both ( providers) ;
256255 }
257256
258257 fn provide_extern ( & self , providers : & mut ty:: query:: Providers ) {
259- attributes:: provide_extern ( providers) ;
258+ attributes:: provide_both ( providers) ;
260259 }
261260
262261 fn codegen_crate < ' tcx > (
@@ -277,47 +276,27 @@ impl CodegenBackend for LlvmCodegenBackend {
277276 & self ,
278277 ongoing_codegen : Box < dyn Any > ,
279278 sess : & Session ,
280- dep_graph : & DepGraph ,
281- ) -> Result < Box < dyn Any > , ErrorReported > {
279+ ) -> Result < ( CodegenResults , FxHashMap < WorkProductId , WorkProduct > ) , ErrorReported > {
282280 let ( codegen_results, work_products) = ongoing_codegen
283281 . downcast :: < rustc_codegen_ssa:: back:: write:: OngoingCodegen < LlvmCodegenBackend > > ( )
284282 . expect ( "Expected LlvmCodegenBackend's OngoingCodegen, found Box<Any>" )
285283 . join ( sess) ;
286- if sess. opts . debugging_opts . incremental_info {
287- rustc_codegen_ssa:: back:: write:: dump_incremental_data ( & codegen_results) ;
288- }
289284
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+ }
292289 } ) ;
293290
294- sess. compile_status ( ) ?;
295-
296- Ok ( Box :: new ( codegen_results) )
291+ Ok ( ( codegen_results, work_products) )
297292 }
298293
299294 fn link (
300295 & self ,
301296 sess : & Session ,
302- codegen_results : Box < dyn Any > ,
297+ codegen_results : CodegenResults ,
303298 outputs : & OutputFilenames ,
304299 ) -> 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-
321300 // Run the linker on any artifacts that resulted from the LLVM run.
322301 // This should produce either a finished executable or library.
323302 sess. time ( "link_crate" , || {
@@ -334,16 +313,6 @@ impl CodegenBackend for LlvmCodegenBackend {
334313 ) ;
335314 } ) ;
336315
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-
347316 Ok ( ( ) )
348317 }
349318}
0 commit comments