Peter Collingbourne | 5cbab07 | 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 | 12b0809 | 2013-08-15 21:18:53 +0000 | [diff] [blame] | 5 | dfsan.cc |
| 6 | dfsan_custom.cc |
| 7 | dfsan_interceptors.cc) |
Alexey Samsonov | 878a9a5 | 2014-02-18 08:07:09 +0000 | [diff] [blame] | 8 | set(DFSAN_COMMON_CFLAGS ${SANITIZER_COMMON_CFLAGS}) |
| 9 | # Prevent clang from generating libc calls. |
Kuba Brecka | 14c0c59 | 2014-10-15 22:47:54 +0000 | [diff] [blame] | 10 | append_list_if(COMPILER_RT_HAS_FFREESTANDING_FLAG -ffreestanding DFSAN_COMMON_CFLAGS) |
Peter Collingbourne | 5cbab07 | 2013-08-07 22:47:26 +0000 | [diff] [blame] | 11 | |
| 12 | # Static runtime library. |
Alexey Samsonov | f6cf6ab | 2014-02-14 12:05:41 +0000 | [diff] [blame] | 13 | add_custom_target(dfsan) |
Peter Collingbourne | 5cbab07 | 2013-08-07 22:47:26 +0000 | [diff] [blame] | 14 | set(arch "x86_64") |
| 15 | if(CAN_TARGET_${arch}) |
Alexey Samsonov | 878a9a5 | 2014-02-18 08:07:09 +0000 | [diff] [blame] | 16 | set(DFSAN_CFLAGS ${DFSAN_COMMON_CFLAGS}) |
Kuba Brecka | 14c0c59 | 2014-10-15 22:47:54 +0000 | [diff] [blame] | 17 | append_list_if(COMPILER_RT_HAS_FPIE_FLAG -fPIE DFSAN_CFLAGS) |
Alexey Samsonov | 78a8435 | 2014-03-31 13:45:36 +0000 | [diff] [blame] | 18 | add_compiler_rt_runtime(clang_rt.dfsan-${arch} ${arch} STATIC |
Peter Collingbourne | 5cbab07 | 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}> |
Alexey Samsonov | 878a9a5 | 2014-02-18 08:07:09 +0000 | [diff] [blame] | 23 | CFLAGS ${DFSAN_CFLAGS}) |
| 24 | set(DFSAN_NOLIBC_CFLAGS ${DFSAN_COMMON_CFLAGS} -DDFSAN_NOLIBC) |
Alexey Samsonov | 78a8435 | 2014-03-31 13:45:36 +0000 | [diff] [blame] | 25 | add_compiler_rt_runtime(clang_rt.dfsan-libc-${arch} ${arch} STATIC |
Peter Collingbourne | 5cbab07 | 2013-08-07 22:47:26 +0000 | [diff] [blame] | 26 | SOURCES ${DFSAN_RTL_SOURCES} |
| 27 | $<TARGET_OBJECTS:RTSanitizerCommon.${arch}> |
Alexey Samsonov | 878a9a5 | 2014-02-18 08:07:09 +0000 | [diff] [blame] | 28 | CFLAGS ${DFSAN_NOLIBC_CFLAGS}) |
Peter Collingbourne | 014328e | 2013-08-29 22:49:00 +0000 | [diff] [blame] | 29 | add_sanitizer_rt_symbols(clang_rt.dfsan-${arch} dfsan.syms.extra) |
Alexey Samsonov | f6cf6ab | 2014-02-14 12:05:41 +0000 | [diff] [blame] | 30 | add_dependencies(dfsan |
| 31 | clang_rt.dfsan-${arch} |
| 32 | clang_rt.dfsan-${arch}-symbols) |
Peter Collingbourne | 5cbab07 | 2013-08-07 22:47:26 +0000 | [diff] [blame] | 33 | endif() |
| 34 | |
Alexey Samsonov | 1181a10 | 2014-02-18 14:28:53 +0000 | [diff] [blame] | 35 | set(dfsan_abilist_filename ${COMPILER_RT_OUTPUT_DIR}/dfsan_abilist.txt) |
Peter Collingbourne | 0e51eda | 2013-08-14 18:54:06 +0000 | [diff] [blame] | 36 | add_custom_target(dfsan_abilist ALL |
Chandler Carruth | c42ddde | 2014-04-30 23:31:45 +0000 | [diff] [blame] | 37 | DEPENDS ${dfsan_abilist_filename}) |
Alexey Samsonov | 1181a10 | 2014-02-18 14:28:53 +0000 | [diff] [blame] | 38 | add_custom_command(OUTPUT ${dfsan_abilist_filename} |
Peter Collingbourne | 0e51eda | 2013-08-14 18:54:06 +0000 | [diff] [blame] | 39 | VERBATIM |
| 40 | COMMAND |
| 41 | cat ${CMAKE_CURRENT_SOURCE_DIR}/done_abilist.txt |
Peter Collingbourne | 113ff7f | 2014-11-05 17:21:06 +0000 | [diff] [blame^] | 42 | ${CMAKE_CURRENT_SOURCE_DIR}/libc_ubuntu1404_abilist.txt |
Alexey Samsonov | 1181a10 | 2014-02-18 14:28:53 +0000 | [diff] [blame] | 43 | > ${dfsan_abilist_filename} |
Peter Collingbourne | 113ff7f | 2014-11-05 17:21:06 +0000 | [diff] [blame^] | 44 | DEPENDS done_abilist.txt libc_ubuntu1404_abilist.txt) |
Alexey Samsonov | f6cf6ab | 2014-02-14 12:05:41 +0000 | [diff] [blame] | 45 | add_dependencies(dfsan dfsan_abilist) |
Alexey Samsonov | 1181a10 | 2014-02-18 14:28:53 +0000 | [diff] [blame] | 46 | install(FILES ${dfsan_abilist_filename} |
| 47 | DESTINATION ${COMPILER_RT_INSTALL_PATH}) |
Alexey Samsonov | 63a4af7 | 2014-02-18 09:33:45 +0000 | [diff] [blame] | 48 | |
| 49 | add_dependencies(compiler-rt dfsan) |