[tsan] Refine fstat{,64} interceptors (#86625)
authorFangrui Song <i@maskray.me>
Tue, 26 Mar 2024 21:09:39 +0000 (14:09 -0700)
committerllvmbot <llvmbot@llvm.org>
Mon, 1 Apr 2024 22:10:23 +0000 (22:10 +0000)
commitf249092ef26d6fe9627b0158c7c15dee241226db
tree6d871ca0ad6f2cb9b674c5ea4cf3c4089981ecf2
parent76c721994a11abe898848699ea82da267ebc8320
[tsan] Refine fstat{,64} interceptors (#86625)

In glibc versions before 2.33. `libc_nonshared.a` defines
`__fxstat/__fxstat64` but there is no `fstat/fstat64`. glibc 2.33 added
`fstat/fstat64` and obsoleted `__fxstat/__fxstat64`. Ports added after
2.33 do not provide `__fxstat/__fxstat64`, so our `fstat/fstat64`
interceptors using `__fxstat/__fxstat64` interceptors would lead to
runtime failures on such ports (LoongArch and certain RISC-V ports).

Similar to https://reviews.llvm.org/D118423, refine the conditions that
we define fstat{,64} interceptors. `fstat` is supported by musl/*BSD
while `fstat64` is glibc only.

(cherry picked from commit d5224b73ccd09a6759759791f58426b6acd4a2e2)
compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp