summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/asan/CMakeLists.txt
blob: a8183c4f2dd15571aab4d467f4932d0c275edaae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Build for the AddressSanitizer runtime support library.

set(ASAN_SOURCES
  asan_allocator.cc
  asan_globals.cc
  asan_interceptors.cc
  asan_linux.cc
  asan_mac.cc
  asan_malloc_linux.cc
  asan_malloc_mac.cc
  asan_malloc_win.cc
  asan_new_delete.cc
  asan_poisoning.cc
  asan_posix.cc
  asan_printf.cc
  asan_rtl.cc
  asan_stack.cc
  asan_stats.cc
  asan_thread.cc
  asan_thread_registry.cc
  asan_win.cc
  )

include_directories(..)

set(ASAN_CFLAGS
  -fPIC
  -fno-exceptions
  -funwind-tables
  -fvisibility=hidden
  )
if (SUPPORTS_NO_VARIADIC_MACROS_FLAG)
  list(APPEND ASAN_CFLAGS -Wno-variadic-macros)
endif ()

set(ASAN_COMMON_DEFINITIONS
  ASAN_HAS_EXCEPTIONS=1
  ASAN_NEEDS_SEGV=1
  )

if(CAN_TARGET_X86_64)
  add_library(clang_rt.asan-x86_64 STATIC
    ${ASAN_SOURCES}
    $<TARGET_OBJECTS:RTInterception.x86_64>
    $<TARGET_OBJECTS:RTSanitizerCommon.x86_64>
    )
  set_target_compile_flags(clang_rt.asan-x86_64
    ${ASAN_CFLAGS}
    ${TARGET_X86_64_CFLAGS}
    )
  set_property(TARGET clang_rt.asan-x86_64 APPEND PROPERTY COMPILE_DEFINITIONS
    ${ASAN_COMMON_DEFINITIONS})
endif()
if(CAN_TARGET_I386)
  add_library(clang_rt.asan-i386 STATIC
    ${ASAN_SOURCES}
    $<TARGET_OBJECTS:RTInterception.i386>
    $<TARGET_OBJECTS:RTSanitizerCommon.i386>
    )
  set_target_compile_flags(clang_rt.asan-i386
    ${ASAN_CFLAGS}
    ${TARGET_I386_CFLAGS}
    )
  set_property(TARGET clang_rt.asan-x86_64 APPEND PROPERTY COMPILE_DEFINITIONS
    ${ASAN_COMMON_DEFINITIONS})
endif()

if(LLVM_INCLUDE_TESTS)
  add_subdirectory(tests)
endif()
OpenPOWER on IntegriCloud