@@ -158,7 +158,7 @@ pub struct Build {
158
158
initial_rustc : PathBuf ,
159
159
initial_cargo : PathBuf ,
160
160
initial_lld : PathBuf ,
161
- initial_libdir : PathBuf ,
161
+ initial_relative_libdir : PathBuf ,
162
162
initial_sysroot : PathBuf ,
163
163
164
164
// Runtime state filled in later on
@@ -312,46 +312,19 @@ impl Build {
312
312
let in_tree_llvm_info = config. in_tree_llvm_info . clone ( ) ;
313
313
let in_tree_gcc_info = config. in_tree_gcc_info . clone ( ) ;
314
314
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
+
326
318
let initial_target_dir = Path :: new ( & initial_target_libdir_str) . parent ( ) . unwrap ( ) ;
327
319
let initial_lld = initial_target_dir. join ( "bin" ) . join ( "rust-lld" ) ;
328
320
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 ( ) ;
355
328
356
329
let version = std:: fs:: read_to_string ( src. join ( "src" ) . join ( "version" ) )
357
330
. expect ( "failed to read src/version" ) ;
@@ -380,11 +353,11 @@ impl Build {
380
353
}
381
354
382
355
let mut build = Build {
356
+ initial_lld,
357
+ initial_relative_libdir,
383
358
initial_rustc : config. initial_rustc . clone ( ) ,
384
359
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 ( ) ,
388
361
local_rebuild : config. local_rebuild ,
389
362
fail_fast : config. cmd . fail_fast ( ) ,
390
363
doc_tests : config. cmd . doc_tests ( ) ,
0 commit comments