summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorR. Voggenauer <rvogg@users.noreply.github.com>2023-02-14 15:21:06 +0100
committerTobias Hieta <tobias@hieta.se>2023-02-20 09:33:05 +0100
commit6cdd68401c3513584c72826b2c9d4473e0ea026c (patch)
treed0b8569aa8cea48e3b9ea079712489fec8a4f2a3
parent1ab37a25e463ea144289a1cbcf32a7659b2d60bb (diff)
downloadllvm-6cdd68401c3513584c72826b2c9d4473e0ea026c.tar.gz
[Support] [Windows] Don't check file access time in equivalent(file_status, file_status)
The sys::fs::equivalent(file_status, file_status) function is meant to judge whether two file_status structs denote the same individual file. On Unix, this is implemented by only comparing the st_dev and st_ino numbers (from stat), ignoring all other fields. On Windows, lacking reliable fields corresponding to st_dev and st_ino, equivalent(file_status, file_status) compares essentially all fields. However, since 1e39ef331b2b78baec84fdb577d497511cc46bd5 (https://reviews.llvm.org/D18456), file_status also contains the file access time. Including the file access time in equivalent(file_status, file_status) makes it possible to spuriously break. In particular, when invoking equivalent(Twine, Twine), with two paths, there's a race condition - the function calls status() on both input paths. Even if the two paths are the same, the comparison can fail, if the file was accessed between the two status() calls. Thus, it seems like the inclusion of the access time in equivalent(file_status, file_status) was a mistake. This race condition can cause spurious failures when linking with LLD/ELF, where LLD uses equivalent() to check whether a file exists within a specific sysroot, and that sysroot is accessed by other processes concurrently. This fixes downstream issue https://github.com/msys2/MINGW-packages/issues/15695. Differential Revision: https://reviews.llvm.org/D144172 (cherry picked from commit a1e80c69223a091e6f0fc84df33a464604c8bbc1)
-rw-r--r--llvm/lib/Support/Windows/Path.inc2
1 files changed, 0 insertions, 2 deletions
diff --git a/llvm/lib/Support/Windows/Path.inc b/llvm/lib/Support/Windows/Path.inc
index 92cf4fcda5a6..7106a67b576a 100644
--- a/llvm/lib/Support/Windows/Path.inc
+++ b/llvm/lib/Support/Windows/Path.inc
@@ -650,8 +650,6 @@ bool equivalent(file_status A, file_status B) {
return A.FileIndexHigh == B.FileIndexHigh &&
A.FileIndexLow == B.FileIndexLow && A.FileSizeHigh == B.FileSizeHigh &&
A.FileSizeLow == B.FileSizeLow &&
- A.LastAccessedTimeHigh == B.LastAccessedTimeHigh &&
- A.LastAccessedTimeLow == B.LastAccessedTimeLow &&
A.LastWriteTimeHigh == B.LastWriteTimeHigh &&
A.LastWriteTimeLow == B.LastWriteTimeLow &&
A.VolumeSerialNumber == B.VolumeSerialNumber;