1include_directories(..)
2
3# Runtime library sources and build flags.
4set(MSAN_RTL_SOURCES
5  msan.cpp
6  msan_allocator.cpp
7  msan_chained_origin_depot.cpp
8  msan_interceptors.cpp
9  msan_linux.cpp
10  msan_report.cpp
11  msan_thread.cpp
12  msan_poisoning.cpp
13  )
14
15set(MSAN_RTL_CXX_SOURCES
16  msan_new_delete.cpp
17  )
18
19set(MSAN_RTL_HEADERS
20  msan.h
21  msan_allocator.h
22  msan_chained_origin_depot.h
23  msan_flags.h
24  msan_flags.inc
25  msan_interface_internal.h
26  msan_origin.h
27  msan_poisoning.h
28  msan_report.h
29  msan_thread.h)
30
31set(MSAN_RTL_CFLAGS ${SANITIZER_COMMON_CFLAGS})
32if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
33  append_list_if(COMPILER_RT_HAS_FTLS_MODEL_INITIAL_EXEC -ftls-model=initial-exec MSAN_RTL_CFLAGS)
34endif()
35append_rtti_flag(OFF MSAN_RTL_CFLAGS)
36if(NOT CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
37  append_list_if(COMPILER_RT_HAS_FPIE_FLAG -fPIE MSAN_RTL_CFLAGS)
38endif()
39# Prevent clang from generating libc calls.
40append_list_if(COMPILER_RT_HAS_FFREESTANDING_FLAG -ffreestanding MSAN_RTL_CFLAGS)
41
42set(MSAN_RUNTIME_LIBRARIES)
43
44# Static runtime library.
45add_compiler_rt_component(msan)
46
47foreach(arch ${MSAN_SUPPORTED_ARCH})
48  add_compiler_rt_runtime(clang_rt.msan
49    STATIC
50    ARCHS ${arch}
51    SOURCES ${MSAN_RTL_SOURCES}
52            $<TARGET_OBJECTS:RTInterception.${arch}>
53            $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
54            $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
55            $<TARGET_OBJECTS:RTSanitizerCommonCoverage.${arch}>
56            $<TARGET_OBJECTS:RTSanitizerCommonSymbolizer.${arch}>
57            $<TARGET_OBJECTS:RTUbsan.${arch}>
58    ADDITIONAL_HEADERS ${MSAN_RTL_HEADERS}
59    CFLAGS ${MSAN_RTL_CFLAGS}
60    PARENT_TARGET msan)
61  add_compiler_rt_runtime(clang_rt.msan_cxx
62    STATIC
63    ARCHS ${arch}
64    SOURCES ${MSAN_RTL_CXX_SOURCES}
65            $<TARGET_OBJECTS:RTUbsan_cxx.${arch}>
66    ADDITIONAL_HEADERS ${MSAN_RTL_HEADERS}
67    CFLAGS ${MSAN_RTL_CFLAGS}
68    PARENT_TARGET msan)
69  list(APPEND MSAN_RUNTIME_LIBRARIES clang_rt.msan-${arch}
70                                     clang_rt.msan_cxx-${arch})
71  if(SANITIZER_USE_SYMBOLS)
72    add_sanitizer_rt_symbols(clang_rt.msan
73      ARCHS ${arch}
74      EXTRA msan.syms.extra)
75    add_sanitizer_rt_symbols(clang_rt.msan_cxx
76      ARCHS ${arch}
77      EXTRA msan.syms.extra)
78    add_dependencies(msan clang_rt.msan-${arch}-symbols
79                          clang_rt.msan_cxx-${arch}-symbols)
80  endif()
81endforeach()
82
83add_compiler_rt_resource_file(msan_blacklist msan_blacklist.txt msan)
84list(APPEND MSAN_RUNTIME_LIBRARIES msan_blacklist)
85
86if(COMPILER_RT_INCLUDE_TESTS)
87  add_subdirectory(tests)
88endif()
89