CMakeLists.txt revision f7c1d18183d2dfbd02864cf47b3239d6a5d717c0
1# Build for the AddressSanitizer runtime support library.
2
3set(ASAN_SOURCES
4  asan_allocator.cc
5  asan_globals.cc
6  asan_interceptors.cc
7  asan_linux.cc
8  asan_mac.cc
9  asan_malloc_linux.cc
10  asan_malloc_mac.cc
11  asan_malloc_win.cc
12  asan_new_delete.cc
13  asan_poisoning.cc
14  asan_posix.cc
15  asan_printf.cc
16  asan_report.cc
17  asan_rtl.cc
18  asan_stack.cc
19  asan_stats.cc
20  asan_thread.cc
21  asan_thread_registry.cc
22  asan_win.cc
23  )
24
25include_directories(..)
26
27set(ASAN_CFLAGS
28  -fPIC
29  -fno-exceptions
30  -funwind-tables
31  -fvisibility=hidden
32  -fno-builtin
33  -fomit-frame-pointer
34  -O3
35  )
36if (SUPPORTS_NO_VARIADIC_MACROS_FLAG)
37  list(APPEND ASAN_CFLAGS -Wno-variadic-macros)
38endif ()
39
40if (APPLE)
41  list(APPEND ASAN_CFLAGS -mmacosx-version-min=10.5)
42endif()
43
44set(ASAN_COMMON_DEFINITIONS
45  ASAN_HAS_EXCEPTIONS=1
46  ASAN_NEEDS_SEGV=1
47  )
48
49# FIXME: We need to build universal binaries on OS X instead of
50# two arch-specific binaries.
51
52if(CAN_TARGET_X86_64)
53  add_library(clang_rt.asan-x86_64 STATIC
54    ${ASAN_SOURCES}
55    $<TARGET_OBJECTS:RTInterception.x86_64>
56    $<TARGET_OBJECTS:RTSanitizerCommon.x86_64>
57    )
58  set_target_compile_flags(clang_rt.asan-x86_64
59    ${ASAN_CFLAGS}
60    ${TARGET_X86_64_CFLAGS}
61    )
62  set_property(TARGET clang_rt.asan-x86_64 APPEND PROPERTY COMPILE_DEFINITIONS
63    ${ASAN_COMMON_DEFINITIONS})
64  add_clang_runtime_static_library(clang_rt.asan-x86_64)
65endif()
66if(CAN_TARGET_I386)
67  add_library(clang_rt.asan-i386 STATIC
68    ${ASAN_SOURCES}
69    $<TARGET_OBJECTS:RTInterception.i386>
70    $<TARGET_OBJECTS:RTSanitizerCommon.i386>
71    )
72  set_target_compile_flags(clang_rt.asan-i386
73    ${ASAN_CFLAGS}
74    ${TARGET_I386_CFLAGS}
75    )
76  set_property(TARGET clang_rt.asan-i386 APPEND PROPERTY COMPILE_DEFINITIONS
77    ${ASAN_COMMON_DEFINITIONS})
78  add_clang_runtime_static_library(clang_rt.asan-i386)
79endif()
80
81if(LLVM_INCLUDE_TESTS)
82  add_subdirectory(tests)
83endif()
84
85# ASan output tests.
86# FIXME: move all output tests from output_tests/ to lit_tests/ and get rid
87# of the first directory.
88add_subdirectory(lit_tests)
89