Skip to content

Commit

Permalink
[compiler-rt][cmake] Build unit tests conditionally with _FILE_OFFSET…
Browse files Browse the repository at this point in the history
…_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

llvm-svn: 303350
  • Loading branch information
Simon Dardis committed May 18, 2017
1 parent 7bca591 commit 657899b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions compiler-rt/lib/sanitizer_common/tests/CMakeLists.txt
Expand Up @@ -146,6 +146,15 @@ set_target_properties(SanitizerUnitTests PROPERTIES FOLDER "Compiler-RT Tests")
# 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})
Expand Down

0 comments on commit 657899b

Please sign in to comment.