blob: aa7d63d3896ee0370e039eeb1e480247c917ba39 [file] [log] [blame]
Dmitry Vyukov530fb942014-03-03 13:15:12 +00001# Build for the experimental deadlock detector runtime library.
2
3include_directories(../..)
4
5set(DD_CFLAGS ${SANITIZER_COMMON_CFLAGS})
6append_no_rtti_flag(DD_CFLAGS)
7
8if("${CMAKE_BUILD_TYPE}" EQUAL "Release")
9 set(DD_COMMON_DEFINITIONS DEBUG=0)
10else()
11 set(DD_COMMON_DEFINITIONS DEBUG=1)
12endif()
13
Dmitry Vyukovd1d86532014-03-04 12:52:20 +000014set(DD_DYNAMIC_DEFINITIONS DYNAMIC=1)
15
Dmitry Vyukov530fb942014-03-03 13:15:12 +000016set(DD_SOURCES
17 dd_rtl.cc
18 dd_interceptors.cc
19)
20
21set(DD_HEADERS
22 dd_rtl.h
23)
24
Viktor Kutuzov68b3e872014-09-17 07:54:46 +000025set(DD_LINKLIBS)
Kuba Brecka14c0c592014-10-15 22:47:54 +000026append_list_if(COMPILER_RT_HAS_LIBDL dl DD_LINKLIBS)
27append_list_if(COMPILER_RT_HAS_LIBPTHREAD pthread DD_LINKLIBS)
Viktor Kutuzov68b3e872014-09-17 07:54:46 +000028
Dmitry Vyukov530fb942014-03-03 13:15:12 +000029add_custom_target(dd)
30# Deadlock detector is currently supported on 64-bit Linux only.
Dmitry Vyukovd1d86532014-03-04 12:52:20 +000031if(CAN_TARGET_x86_64 AND UNIX AND NOT APPLE AND NOT ANDROID)
Dmitry Vyukov530fb942014-03-03 13:15:12 +000032 set(arch "x86_64")
Alexey Samsonov78a84352014-03-31 13:45:36 +000033 add_compiler_rt_runtime(clang_rt.dd-${arch} ${arch} STATIC
Dmitry Vyukov530fb942014-03-03 13:15:12 +000034 SOURCES ${DD_SOURCES}
35 $<TARGET_OBJECTS:RTInterception.${arch}>
36 $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
37 $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
38 CFLAGS ${DD_CFLAGS}
39 DEFS ${DD_COMMON_DEFINITIONS})
Dmitry Vyukovd1d86532014-03-04 12:52:20 +000040
Alexey Samsonov1c9a9212014-06-05 00:58:28 +000041 add_compiler_rt_object_library(RTDD ${arch}
42 SOURCES ${DD_SOURCES} CFLAGS ${DD_CFLAGS}
43 DEFS ${DD_COMMON_DEFINITIONS} ${DD_DYNAMIC_DEFINITIONS})
Dmitry Vyukovd1d86532014-03-04 12:52:20 +000044
Alexey Samsonov1c9a9212014-06-05 00:58:28 +000045 add_compiler_rt_runtime(clang_rt.dyndd-${arch} ${arch} SHARED
46 SOURCES $<TARGET_OBJECTS:RTDD.${arch}>
47 $<TARGET_OBJECTS:RTInterception.${arch}>
48 $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
49 $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>)
Viktor Kutuzov68b3e872014-09-17 07:54:46 +000050 target_link_libraries(clang_rt.dyndd-${arch} ${DD_LINKLIBS})
Dmitry Vyukov530fb942014-03-03 13:15:12 +000051endif()
52
53add_dependencies(compiler-rt dd)
54