@@ -22,9 +22,9 @@ pub(crate) fn build_sysroot(
2222
2323 eprintln ! ( "[BUILD] sysroot {:?}" , sysroot_kind) ;
2424
25- let dist_dir = RelPath :: DIST . to_path ( dirs) ;
25+ let dist_dir = & dirs. dist_dir ;
2626
27- ensure_empty_dir ( & dist_dir) ;
27+ ensure_empty_dir ( dist_dir) ;
2828 fs:: create_dir_all ( dist_dir. join ( "bin" ) ) . unwrap ( ) ;
2929 fs:: create_dir_all ( dist_dir. join ( "lib" ) ) . unwrap ( ) ;
3030
@@ -55,7 +55,7 @@ pub(crate) fn build_sysroot(
5555 let mut build_cargo_wrapper_cmd = Command :: new ( & bootstrap_host_compiler. rustc ) ;
5656 let wrapper_path = dist_dir. join ( & wrapper_name) ;
5757 build_cargo_wrapper_cmd
58- . arg ( RelPath :: SCRIPTS . to_path ( dirs ) . join ( & format ! ( "{wrapper}.rs" ) ) )
58+ . arg ( dirs . source_dir . join ( "scripts" ) . join ( & format ! ( "{wrapper}.rs" ) ) )
5959 . arg ( "-o" )
6060 . arg ( & wrapper_path)
6161 . arg ( "-Cstrip=debuginfo" ) ;
@@ -85,7 +85,7 @@ pub(crate) fn build_sysroot(
8585 & cg_clif_dylib_path,
8686 sysroot_kind,
8787 ) ;
88- host. install_into_sysroot ( & dist_dir) ;
88+ host. install_into_sysroot ( dist_dir) ;
8989
9090 if !is_native {
9191 build_sysroot_for_triple (
@@ -99,7 +99,7 @@ pub(crate) fn build_sysroot(
9999 & cg_clif_dylib_path,
100100 sysroot_kind,
101101 )
102- . install_into_sysroot ( & dist_dir) ;
102+ . install_into_sysroot ( dist_dir) ;
103103 }
104104
105105 let mut target_compiler = {
@@ -143,10 +143,10 @@ impl SysrootTarget {
143143 }
144144}
145145
146- static STDLIB_SRC : RelPath = RelPath :: BUILD . join ( "stdlib" ) ;
146+ static STDLIB_SRC : RelPath = RelPath :: build ( "stdlib" ) ;
147147static STANDARD_LIBRARY : CargoProject =
148- CargoProject :: new ( & STDLIB_SRC . join ( " library/sysroot") , "stdlib_target" ) ;
149- static RTSTARTUP_SYSROOT : RelPath = RelPath :: BUILD . join ( "rtstartup" ) ;
148+ CargoProject :: new ( & RelPath :: build ( "stdlib/ library/sysroot") , "stdlib_target" ) ;
149+ static RTSTARTUP_SYSROOT : RelPath = RelPath :: build ( "rtstartup" ) ;
150150
151151fn build_sysroot_for_triple (
152152 dirs : & Dirs ,
@@ -247,6 +247,7 @@ fn build_clif_sysroot_for_triple(
247247 let mut build_cmd = STANDARD_LIBRARY . build ( & compiler, dirs) ;
248248 build_cmd. arg ( "--release" ) ;
249249 build_cmd. arg ( "--features" ) . arg ( "backtrace panic-unwind compiler-builtins-no-f16-f128" ) ;
250+ build_cmd. arg ( format ! ( "-Zroot-dir={}" , STDLIB_SRC . to_path( dirs) . display( ) ) ) ;
250251 build_cmd. env ( "CARGO_PROFILE_RELEASE_DEBUG" , "true" ) ;
251252 build_cmd. env ( "__CARGO_DEFAULT_LIB_METADATA" , "cg_clif" ) ;
252253 if compiler. triple . contains ( "apple" ) {
@@ -281,13 +282,14 @@ fn build_rtstartup(dirs: &Dirs, compiler: &Compiler) -> Option<SysrootTarget> {
281282 return None ;
282283 }
283284
284- RTSTARTUP_SYSROOT . ensure_fresh ( dirs) ;
285+ let rtstartup_sysroot = RTSTARTUP_SYSROOT . to_path ( dirs) ;
286+ ensure_empty_dir ( & rtstartup_sysroot) ;
285287
286288 let rtstartup_src = STDLIB_SRC . to_path ( dirs) . join ( "library" ) . join ( "rtstartup" ) ;
287289 let mut target_libs = SysrootTarget { triple : compiler. triple . clone ( ) , libs : vec ! [ ] } ;
288290
289291 for file in [ "rsbegin" , "rsend" ] {
290- let obj = RTSTARTUP_SYSROOT . to_path ( dirs ) . join ( format ! ( "{file}.o" ) ) ;
292+ let obj = rtstartup_sysroot . join ( format ! ( "{file}.o" ) ) ;
291293 let mut build_rtstartup_cmd = Command :: new ( & compiler. rustc ) ;
292294 build_rtstartup_cmd
293295 . arg ( "--target" )
0 commit comments