diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-10-08 23:32:03 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-08 23:32:03 +0200 |
| commit | 5d2c29d2a1a8477ecbbbfb1a88b20ce07664e580 (patch) | |
| tree | 407439e583bb7d4c4083bc213e330b0dd2ddb4a8 /src/bootstrap | |
| parent | 6776cac4c1ba658fb9154a27fbe54a49f46b4071 (diff) | |
| parent | 67220d69702b4428a811d063fce3045da7a4040d (diff) | |
| download | rust-5d2c29d2a1a8477ecbbbfb1a88b20ce07664e580.tar.gz rust-5d2c29d2a1a8477ecbbbfb1a88b20ce07664e580.zip | |
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 https://github.com/rust-lang/rust/issues/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`
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/config.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 8c501f637d9..da2d1c1301d 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -829,10 +829,19 @@ impl Config { let s = git_root.to_str().unwrap(); // Bootstrap is quite bad at handling /? in front of paths - config.src = match s.strip_prefix("\\\\?\\") { + let src = match s.strip_prefix("\\\\?\\") { Some(p) => PathBuf::from(p), None => PathBuf::from(git_root), }; + // If this doesn't have at least `stage0.json`, we guessed wrong. This can happen when, + // for example, the build directory is inside of another unrelated git directory. + // In that case keep the original `CARGO_MANIFEST_DIR` handling. + // + // NOTE: this implies that downloadable bootstrap isn't supported when the build directory is outside + // the source directory. We could fix that by setting a variable from all three of python, ./x, and x.ps1. + if src.join("src").join("stage0.json").exists() { + config.src = src; + } } else { // We're building from a tarball, not git sources. // We don't support pre-downloaded bootstrap in this case. |
