[compiler-rt] 68e4518 - Revert "[NFC][sanitizer] Switch to `gnu_get_libc_version` (#108724)"

Thurston Dang via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 16 12:11:41 PDT 2024


Author: Thurston Dang
Date: 2024-09-16T19:11:27Z
New Revision: 68e4518598d63efa02230f400e50263baccbb8e4

URL: https://github.com/llvm/llvm-project/commit/68e4518598d63efa02230f400e50263baccbb8e4
DIFF: https://github.com/llvm/llvm-project/commit/68e4518598d63efa02230f400e50263baccbb8e4.diff

LOG: Revert "[NFC][sanitizer] Switch to `gnu_get_libc_version` (#108724)"

This reverts commit 69f3244da76586be393d1e97b01660c6f03d666c.

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.)

Added: 
    

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
index 92ac1072aaf673..f272a54b2b907c 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
@@ -40,10 +40,6 @@
 #  include <sys/resource.h>
 #  include <syslog.h>
 
-#  ifdef SANITIZER_GLIBC
-#    include <gnu/libc-version.h>
-#  endif
-
 #  if !defined(ElfW)
 #    define ElfW(type) Elf_##type
 #  endif
@@ -202,11 +198,17 @@ bool SetEnv(const char *name, const char *value) {
 
 __attribute__((unused)) static bool GetLibcVersion(int *major, int *minor,
                                                    int *patch) {
-#  ifdef SANITIZER_GLIBC
-  const char *p = gnu_get_libc_version();
+#  ifdef _CS_GNU_LIBC_VERSION
+  char buf[64];
+  uptr len = confstr(_CS_GNU_LIBC_VERSION, buf, sizeof(buf));
+  if (len >= sizeof(buf))
+    return false;
+  buf[len] = 0;
+  static const char kGLibC[] = "glibc ";
+  if (internal_strncmp(buf, kGLibC, sizeof(kGLibC) - 1) != 0)
+    return false;
+  const char *p = buf + sizeof(kGLibC) - 1;
   *major = internal_simple_strtoll(p, &p, 10);
-  // Caller does not expect anything else.
-  CHECK_EQ(*major, 2);
   *minor = (*p == '.') ? internal_simple_strtoll(p + 1, &p, 10) : 0;
   *patch = (*p == '.') ? internal_simple_strtoll(p + 1, &p, 10) : 0;
   return true;


        


More information about the llvm-commits mailing list