Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / lib / tsan / CMakeLists.txt
blobc5ec6b0ddfd229b3541e23d7058a337627b22af4
1 # Build for the ThreadSanitizer runtime support library.
3 set(TSAN_CFLAGS ${SANITIZER_COMMON_CFLAGS})
4 # SANITIZER_COMMON_CFLAGS contains -fPIC, but it's performance-critical for
5 # 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.
7 if(NOT CMAKE_SYSTEM MATCHES "FreeBSD")
8   append_list_if(COMPILER_RT_HAS_FPIE_FLAG -fPIE TSAN_CFLAGS)
9 endif()
10 append_rtti_flag(OFF TSAN_CFLAGS)
12 if(COMPILER_RT_TSAN_DEBUG_OUTPUT)
13   # Add extra debug information to TSan runtime. This configuration is rarely
14   # used, but we need to support it so that debug output will not bitrot.
15   list(APPEND TSAN_CFLAGS -DTSAN_DEBUG_OUTPUT=2)
16 endif()
18 # Add the actual runtime library.
19 add_subdirectory(rtl)
21 # Build libcxx instrumented with TSan.
22 if(COMPILER_RT_LIBCXX_PATH AND
23    COMPILER_RT_LIBCXXABI_PATH AND
24    COMPILER_RT_TEST_COMPILER_ID STREQUAL "Clang" AND
25    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=thread
33       USE_TOOLCHAIN)
34     list(APPEND libcxx_tsan_deps libcxx_tsan_${arch}-build)
35   endforeach()
37   add_custom_target(libcxx_tsan DEPENDS ${libcxx_tsan_deps})
38   set_target_properties(libcxx_tsan PROPERTIES FOLDER "Compiler-RT Misc")
39 endif()
41 if(COMPILER_RT_INCLUDE_TESTS)
42   add_subdirectory(tests)
43 endif()