Skip to content

Commit 68e4518

Browse files
committed
Revert "[NFC][sanitizer] Switch to gnu_get_libc_version (llvm#108724)"
This reverts commit 69f3244. Reason: buildbot breakage because Android doesn't have <gnu/libc-version.h> https://lab.llvm.org/buildbot/#/builders/186/builds/2381 (It's probably easy to fix but I don't readily have an Android device to test.)
1 parent 73d83f2 commit 68e4518

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@
4040
# include <sys/resource.h>
4141
# include <syslog.h>
4242

43-
# ifdef SANITIZER_GLIBC
44-
# include <gnu/libc-version.h>
45-
# endif
46-
4743
# if !defined(ElfW)
4844
# define ElfW(type) Elf_##type
4945
# endif
@@ -202,11 +198,17 @@ bool SetEnv(const char *name, const char *value) {
202198

203199
__attribute__((unused)) static bool GetLibcVersion(int *major, int *minor,
204200
int *patch) {
205-
# ifdef SANITIZER_GLIBC
206-
const char *p = gnu_get_libc_version();
201+
# ifdef _CS_GNU_LIBC_VERSION
202+
char buf[64];
203+
uptr len = confstr(_CS_GNU_LIBC_VERSION, buf, sizeof(buf));
204+
if (len >= sizeof(buf))
205+
return false;
206+
buf[len] = 0;
207+
static const char kGLibC[] = "glibc ";
208+
if (internal_strncmp(buf, kGLibC, sizeof(kGLibC) - 1) != 0)
209+
return false;
210+
const char *p = buf + sizeof(kGLibC) - 1;
207211
*major = internal_simple_strtoll(p, &p, 10);
208-
// Caller does not expect anything else.
209-
CHECK_EQ(*major, 2);
210212
*minor = (*p == '.') ? internal_simple_strtoll(p + 1, &p, 10) : 0;
211213
*patch = (*p == '.') ? internal_simple_strtoll(p + 1, &p, 10) : 0;
212214
return true;

0 commit comments

Comments
 (0)