Skip to content

Commit 21edc73

Browse files
committed
bootstrap: Try to track down why initial_libdir sometimes fails
Determining this path occasionally fails locally for unknown reasons, resulting in the build failing with an unhelpful `StripPrefixError(())` panic message. In order to track down why that's happening, include some relevant information in the panic message when that failure occurs.
1 parent 0d63418 commit 21edc73

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

Diff for: src/bootstrap/src/lib.rs

+14-8
Original file line numberDiff line numberDiff line change
@@ -332,14 +332,20 @@ impl Build {
332332
.trim()
333333
.to_string();
334334

335-
let initial_libdir = initial_target_dir
336-
.parent()
337-
.unwrap()
338-
.parent()
339-
.unwrap()
340-
.strip_prefix(&initial_sysroot)
341-
.unwrap()
342-
.to_path_buf();
335+
// FIXME(Zalathar): Determining this path occasionally fails locally for
336+
// unknown reasons, so we print some extra context to help track down why.
337+
let find_initial_libdir = || {
338+
let initial_libdir =
339+
initial_target_dir.parent()?.parent()?.strip_prefix(&initial_sysroot).ok()?;
340+
Some(initial_libdir.to_path_buf())
341+
};
342+
let Some(initial_libdir) = find_initial_libdir() else {
343+
panic!(
344+
"couldn't determine `initial_libdir` \
345+
from target dir {initial_target_dir:?} \
346+
and sysroot {initial_sysroot:?}"
347+
)
348+
};
343349

344350
let version = std::fs::read_to_string(src.join("src").join("version"))
345351
.expect("failed to read src/version");

0 commit comments

Comments
 (0)