brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · 3319855 Raw
45 lines · plain
1# Build for the ThreadSanitizer runtime support library.2 3set(TSAN_CFLAGS ${SANITIZER_COMMON_CFLAGS})4# SANITIZER_COMMON_CFLAGS contains -fPIC, but it's performance-critical for5# TSan runtime to be built with -fPIE to reduce the number of register spills.6# On FreeBSD however it provokes linkage issue thus we disable it.7if(NOT CMAKE_SYSTEM MATCHES "FreeBSD")8  append_list_if(COMPILER_RT_HAS_FPIE_FLAG -fPIE TSAN_CFLAGS)9endif()10append_rtti_flag(OFF TSAN_CFLAGS)11 12if(COMPILER_RT_TSAN_DEBUG_OUTPUT)13  # Add extra debug information to TSan runtime. This configuration is rarely14  # used, but we need to support it so that debug output will not bitrot.15  list(APPEND TSAN_CFLAGS -DTSAN_DEBUG_OUTPUT=2)16endif()17 18# Add the actual runtime library.19add_subdirectory(rtl)20 21# Build libcxx instrumented with TSan.22if(COMPILER_RT_LIBCXX_PATH AND23   COMPILER_RT_LIBCXXABI_PATH AND24   COMPILER_RT_TEST_COMPILER_ID STREQUAL "Clang" AND25   NOT ANDROID)26  set(libcxx_tsan_deps)27  foreach(arch ${TSAN_SUPPORTED_ARCH})28    get_target_flags_for_arch(${arch} TARGET_CFLAGS)29    set(LIBCXX_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/libcxx_tsan_${arch})30    add_custom_libcxx(libcxx_tsan_${arch} ${LIBCXX_PREFIX}31      DEPS ${TSAN_RUNTIME_LIBRARIES}32      CFLAGS ${TARGET_CFLAGS} -fsanitize=thread33      CMAKE_ARGS -DRUNTIMES_EXECUTE_ONLY_CODE=${RUNTIMES_EXECUTE_ONLY_CODE}34      USE_TOOLCHAIN)35    list(APPEND libcxx_tsan_deps libcxx_tsan_${arch}-install-cmake326-workaround)36  endforeach()37 38  add_custom_target(libcxx_tsan DEPENDS ${libcxx_tsan_deps})39  set_target_properties(libcxx_tsan PROPERTIES FOLDER "Compiler-RT/Metatargets")40endif()41 42if(COMPILER_RT_INCLUDE_TESTS)43  add_subdirectory(tests)44endif()45