Dmitry Vyukov | 530fb94 | 2014-03-03 13:15:12 +0000 | [diff] [blame] | 1 | # Build for the experimental deadlock detector runtime library. |
| 2 | |
| 3 | include_directories(../..) |
| 4 | |
| 5 | set(DD_CFLAGS ${SANITIZER_COMMON_CFLAGS}) |
| 6 | append_no_rtti_flag(DD_CFLAGS) |
| 7 | |
| 8 | if("${CMAKE_BUILD_TYPE}" EQUAL "Release") |
| 9 | set(DD_COMMON_DEFINITIONS DEBUG=0) |
| 10 | else() |
| 11 | set(DD_COMMON_DEFINITIONS DEBUG=1) |
| 12 | endif() |
| 13 | |
Dmitry Vyukov | d1d8653 | 2014-03-04 12:52:20 +0000 | [diff] [blame^] | 14 | set(DD_DYNAMIC_DEFINITIONS DYNAMIC=1) |
| 15 | |
Dmitry Vyukov | 530fb94 | 2014-03-03 13:15:12 +0000 | [diff] [blame] | 16 | set(DD_SOURCES |
| 17 | dd_rtl.cc |
| 18 | dd_interceptors.cc |
| 19 | ) |
| 20 | |
| 21 | set(DD_HEADERS |
| 22 | dd_rtl.h |
| 23 | ) |
| 24 | |
| 25 | add_custom_target(dd) |
| 26 | # Deadlock detector is currently supported on 64-bit Linux only. |
Dmitry Vyukov | d1d8653 | 2014-03-04 12:52:20 +0000 | [diff] [blame^] | 27 | if(CAN_TARGET_x86_64 AND UNIX AND NOT APPLE AND NOT ANDROID) |
Dmitry Vyukov | 530fb94 | 2014-03-03 13:15:12 +0000 | [diff] [blame] | 28 | set(arch "x86_64") |
| 29 | add_compiler_rt_static_runtime(clang_rt.dd-${arch} ${arch} |
| 30 | SOURCES ${DD_SOURCES} |
| 31 | $<TARGET_OBJECTS:RTInterception.${arch}> |
| 32 | $<TARGET_OBJECTS:RTSanitizerCommon.${arch}> |
| 33 | $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}> |
| 34 | CFLAGS ${DD_CFLAGS} |
| 35 | DEFS ${DD_COMMON_DEFINITIONS}) |
Dmitry Vyukov | d1d8653 | 2014-03-04 12:52:20 +0000 | [diff] [blame^] | 36 | |
| 37 | add_library(RTDD OBJECT ${DD_SOURCES}) |
| 38 | set_target_compile_flags(RTDD ${DD_CFLAGS}) |
| 39 | set_property(TARGET RTDD APPEND PROPERTY |
| 40 | COMPILE_DEFINITIONS ${DD_COMMON_DEFINITIONS}) |
| 41 | set_property(TARGET RTDD APPEND PROPERTY |
| 42 | COMPILE_DEFINITIONS ${DD_DYNAMIC_DEFINITIONS}) |
| 43 | |
| 44 | add_library(clang_rt.dyndd-${arch} SHARED |
| 45 | $<TARGET_OBJECTS:RTDD> |
| 46 | $<TARGET_OBJECTS:RTInterception.${arch}> |
| 47 | $<TARGET_OBJECTS:RTSanitizerCommon.${arch}> |
| 48 | $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>) |
| 49 | # set_target_compile_flags(clang_rt.dd-${arch} ${DD_CFLAGS}) |
| 50 | # set_property(TARGET clang_rt.dd-${arch} APPEND PROPERTY |
| 51 | # COMPILE_DEFINITIONS ${DD_COMMON_DEFINITIONS}) |
| 52 | target_link_libraries(clang_rt.dyndd-${arch} pthread dl) |
Dmitry Vyukov | 530fb94 | 2014-03-03 13:15:12 +0000 | [diff] [blame] | 53 | endif() |
| 54 | |
| 55 | add_dependencies(compiler-rt dd) |
| 56 | |