@@ -28,7 +28,6 @@ use rustc::util::common::ErrorReported;
28
28
use rustc_codegen_ssa:: back:: linker:: LinkerInfo ;
29
29
use rustc_codegen_ssa:: CrateInfo ;
30
30
use rustc_codegen_utils:: codegen_backend:: CodegenBackend ;
31
- use rustc_codegen_utils:: link:: out_filename;
32
31
use rustc_mir:: monomorphize:: partitioning:: CodegenUnitExt ;
33
32
34
33
use cranelift:: codegen:: settings;
@@ -46,8 +45,6 @@ mod common;
46
45
mod constant;
47
46
mod debuginfo;
48
47
mod intrinsics;
49
- mod link;
50
- mod link_copied;
51
48
mod linkage;
52
49
mod main_shim;
53
50
mod metadata;
@@ -366,20 +363,21 @@ impl CodegenBackend for CraneliftCodegenBackend {
366
363
_dep_graph : & DepGraph ,
367
364
outputs : & OutputFilenames ,
368
365
) -> Result < ( ) , ErrorReported > {
369
- let res = * res
366
+ use rustc_codegen_ssa:: back:: link:: link_binary;
367
+
368
+ let codegen_results = * res
370
369
. downcast :: < CodegenResults > ( )
371
370
. expect ( "Expected CraneliftCodegenBackend's CodegenResult, found Box<Any>" ) ;
372
371
373
- for & crate_type in sess. crate_types . borrow ( ) . iter ( ) {
374
- let output_name = out_filename ( sess, crate_type, & outputs, & res. crate_name . as_str ( ) ) ;
375
- match crate_type {
376
- CrateType :: Rlib => link:: link_rlib ( sess, & res, output_name) ,
377
- CrateType :: Dylib | CrateType :: Executable => {
378
- link:: link_natively ( sess, crate_type, & res, & output_name) ;
379
- }
380
- _ => sess. fatal ( & format ! ( "Unsupported crate type: {:?}" , crate_type) ) ,
381
- }
382
- }
372
+ let target_cpu = :: target_lexicon:: HOST . to_string ( ) ;
373
+ link_binary :: < crate :: archive:: ArArchiveBuilder < ' _ > > (
374
+ sess,
375
+ & codegen_results,
376
+ outputs,
377
+ & codegen_results. crate_name . as_str ( ) ,
378
+ & target_cpu,
379
+ ) ;
380
+
383
381
Ok ( ( ) )
384
382
}
385
383
}
0 commit comments