[NFC][sanitizer] Switch to gnu_get_libc_version#108724
Merged
vitalybuka merged 5 commits intomainfrom Sep 16, 2024
Merged
Conversation
Created using spr 1.3.4 [skip ci]
Created using spr 1.3.4
Member
|
@llvm/pr-subscribers-compiler-rt-sanitizer Author: Vitaly Buka (vitalybuka) Changes
Looks like we use Full diff: https://github.com/llvm/llvm-project/pull/108724.diff 1 Files Affected:
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
index 071ecc4516e0f0..bc3a41bba03fc1 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
@@ -40,6 +40,10 @@
# 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
@@ -198,17 +202,11 @@ bool SetEnv(const char *name, const char *value) {
__attribute__((unused)) static bool GetLibcVersion(int *major, int *minor,
int *patch) {
-# 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;
+# ifdef SANITIZER_GLIBC
+ const char *p = gnu_get_libc_version();
*major = internal_simple_strtoll(p, &p, 10);
+ // Caller do 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;
|
Member
|
The header gnu/libc-version.h has been in glibc available since 1998. Nice! |
MaskRay
approved these changes
Sep 16, 2024
MaskRay
reviewed
Sep 16, 2024
thurstond
approved these changes
Sep 16, 2024
Created using spr 1.3.4 [skip ci]
thurstond
added a commit
that referenced
this pull request
Sep 16, 2024
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.)
tmsri
pushed a commit
to tmsri/llvm-project
that referenced
this pull request
Sep 19, 2024
…)" (llvm#108885) In llvm#108724 `#ifdef` was used instead of `#if`. This reverts commit 68e4518.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
gnu_get_libc_versionunlikeconfstris notintercepted. We should be able to use this
function earier.
Looks like we use
confstrstaring fromhttps://gcc.gnu.org/bugzilla/show_bug.cgi?id=60038
but there is no specific reason to refer it over
gnu_get_libc_version.