CMakeLists.txt revision 2d1fdb26e458c4ddc04155c1d421bced3ba90cd0
114110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourneinclude_directories(..)
214110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne
314110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne# Runtime library sources and build flags.
414110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourneset(DFSAN_RTL_SOURCES
514110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne  dfsan.cc
614110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne  dfsan_custom.cc
714110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne  dfsan_interceptors.cc)
814110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourneset(DFSAN_COMMON_CFLAGS ${SANITIZER_COMMON_CFLAGS})
914110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne# Prevent clang from generating libc calls.
1014110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourneappend_if(COMPILER_RT_HAS_FFREESTANDING_FLAG -ffreestanding DFSAN_COMMON_CFLAGS)
1114110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne
1214110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne# Static runtime library.
1314110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourneadd_custom_target(dfsan)
1414110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourneset(arch "x86_64")
1514110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourneif(CAN_TARGET_${arch})
1614110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne  set(DFSAN_CFLAGS ${DFSAN_COMMON_CFLAGS})
1714110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne  append_if(COMPILER_RT_HAS_FPIE_FLAG -fPIE DFSAN_CFLAGS)
1814110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne  add_compiler_rt_runtime(clang_rt.dfsan-${arch} ${arch} STATIC
1914110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne    SOURCES ${DFSAN_RTL_SOURCES}
2014110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne            $<TARGET_OBJECTS:RTInterception.${arch}>
2114110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne            $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
2214110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne            $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
2314110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne    CFLAGS ${DFSAN_CFLAGS})
2414110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne  set(DFSAN_NOLIBC_CFLAGS ${DFSAN_COMMON_CFLAGS} -DDFSAN_NOLIBC)
2514110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne  add_compiler_rt_runtime(clang_rt.dfsan-libc-${arch} ${arch} STATIC
2614110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne    SOURCES ${DFSAN_RTL_SOURCES}
2714110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne            $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
2814110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne            CFLAGS ${DFSAN_NOLIBC_CFLAGS})
2914110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne  add_sanitizer_rt_symbols(clang_rt.dfsan-${arch} dfsan.syms.extra)
3014110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne  add_dependencies(dfsan
3114110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne    clang_rt.dfsan-${arch}
3214110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne    clang_rt.dfsan-${arch}-symbols)
3314110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourneendif()
3414110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne
3514110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourneset(dfsan_abilist_filename ${COMPILER_RT_OUTPUT_DIR}/dfsan_abilist.txt)
3614110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourneadd_custom_target(dfsan_abilist ALL
3714110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne  DEPENDS ${dfsan_abilist_filename})
3814110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourneadd_custom_command(OUTPUT ${dfsan_abilist_filename}
3914110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne                   VERBATIM
405f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner                   COMMAND
4114110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne                     cat ${CMAKE_CURRENT_SOURCE_DIR}/done_abilist.txt
425f9e272e632e951b1efe824cd16acb4d96077930Chris Lattner                         ${CMAKE_CURRENT_SOURCE_DIR}/libc_ubuntu1204_abilist.txt
4314110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne                         > ${dfsan_abilist_filename}
4414110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne                   DEPENDS done_abilist.txt libc_ubuntu1204_abilist.txt)
4514110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourneadd_dependencies(dfsan dfsan_abilist)
4614110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourneinstall(FILES ${dfsan_abilist_filename}
4714110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne        DESTINATION ${COMPILER_RT_INSTALL_PATH})
4814110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne
4914110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourneadd_dependencies(compiler-rt dfsan)
5014110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne