[sanitizer] Restrict clock_gettime workaround to glibc
authorFangrui Song <i@maskray.me>
Sat, 6 Mar 2021 18:32:27 +0000 (10:32 -0800)
committerFangrui Song <i@maskray.me>
Sat, 6 Mar 2021 18:32:27 +0000 (10:32 -0800)
commitca747e48afa091afd8568df8973dfcbd43b8e334
tree548168eb3d71ae0f01d7415ea6a4d96225715789
parentd163e75c81c1609855b98cbdffa0141c70d8578d
[sanitizer] Restrict clock_gettime workaround to glibc

The hackery is due to glibc clock_gettime crashing from preinit_array (D40679).
32-bit musl architectures do not define `__NR_clock_gettime` so the code causes a compile error.

Tested on Alpine Linux x86-64 (musl) and FreeBSD x86-64.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D96925
compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
compiler-rt/lib/sanitizer_common/sanitizer_linux.h
compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp