@@ -10,10 +10,6 @@ use crate::utils::{
10
10
} ;
11
11
use crate :: { config, CodegenBackend , SysrootKind } ;
12
12
13
- static DIST_DIR : RelPath = RelPath :: DIST ;
14
- static BIN_DIR : RelPath = RelPath :: DIST . join ( "bin" ) ;
15
- static LIB_DIR : RelPath = RelPath :: DIST . join ( "lib" ) ;
16
-
17
13
pub ( crate ) fn build_sysroot (
18
14
dirs : & Dirs ,
19
15
sysroot_kind : SysrootKind ,
@@ -26,9 +22,12 @@ pub(crate) fn build_sysroot(
26
22
27
23
eprintln ! ( "[BUILD] sysroot {:?}" , sysroot_kind) ;
28
24
29
- DIST_DIR . ensure_fresh ( dirs) ;
30
- BIN_DIR . ensure_exists ( dirs) ;
31
- LIB_DIR . ensure_exists ( dirs) ;
25
+ let dist_dir = RelPath :: DIST . to_path ( dirs) ;
26
+
27
+ remove_dir_if_exists ( & dist_dir) ;
28
+ fs:: create_dir_all ( & dist_dir) . unwrap ( ) ;
29
+ fs:: create_dir_all ( dist_dir. join ( "bin" ) ) . unwrap ( ) ;
30
+ fs:: create_dir_all ( dist_dir. join ( "lib" ) ) . unwrap ( ) ;
32
31
33
32
let is_native = bootstrap_host_compiler. triple == target_triple;
34
33
@@ -38,11 +37,10 @@ pub(crate) fn build_sysroot(
38
37
let cg_clif_dylib_path = if cfg ! ( windows) {
39
38
// Windows doesn't have rpath support, so the cg_clif dylib needs to be next to the
40
39
// binaries.
41
- BIN_DIR
40
+ dist_dir . join ( "bin" )
42
41
} else {
43
- LIB_DIR
42
+ dist_dir . join ( "lib" )
44
43
}
45
- . to_path ( dirs)
46
44
. join ( src_path. file_name ( ) . unwrap ( ) ) ;
47
45
try_hard_link ( src_path, & cg_clif_dylib_path) ;
48
46
CodegenBackend :: Local ( cg_clif_dylib_path)
@@ -56,7 +54,7 @@ pub(crate) fn build_sysroot(
56
54
let wrapper_name = wrapper_base_name. replace ( "____" , wrapper) ;
57
55
58
56
let mut build_cargo_wrapper_cmd = Command :: new ( & bootstrap_host_compiler. rustc ) ;
59
- let wrapper_path = DIST_DIR . to_path ( dirs ) . join ( & wrapper_name) ;
57
+ let wrapper_path = dist_dir . join ( & wrapper_name) ;
60
58
build_cargo_wrapper_cmd
61
59
. arg ( RelPath :: SCRIPTS . to_path ( dirs) . join ( & format ! ( "{wrapper}.rs" ) ) )
62
60
. arg ( "-o" )
@@ -79,7 +77,7 @@ pub(crate) fn build_sysroot(
79
77
build_cargo_wrapper_cmd. env ( "BUILTIN_BACKEND" , name) ;
80
78
}
81
79
spawn_and_wait ( build_cargo_wrapper_cmd) ;
82
- try_hard_link ( wrapper_path, BIN_DIR . to_path ( dirs ) . join ( wrapper_name) ) ;
80
+ try_hard_link ( wrapper_path, dist_dir . join ( "bin" ) . join ( wrapper_name) ) ;
83
81
}
84
82
85
83
let host = build_sysroot_for_triple (
@@ -88,7 +86,7 @@ pub(crate) fn build_sysroot(
88
86
& cg_clif_dylib_path,
89
87
sysroot_kind,
90
88
) ;
91
- host. install_into_sysroot ( & DIST_DIR . to_path ( dirs ) ) ;
89
+ host. install_into_sysroot ( & dist_dir ) ;
92
90
93
91
if !is_native {
94
92
build_sysroot_for_triple (
@@ -102,24 +100,21 @@ pub(crate) fn build_sysroot(
102
100
& cg_clif_dylib_path,
103
101
sysroot_kind,
104
102
)
105
- . install_into_sysroot ( & DIST_DIR . to_path ( dirs ) ) ;
103
+ . install_into_sysroot ( & dist_dir ) ;
106
104
}
107
105
108
106
// Copy std for the host to the lib dir. This is necessary for the jit mode to find
109
107
// libstd.
110
108
for lib in host. libs {
111
109
let filename = lib. file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ;
112
110
if filename. contains ( "std-" ) && !filename. contains ( ".rlib" ) {
113
- try_hard_link ( & lib, LIB_DIR . to_path ( dirs ) . join ( lib. file_name ( ) . unwrap ( ) ) ) ;
111
+ try_hard_link ( & lib, dist_dir . join ( "lib" ) . join ( lib. file_name ( ) . unwrap ( ) ) ) ;
114
112
}
115
113
}
116
114
117
115
let mut target_compiler = {
118
- let dirs: & Dirs = & dirs;
119
- let rustc_clif =
120
- RelPath :: DIST . to_path ( & dirs) . join ( wrapper_base_name. replace ( "____" , "rustc-clif" ) ) ;
121
- let rustdoc_clif =
122
- RelPath :: DIST . to_path ( & dirs) . join ( wrapper_base_name. replace ( "____" , "rustdoc-clif" ) ) ;
116
+ let rustc_clif = dist_dir. join ( wrapper_base_name. replace ( "____" , "rustc-clif" ) ) ;
117
+ let rustdoc_clif = dist_dir. join ( wrapper_base_name. replace ( "____" , "rustdoc-clif" ) ) ;
123
118
124
119
Compiler {
125
120
cargo : bootstrap_host_compiler. cargo . clone ( ) ,
0 commit comments