diff options
| author | Zalathar <Zalathar@users.noreply.github.com> | 2024-08-30 15:31:49 +1000 |
|---|---|---|
| committer | Zalathar <Zalathar@users.noreply.github.com> | 2024-08-30 15:45:09 +1000 |
| commit | 21edc735170642d541adb5a2a4c07159e75f8cb0 (patch) | |
| tree | d592820deaf48cebccc474b9711b7907c6d4fbbf | |
| parent | 0d634185dfddefe09047881175f35c65d68dcff1 (diff) | |
| download | rust-21edc735170642d541adb5a2a4c07159e75f8cb0.tar.gz rust-21edc735170642d541adb5a2a4c07159e75f8cb0.zip | |
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.
| -rw-r--r-- | src/bootstrap/src/lib.rs | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index 268392c5fb1..4cb2e343730 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -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"); |
