diff options
| author | bors <bors@rust-lang.org> | 2023-04-02 14:54:31 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-04-02 14:54:31 +0000 |
| commit | 3a8a131e9509c478ece1c58fe0ea2d49463d2300 (patch) | |
| tree | a832b12597d8096326cd41c872c2e5c73d25743b | |
| parent | a5a690cf4bcc53b8e512d51480b00c73b5eaadae (diff) | |
| parent | 28b7e6abff37d280f7077ed1f362ed7954753c75 (diff) | |
| download | rust-3a8a131e9509c478ece1c58fe0ea2d49463d2300.tar.gz rust-3a8a131e9509c478ece1c58fe0ea2d49463d2300.zip | |
Auto merge of #109811 - jyn514:symlink-fixes, r=Mark-Simulacrum
Replace any existing `build/host` symlink This has two advantages: 1. If `build.build` changes between runs, the symlink is no longer silently wrong. 2. If the entire build directory is moved, the symlink is no longer broken because it points to the wrong absolute path.
| -rw-r--r-- | src/bootstrap/lib.rs | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 2ffad594fc7..e3f3ab5243e 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -21,7 +21,6 @@ use std::collections::{HashMap, HashSet}; use std::env; use std::fs::{self, File}; use std::io; -use std::io::ErrorKind; use std::path::{Path, PathBuf}; use std::process::{Command, Stdio}; use std::str; @@ -505,16 +504,18 @@ impl Build { let build_triple = build.out.join(&build.build.triple); t!(fs::create_dir_all(&build_triple)); let host = build.out.join("host"); - if let Err(e) = symlink_dir(&build.config, &build_triple, &host) { - if e.kind() != ErrorKind::AlreadyExists { - panic!( - "symlink_dir({} => {}) failed with {}", - host.display(), - build_triple.display(), - e - ); - } - } + if host.is_symlink() { + // Left over from a previous build; overwrite it. + // This matters if `build.build` has changed between invocations. + #[cfg(windows)] + t!(fs::remove_dir(&host)); + #[cfg(not(windows))] + t!(fs::remove_file(&host)); + } + t!( + symlink_dir(&build.config, &build_triple, &host), + format!("symlink_dir({} => {}) failed", host.display(), build_triple.display()) + ); build } |
