[PATCH] D60644: [compiler-rt][builtins][sanitizers] Guard test cases with macros with GLIBC* macros

Amy Kwan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 23 13:21:22 PDT 2019


amyk updated this revision to Diff 196306.
amyk retitled this revision from "[compiler-rt][builtins][sanitizers] Guard test cases with macros to run when specific version of GLIBC is detected " to "[compiler-rt][builtins][sanitizers] Guard test cases with macros with GLIBC* macros ".
amyk edited the summary of this revision.
amyk added a comment.

**Originally, this patch modified the following to check for the version of GLIBC**:

- Compiler-RT builtins test cases: `compiler_rt_logb_test.c`, `divsc3_test.c`, `ppc/qdiv_test.c`
- Sanitizer test case: `getpw_getgr.cc`

**Updated this patch to**:

- Change only `compiler-rt/test/builtins/Unit/compiler_rt_logb_test.c ` and `compiler-rt/test/sanitizer_common/TestCases/Posix/getpw_getgr.cc` tests
- Guard the problematic lines of the `getpw_getgr.cc` test to check for the macro, `_GLIBCXX_USE_CXX11_ABI` instead, as this test no longer appears to be an issue related to the GLIBC version. If this macro is set to 1 (meaning, the C++11 ABI is used), then execute the lines
- Other compiler-rt builtin failures are avoided by building with a higher version of GCC, so I will not be modifying other tests


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60644/new/

https://reviews.llvm.org/D60644

Files:
  compiler-rt/test/builtins/Unit/compiler_rt_logb_test.c
  compiler-rt/test/sanitizer_common/TestCases/Posix/getpw_getgr.cc


Index: compiler-rt/test/sanitizer_common/TestCases/Posix/getpw_getgr.cc
===================================================================
--- compiler-rt/test/sanitizer_common/TestCases/Posix/getpw_getgr.cc
+++ compiler-rt/test/sanitizer_common/TestCases/Posix/getpw_getgr.cc
@@ -72,7 +72,11 @@
   test<passwd>(&getpwuid, 0);
   test<passwd>(&getpwnam, "root");
   test<group>(&getgrgid, 0);
+  // Run this if we're using the C++11 ABI. There seems to be an issue
+  // that maybe related to _GLIBCXX_USE_CXX11_ABI and the string assigned.
+#if _GLIBCXX_USE_CXX11_ABI
   test<group>(&getgrnam, any_group.c_str());
+#endif
 
 #if !defined(__ANDROID__)
   setpwent();
@@ -91,7 +95,11 @@
   test_r<passwd>(&getpwnam_r, "root");
 
   test_r<group>(&getgrgid_r, 0);
+  // Run this if we're using the C++11 ABI. There seems to be an issue
+  // that maybe related to _GLIBCXX_USE_CXX11_ABI and the string assigned.
+#if _GLIBCXX_USE_CXX11_ABI
   test_r<group>(&getgrnam_r, any_group.c_str());
+#endif
 
 #if defined(__linux__)
   auto pwd_file = [] {
Index: compiler-rt/test/builtins/Unit/compiler_rt_logb_test.c
===================================================================
--- compiler-rt/test/builtins/Unit/compiler_rt_logb_test.c
+++ compiler-rt/test/builtins/Unit/compiler_rt_logb_test.c
@@ -36,6 +36,11 @@
 };
 
 int main() {
+  // Run the compiler-rt logb test case if the GLIBC
+  // version is >= 2.23. Older versions of libm may not
+  // compute to the same value as the compiler-rt value.
+#if defined(__GLIBC__) && defined(__GLIBC_MINOR__) && \
+    defined (__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 23)
   const unsigned N = sizeof(cases) / sizeof(cases[0]);
   unsigned i;
   for (i = 0; i < N; ++i) {
@@ -57,6 +62,7 @@
     if (test__compiler_rt_logb(fromRep(signBit ^ x))) return 1;
     x >>= 1;
   }
+#endif
 
   return 0;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60644.196306.patch
Type: text/x-patch
Size: 1843 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190423/9e478637/attachment-0001.bin>


More information about the llvm-commits mailing list