@@ -158,7 +158,7 @@ pub struct Build {
158158 initial_rustc : PathBuf ,
159159 initial_cargo : PathBuf ,
160160 initial_lld : PathBuf ,
161- initial_libdir : PathBuf ,
161+ initial_relative_libdir : PathBuf ,
162162 initial_sysroot : PathBuf ,
163163
164164 // Runtime state filled in later on
@@ -312,46 +312,19 @@ impl Build {
312312 let in_tree_llvm_info = config. in_tree_llvm_info . clone ( ) ;
313313 let in_tree_gcc_info = config. in_tree_gcc_info . clone ( ) ;
314314
315- let initial_target_libdir_str = if config. dry_run ( ) {
316- "/dummy/lib/path/to/lib/" . to_string ( )
317- } else {
318- output (
319- Command :: new ( & config. initial_rustc )
320- . arg ( "--target" )
321- . arg ( config. build . rustc_target_arg ( ) )
322- . arg ( "--print" )
323- . arg ( "target-libdir" ) ,
324- )
325- } ;
315+ let initial_target_libdir_str =
316+ config. initial_sysroot . join ( "lib/rustlib" ) . join ( config. build ) . join ( "lib" ) ;
317+
326318 let initial_target_dir = Path :: new ( & initial_target_libdir_str) . parent ( ) . unwrap ( ) ;
327319 let initial_lld = initial_target_dir. join ( "bin" ) . join ( "rust-lld" ) ;
328320
329- let initial_sysroot = if config. dry_run ( ) {
330- "/dummy" . to_string ( )
331- } else {
332- output ( Command :: new ( & config. initial_rustc ) . arg ( "--print" ) . arg ( "sysroot" ) )
333- }
334- . trim ( )
335- . to_string ( ) ;
336-
337- // FIXME(Zalathar): Determining this path occasionally fails locally for
338- // unknown reasons, so we print some extra context to help track down why.
339- let find_initial_libdir = || {
340- let initial_libdir =
341- initial_target_dir. parent ( ) ?. parent ( ) ?. strip_prefix ( & initial_sysroot) . ok ( ) ?;
342- Some ( initial_libdir. to_path_buf ( ) )
343- } ;
344- let Some ( initial_libdir) = find_initial_libdir ( ) else {
345- panic ! (
346- "couldn't determine `initial_libdir`:
347- - config.initial_rustc: {rustc:?}
348- - initial_target_libdir_str: {initial_target_libdir_str:?}
349- - initial_target_dir: {initial_target_dir:?}
350- - initial_sysroot: {initial_sysroot:?}
351- " ,
352- rustc = config. initial_rustc,
353- ) ;
354- } ;
321+ let initial_relative_libdir = initial_target_dir
322+ . ancestors ( )
323+ . nth ( 2 )
324+ . unwrap ( )
325+ . strip_prefix ( & config. initial_sysroot )
326+ . expect ( "Couldn’t determine initial relative libdir." )
327+ . to_path_buf ( ) ;
355328
356329 let version = std:: fs:: read_to_string ( src. join ( "src" ) . join ( "version" ) )
357330 . expect ( "failed to read src/version" ) ;
@@ -380,11 +353,11 @@ impl Build {
380353 }
381354
382355 let mut build = Build {
356+ initial_lld,
357+ initial_relative_libdir,
383358 initial_rustc : config. initial_rustc . clone ( ) ,
384359 initial_cargo : config. initial_cargo . clone ( ) ,
385- initial_lld,
386- initial_libdir,
387- initial_sysroot : initial_sysroot. into ( ) ,
360+ initial_sysroot : config. initial_sysroot . clone ( ) ,
388361 local_rebuild : config. local_rebuild ,
389362 fail_fast : config. cmd . fail_fast ( ) ,
390363 doc_tests : config. cmd . doc_tests ( ) ,
0 commit comments