From 6f041eca19b9d7445aabdb496c404bfd45fcd7d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Rakic?= Date: Tue, 21 Feb 2023 14:25:59 +0000 Subject: [PATCH] fix rustfmt symlink exists check in bootstrap --- src/bootstrap/download.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/download.rs b/src/bootstrap/download.rs index d6592d2d77116..e51a9d77fddce 100644 --- a/src/bootstrap/download.rs +++ b/src/bootstrap/download.rs @@ -342,7 +342,13 @@ impl Config { #[cfg(not(windows))] { let legacy_rustfmt = self.initial_rustc.with_file_name(exe("rustfmt", host)); - if !legacy_rustfmt.exists() { + + // Note: we check here whether the symlink itself exists. `Path::exists` would follow + // the symlink and return whether the linked file exists instead. If `rustfmt_path` does + // not exist but the `legacy_rustfmt` link does, we would recreate it. This was one of + // the perf.rlo errors related to issue #108258. + let symlink_exists = std::fs::read_link(&legacy_rustfmt).is_ok(); + if !symlink_exists { t!(self.symlink_file(&rustfmt_path, &legacy_rustfmt)); } }