Peter Collingbourne | eee71ae | 2013-08-07 22:47:26 +0000 | [diff] [blame] | 1 | include_directories(..) |
| 2 | |
| 3 | # Runtime library sources and build flags. |
| 4 | set(DFSAN_RTL_SOURCES |
Peter Collingbourne | 6e4c46d | 2013-08-15 21:18:53 +0000 | [diff] [blame] | 5 | dfsan.cc |
| 6 | dfsan_custom.cc |
| 7 | dfsan_interceptors.cc) |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 8 | set(DFSAN_COMMON_CFLAGS ${SANITIZER_COMMON_CFLAGS}) |
| 9 | # Prevent clang from generating libc calls. |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame^] | 10 | append_list_if(COMPILER_RT_HAS_FFREESTANDING_FLAG -ffreestanding DFSAN_COMMON_CFLAGS) |
Peter Collingbourne | eee71ae | 2013-08-07 22:47:26 +0000 | [diff] [blame] | 11 | |
| 12 | # Static runtime library. |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 13 | add_custom_target(dfsan) |
Peter Collingbourne | eee71ae | 2013-08-07 22:47:26 +0000 | [diff] [blame] | 14 | set(arch "x86_64") |
| 15 | if(CAN_TARGET_${arch}) |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 16 | set(DFSAN_CFLAGS ${DFSAN_COMMON_CFLAGS}) |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame^] | 17 | append_list_if(COMPILER_RT_HAS_FPIE_FLAG -fPIE DFSAN_CFLAGS) |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 18 | add_compiler_rt_runtime(clang_rt.dfsan-${arch} ${arch} STATIC |
Peter Collingbourne | eee71ae | 2013-08-07 22:47:26 +0000 | [diff] [blame] | 19 | SOURCES ${DFSAN_RTL_SOURCES} |
| 20 | $<TARGET_OBJECTS:RTInterception.${arch}> |
| 21 | $<TARGET_OBJECTS:RTSanitizerCommon.${arch}> |
| 22 | $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}> |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 23 | 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 Collingbourne | eee71ae | 2013-08-07 22:47:26 +0000 | [diff] [blame] | 26 | SOURCES ${DFSAN_RTL_SOURCES} |
| 27 | $<TARGET_OBJECTS:RTSanitizerCommon.${arch}> |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 28 | CFLAGS ${DFSAN_NOLIBC_CFLAGS}) |
Peter Collingbourne | ba945f8 | 2013-08-29 22:49:00 +0000 | [diff] [blame] | 29 | add_sanitizer_rt_symbols(clang_rt.dfsan-${arch} dfsan.syms.extra) |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 30 | add_dependencies(dfsan |
| 31 | clang_rt.dfsan-${arch} |
| 32 | clang_rt.dfsan-${arch}-symbols) |
Peter Collingbourne | eee71ae | 2013-08-07 22:47:26 +0000 | [diff] [blame] | 33 | endif() |
| 34 | |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 35 | set(dfsan_abilist_filename ${COMPILER_RT_OUTPUT_DIR}/dfsan_abilist.txt) |
Peter Collingbourne | e8d2034 | 2013-08-14 18:54:06 +0000 | [diff] [blame] | 36 | add_custom_target(dfsan_abilist ALL |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 37 | DEPENDS ${dfsan_abilist_filename}) |
| 38 | add_custom_command(OUTPUT ${dfsan_abilist_filename} |
Peter Collingbourne | e8d2034 | 2013-08-14 18:54:06 +0000 | [diff] [blame] | 39 | VERBATIM |
| 40 | COMMAND |
| 41 | cat ${CMAKE_CURRENT_SOURCE_DIR}/done_abilist.txt |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame^] | 42 | ${CMAKE_CURRENT_SOURCE_DIR}/libc_ubuntu1404_abilist.txt |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 43 | > ${dfsan_abilist_filename} |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame^] | 44 | DEPENDS done_abilist.txt libc_ubuntu1404_abilist.txt) |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 45 | add_dependencies(dfsan dfsan_abilist) |
| 46 | install(FILES ${dfsan_abilist_filename} |
| 47 | DESTINATION ${COMPILER_RT_INSTALL_PATH}) |
Peter Collingbourne | e8d2034 | 2013-08-14 18:54:06 +0000 | [diff] [blame] | 48 | |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 49 | add_dependencies(compiler-rt dfsan) |