Skip to content

Commit

Permalink
bootstrap: Try to track down why initial_libdir sometimes fails
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Zalathar committed Aug 30, 2024
1 parent 0d63418 commit 21edc73
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/bootstrap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,14 +332,20 @@ impl Build {
.trim()
.to_string();

let initial_libdir = initial_target_dir
.parent()
.unwrap()
.parent()
.unwrap()
.strip_prefix(&initial_sysroot)
.unwrap()
.to_path_buf();
// FIXME(Zalathar): Determining this path occasionally fails locally for
// unknown reasons, so we print some extra context to help track down why.
let find_initial_libdir = || {
let initial_libdir =
initial_target_dir.parent()?.parent()?.strip_prefix(&initial_sysroot).ok()?;
Some(initial_libdir.to_path_buf())
};
let Some(initial_libdir) = find_initial_libdir() else {
panic!(
"couldn't determine `initial_libdir` \
from target dir {initial_target_dir:?} \
and sysroot {initial_sysroot:?}"
)
};

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

0 comments on commit 21edc73

Please sign in to comment.