[PATCH] D33131: [compiler-rt][cmake] Build unit tests conditionally with _FILE_OFFSET_BITS=64 and _LARGEFILE_SOURCE

Simon Dardis via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 12 08:36:35 PDT 2017


sdardis created this revision.
Herald added subscribers: arichardson, mgorny, dberris, kubamracek.

The sanitizer library unit tests for libc can get a different definition
of 'struct stat' to what the sanitizer library is built with for certain
targets.

For MIPS the size element of 'struct stat' is after a macro guarded
explicit padding element.

This patch resolves any possible inconsistency by adding the same
_FILE_OFFSET_BITS=64 and _LARGE_SOURCE with the same
conditions as the sanitizer library to the build flags for the unit tests.

This resolves a recurring build failure on the MIPS buildbots due to
'struct stat' defintion differences.


https://reviews.llvm.org/D33131

Files:
  lib/sanitizer_common/tests/CMakeLists.txt


Index: lib/sanitizer_common/tests/CMakeLists.txt
===================================================================
--- lib/sanitizer_common/tests/CMakeLists.txt
+++ lib/sanitizer_common/tests/CMakeLists.txt
@@ -146,6 +146,15 @@
 # Adds sanitizer tests for architecture.
 macro(add_sanitizer_tests_for_arch arch)
   get_target_flags_for_arch(${arch} TARGET_FLAGS)
+
+  # If the sanitizer library was built with _FILE_OFFSET_BITS=64 we need
+  # to ensure that the library and tests agree on the layout of certain
+  # structures such as 'struct stat'.
+  if( CMAKE_SIZEOF_VOID_P EQUAL 4 )
+    list(APPEND TARGET_FLAGS "-D_LARGEFILE_SOURCE")
+    list(APPEND TARGET_FLAGS "-D_FILE_OFFSET_BITS=64")
+  endif()
+
   set(SANITIZER_TEST_SOURCES ${SANITIZER_UNITTESTS}
                              ${COMPILER_RT_GTEST_SOURCE})
   set(SANITIZER_TEST_COMPILE_DEPS ${SANITIZER_TEST_HEADERS})


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33131.98773.patch
Type: text/x-patch
Size: 886 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170512/0e6510c0/attachment.bin>


More information about the llvm-commits mailing list