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

Simon Dardis via llvm-commits llvm-commits at lists.llvm.org
Thu May 18 06:19:35 PDT 2017


Author: sdardis
Date: Thu May 18 08:19:35 2017
New Revision: 303350

URL: http://llvm.org/viewvc/llvm-project?rev=303350&view=rev
Log:
[compiler-rt][cmake] Build unit tests conditionally with _FILE_OFFSET_BITS=64 and _LARGEFILE_SOURCE

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.

Reviewers: slthakur

Differential Revision: https://reviews.llvm.org/D33131


Modified:
    compiler-rt/trunk/lib/sanitizer_common/tests/CMakeLists.txt

Modified: compiler-rt/trunk/lib/sanitizer_common/tests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/CMakeLists.txt?rev=303350&r1=303349&r2=303350&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/CMakeLists.txt Thu May 18 08:19:35 2017
@@ -146,6 +146,15 @@ set_target_properties(SanitizerUnitTests
 # 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})




More information about the llvm-commits mailing list