blob: daad07f330c0afe2878312c5b59201827ca00913 [file] [log] [blame]
Peter Collingbourneeee71ae2013-08-07 22:47:26 +00001include_directories(..)
2
3# Runtime library sources and build flags.
4set(DFSAN_RTL_SOURCES
Peter Collingbourne6e4c46d2013-08-15 21:18:53 +00005 dfsan.cc
6 dfsan_custom.cc
7 dfsan_interceptors.cc)
Stephen Hines2d1fdb22014-05-28 23:58:16 -07008set(DFSAN_COMMON_CFLAGS ${SANITIZER_COMMON_CFLAGS})
9# Prevent clang from generating libc calls.
Stephen Hines6d186232014-11-26 17:56:19 -080010append_list_if(COMPILER_RT_HAS_FFREESTANDING_FLAG -ffreestanding DFSAN_COMMON_CFLAGS)
Peter Collingbourneeee71ae2013-08-07 22:47:26 +000011
12# Static runtime library.
Stephen Hines2d1fdb22014-05-28 23:58:16 -070013add_custom_target(dfsan)
Peter Collingbourneeee71ae2013-08-07 22:47:26 +000014set(arch "x86_64")
15if(CAN_TARGET_${arch})
Stephen Hines2d1fdb22014-05-28 23:58:16 -070016 set(DFSAN_CFLAGS ${DFSAN_COMMON_CFLAGS})
Stephen Hines6d186232014-11-26 17:56:19 -080017 append_list_if(COMPILER_RT_HAS_FPIE_FLAG -fPIE DFSAN_CFLAGS)
Stephen Hines2d1fdb22014-05-28 23:58:16 -070018 add_compiler_rt_runtime(clang_rt.dfsan-${arch} ${arch} STATIC
Peter Collingbourneeee71ae2013-08-07 22:47:26 +000019 SOURCES ${DFSAN_RTL_SOURCES}
20 $<TARGET_OBJECTS:RTInterception.${arch}>
21 $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
22 $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
Stephen Hines2d1fdb22014-05-28 23:58:16 -070023 CFLAGS ${DFSAN_CFLAGS})
24 set(DFSAN_NOLIBC_CFLAGS ${DFSAN_COMMON_CFLAGS} -DDFSAN_NOLIBC)
25 add_compiler_rt_runtime(clang_rt.dfsan-libc-${arch} ${arch} STATIC
Peter Collingbourneeee71ae2013-08-07 22:47:26 +000026 SOURCES ${DFSAN_RTL_SOURCES}
27 $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
Stephen Hines2d1fdb22014-05-28 23:58:16 -070028 CFLAGS ${DFSAN_NOLIBC_CFLAGS})
Peter Collingbourneba945f82013-08-29 22:49:00 +000029 add_sanitizer_rt_symbols(clang_rt.dfsan-${arch} dfsan.syms.extra)
Stephen Hines2d1fdb22014-05-28 23:58:16 -070030 add_dependencies(dfsan
31 clang_rt.dfsan-${arch}
32 clang_rt.dfsan-${arch}-symbols)
Peter Collingbourneeee71ae2013-08-07 22:47:26 +000033endif()
34
Stephen Hines2d1fdb22014-05-28 23:58:16 -070035set(dfsan_abilist_filename ${COMPILER_RT_OUTPUT_DIR}/dfsan_abilist.txt)
Peter Collingbournee8d20342013-08-14 18:54:06 +000036add_custom_target(dfsan_abilist ALL
Stephen Hines2d1fdb22014-05-28 23:58:16 -070037 DEPENDS ${dfsan_abilist_filename})
38add_custom_command(OUTPUT ${dfsan_abilist_filename}
Peter Collingbournee8d20342013-08-14 18:54:06 +000039 VERBATIM
40 COMMAND
41 cat ${CMAKE_CURRENT_SOURCE_DIR}/done_abilist.txt
Stephen Hines6d186232014-11-26 17:56:19 -080042 ${CMAKE_CURRENT_SOURCE_DIR}/libc_ubuntu1404_abilist.txt
Stephen Hines2d1fdb22014-05-28 23:58:16 -070043 > ${dfsan_abilist_filename}
Stephen Hines6d186232014-11-26 17:56:19 -080044 DEPENDS done_abilist.txt libc_ubuntu1404_abilist.txt)
Stephen Hines2d1fdb22014-05-28 23:58:16 -070045add_dependencies(dfsan dfsan_abilist)
46install(FILES ${dfsan_abilist_filename}
47 DESTINATION ${COMPILER_RT_INSTALL_PATH})
Peter Collingbournee8d20342013-08-14 18:54:06 +000048
Stephen Hines2d1fdb22014-05-28 23:58:16 -070049add_dependencies(compiler-rt dfsan)