@@ -161,7 +161,7 @@ pub struct Build {
161161 initial_rustc : PathBuf ,
162162 initial_cargo : PathBuf ,
163163 initial_lld : PathBuf ,
164- initial_libdir : PathBuf ,
164+ initial_relative_libdir : PathBuf ,
165165 initial_sysroot : PathBuf ,
166166
167167 // Runtime state filled in later on
@@ -315,46 +315,19 @@ impl Build {
315315 let in_tree_llvm_info = config. in_tree_llvm_info . clone ( ) ;
316316 let in_tree_gcc_info = config. in_tree_gcc_info . clone ( ) ;
317317
318- let initial_target_libdir_str = if config. dry_run ( ) {
319- "/dummy/lib/path/to/lib/" . to_string ( )
320- } else {
321- output (
322- Command :: new ( & config. initial_rustc )
323- . arg ( "--target" )
324- . arg ( config. build . rustc_target_arg ( ) )
325- . arg ( "--print" )
326- . arg ( "target-libdir" ) ,
327- )
328- } ;
318+ let initial_target_libdir_str =
319+ config. initial_sysroot . join ( "lib/rustlib" ) . join ( config. build ) . join ( "lib" ) ;
320+
329321 let initial_target_dir = Path :: new ( & initial_target_libdir_str) . parent ( ) . unwrap ( ) ;
330322 let initial_lld = initial_target_dir. join ( "bin" ) . join ( "rust-lld" ) ;
331323
332- let initial_sysroot = if config. dry_run ( ) {
333- "/dummy" . to_string ( )
334- } else {
335- output ( Command :: new ( & config. initial_rustc ) . arg ( "--print" ) . arg ( "sysroot" ) )
336- }
337- . trim ( )
338- . to_string ( ) ;
339-
340- // FIXME(Zalathar): Determining this path occasionally fails locally for
341- // unknown reasons, so we print some extra context to help track down why.
342- let find_initial_libdir = || {
343- let initial_libdir =
344- initial_target_dir. parent ( ) ?. parent ( ) ?. strip_prefix ( & initial_sysroot) . ok ( ) ?;
345- Some ( initial_libdir. to_path_buf ( ) )
346- } ;
347- let Some ( initial_libdir) = find_initial_libdir ( ) else {
348- panic ! (
349- "couldn't determine `initial_libdir`:
350- - config.initial_rustc: {rustc:?}
351- - initial_target_libdir_str: {initial_target_libdir_str:?}
352- - initial_target_dir: {initial_target_dir:?}
353- - initial_sysroot: {initial_sysroot:?}
354- " ,
355- rustc = config. initial_rustc,
356- ) ;
357- } ;
324+ let initial_relative_libdir = initial_target_dir
325+ . ancestors ( )
326+ . nth ( 2 )
327+ . unwrap ( )
328+ . strip_prefix ( & config. initial_sysroot )
329+ . expect ( "Couldn’t determine initial relative libdir." )
330+ . to_path_buf ( ) ;
358331
359332 let version = std:: fs:: read_to_string ( src. join ( "src" ) . join ( "version" ) )
360333 . expect ( "failed to read src/version" ) ;
@@ -383,11 +356,11 @@ impl Build {
383356 }
384357
385358 let mut build = Build {
359+ initial_lld,
360+ initial_relative_libdir,
386361 initial_rustc : config. initial_rustc . clone ( ) ,
387362 initial_cargo : config. initial_cargo . clone ( ) ,
388- initial_lld,
389- initial_libdir,
390- initial_sysroot : initial_sysroot. into ( ) ,
363+ initial_sysroot : config. initial_sysroot . clone ( ) ,
391364 local_rebuild : config. local_rebuild ,
392365 fail_fast : config. cmd . fail_fast ( ) ,
393366 doc_tests : config. cmd . doc_tests ( ) ,
0 commit comments