@@ -31,14 +31,33 @@ pub(crate) fn build_sysroot(
31
31
32
32
let is_native = bootstrap_host_compiler. triple == target_triple;
33
33
34
- let cg_clif_dylib_path = match cg_clif_dylib_src {
34
+ let cg_clif_backend_name = match cg_clif_dylib_src {
35
35
CodegenBackend :: Local ( src_path) => {
36
- // Copy the backend
37
- let cg_clif_dylib_path = dist_dir. join ( "lib" ) . join ( src_path. file_name ( ) . unwrap ( ) ) ;
36
+ // Create the codegen-backends dir in the sysroot
37
+ let dylib_dir = dist_dir
38
+ . join ( "lib" )
39
+ . join ( "rustlib" )
40
+ . join ( & bootstrap_host_compiler. triple )
41
+ . join ( "codegen-backends" ) ;
42
+ fs:: create_dir_all ( & dylib_dir) . unwrap ( ) ;
43
+
44
+ // Copy the backend into the sysroot
45
+ let target_dylib_name = get_file_name (
46
+ & bootstrap_host_compiler. rustc ,
47
+ "rustc_codegen_cranelift_local" ,
48
+ "dylib" ,
49
+ )
50
+ . replace ( "cranelift_local" , "cranelift-local" ) ;
51
+ let cg_clif_dylib_path = dylib_dir. join ( target_dylib_name) ;
38
52
try_hard_link ( src_path, & cg_clif_dylib_path) ;
39
- CodegenBackend :: Local ( cg_clif_dylib_path)
53
+
54
+ // This is using a different name from rustup distributed versions of cg_clif to allow
55
+ // switching between a locally built and rustup distributed version and to ensure that
56
+ // the rustup distributed version doesn't accidentally gets picked when trying to use
57
+ // the locally built version.
58
+ "cranelift-local" . to_owned ( )
40
59
}
41
- CodegenBackend :: Builtin ( name) => CodegenBackend :: Builtin ( name. clone ( ) ) ,
60
+ CodegenBackend :: Builtin ( name) => name. clone ( ) ,
42
61
} ;
43
62
44
63
// Build and copy rustc and cargo wrappers
@@ -69,17 +88,16 @@ pub(crate) fn build_sysroot(
69
88
. env ( "RUSTC" , & bootstrap_host_compiler. rustc )
70
89
. env ( "RUSTDOC" , & bootstrap_host_compiler. rustdoc ) ;
71
90
}
72
- if let CodegenBackend :: Builtin ( name) = cg_clif_dylib_src {
73
- build_cargo_wrapper_cmd. env ( "BUILTIN_BACKEND" , name) ;
74
- }
91
+ build_cargo_wrapper_cmd. env ( "HOST_TUPLE" , & bootstrap_host_compiler. triple ) ;
92
+ build_cargo_wrapper_cmd. env ( "BUILTIN_BACKEND" , & cg_clif_backend_name) ;
75
93
spawn_and_wait ( build_cargo_wrapper_cmd) ;
76
94
try_hard_link ( wrapper_path, dist_dir. join ( "bin" ) . join ( wrapper_name) ) ;
77
95
}
78
96
79
97
let host = build_sysroot_for_triple (
80
98
dirs,
81
99
bootstrap_host_compiler. clone ( ) ,
82
- & cg_clif_dylib_path ,
100
+ & cg_clif_dylib_src ,
83
101
sysroot_kind,
84
102
panic_unwind_support,
85
103
) ;
@@ -94,7 +112,7 @@ pub(crate) fn build_sysroot(
94
112
bootstrap_target_compiler. set_cross_linker_and_runner ( ) ;
95
113
bootstrap_target_compiler
96
114
} ,
97
- & cg_clif_dylib_path ,
115
+ & cg_clif_dylib_src ,
98
116
sysroot_kind,
99
117
panic_unwind_support,
100
118
)
0 commit comments