Skip to content

Commit 5d2c29d

Browse files
authored
Rollup merge of #102581 - jyn514:src-detection, r=Mark-Simulacrum
Make the `config.src` handling for downloadable bootstrap more conservative In particular, this supports build directories within an unrelated git repository. Fixes #102562. As a side effect, it will fall back to the old logic when the source directory is being built from a tarball within an unrelated git repository. However, that second case is unsupported and untested; we reserve the right to break it in the future. `@cr1901` can you confirm this fixes your problem? cc `@kleisauke,` I believe this will also fix your issue (although your use case still isn't supported). r? `@Mark-Simulacrum`
2 parents 6776cac + 67220d6 commit 5d2c29d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/bootstrap/config.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -829,10 +829,19 @@ impl Config {
829829
let s = git_root.to_str().unwrap();
830830

831831
// Bootstrap is quite bad at handling /? in front of paths
832-
config.src = match s.strip_prefix("\\\\?\\") {
832+
let src = match s.strip_prefix("\\\\?\\") {
833833
Some(p) => PathBuf::from(p),
834834
None => PathBuf::from(git_root),
835835
};
836+
// If this doesn't have at least `stage0.json`, we guessed wrong. This can happen when,
837+
// for example, the build directory is inside of another unrelated git directory.
838+
// In that case keep the original `CARGO_MANIFEST_DIR` handling.
839+
//
840+
// NOTE: this implies that downloadable bootstrap isn't supported when the build directory is outside
841+
// the source directory. We could fix that by setting a variable from all three of python, ./x, and x.ps1.
842+
if src.join("src").join("stage0.json").exists() {
843+
config.src = src;
844+
}
836845
} else {
837846
// We're building from a tarball, not git sources.
838847
// We don't support pre-downloaded bootstrap in this case.

0 commit comments

Comments
 (0)