11use std:: env;
22use std:: fs;
3- use std:: path:: Path ;
3+ use std:: path:: { Path , PathBuf } ;
44use std:: process:: { self , Command } ;
55
66use crate :: rustc_info:: { get_file_name, get_rustc_version} ;
@@ -11,7 +11,7 @@ pub(crate) fn build_sysroot(
1111 channel : & str ,
1212 sysroot_kind : SysrootKind ,
1313 target_dir : & Path ,
14- cg_clif_dylib : String ,
14+ cg_clif_build_dir : PathBuf ,
1515 host_triple : & str ,
1616 target_triple : & str ,
1717) {
@@ -24,24 +24,24 @@ pub(crate) fn build_sysroot(
2424 // Copy the backend
2525 for file in [ "cg_clif" , "cg_clif_build_sysroot" ] {
2626 try_hard_link (
27- Path :: new ( "target" ) . join ( channel ) . join ( get_file_name ( file, "bin" ) ) ,
27+ cg_clif_build_dir . join ( get_file_name ( file, "bin" ) ) ,
2828 target_dir. join ( "bin" ) . join ( get_file_name ( file, "bin" ) ) ,
2929 ) ;
3030 }
3131
32- if cfg ! ( windows ) {
33- // Windows doesn't have rpath support, so the cg_clif dylib needs to be next to the
34- // binaries.
35- try_hard_link (
36- Path :: new ( "target" ) . join ( channel ) . join ( & cg_clif_dylib ) ,
37- target_dir . join ( "bin" ) . join ( cg_clif_dylib ) ,
38- ) ;
39- } else {
40- try_hard_link (
41- Path :: new ( "target" ) . join ( channel ) . join ( & cg_clif_dylib ) ,
42- target_dir . join ( "lib" ) . join ( cg_clif_dylib ) ,
43- ) ;
44- }
32+ let cg_clif_dylib = get_file_name ( "rustc_codegen_cranelift" , "dylib" ) ;
33+ try_hard_link (
34+ cg_clif_build_dir . join ( & cg_clif_dylib ) ,
35+ target_dir
36+ . join ( if cfg ! ( windows ) {
37+ // Windows doesn't have rpath support, so the cg_clif dylib needs to be next to the
38+ // binaries.
39+ "bin"
40+ } else {
41+ "lib"
42+ } )
43+ . join ( cg_clif_dylib ) ,
44+ ) ;
4545
4646 // Build and copy cargo wrapper
4747 let mut build_cargo_wrapper_cmd = Command :: new ( "rustc" ) ;
0 commit comments