blob: 92f9da1d423443bf3acc071e2e93fe140ffe38d0 (
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
# Build for the Memory Profiler runtime support library.
set(MEMPROF_SOURCES
memprof_allocator.cpp
memprof_descriptions.cpp
memprof_flags.cpp
memprof_interceptors.cpp
memprof_interceptors_memintrinsics.cpp
memprof_linux.cpp
memprof_malloc_linux.cpp
memprof_posix.cpp
memprof_rtl.cpp
memprof_shadow_setup.cpp
memprof_stack.cpp
memprof_stats.cpp
memprof_thread.cpp
)
set(MEMPROF_CXX_SOURCES
memprof_new_delete.cpp
)
set(MEMPROF_PREINIT_SOURCES
memprof_preinit.cpp
)
SET(MEMPROF_HEADERS
memprof_allocator.h
memprof_descriptions.h
memprof_flags.h
memprof_flags.inc
memprof_init_version.h
memprof_interceptors.h
memprof_interceptors_memintrinsics.h
memprof_interface_internal.h
memprof_internal.h
memprof_mapping.h
memprof_stack.h
memprof_stats.h
memprof_thread.h
)
include_directories(..)
set(MEMPROF_CFLAGS ${SANITIZER_COMMON_CFLAGS})
set(MEMPROF_COMMON_DEFINITIONS "")
append_rtti_flag(OFF MEMPROF_CFLAGS)
set(MEMPROF_DYNAMIC_LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS})
set(MEMPROF_DYNAMIC_DEFINITIONS
${MEMPROF_COMMON_DEFINITIONS} MEMPROF_DYNAMIC=1)
set(MEMPROF_DYNAMIC_CFLAGS ${MEMPROF_CFLAGS})
append_list_if(COMPILER_RT_HAS_FTLS_MODEL_INITIAL_EXEC
-ftls-model=initial-exec MEMPROF_DYNAMIC_CFLAGS)
set(MEMPROF_DYNAMIC_LIBS ${SANITIZER_CXX_ABI_LIBRARIES} ${SANITIZER_COMMON_LINK_LIBS})
append_list_if(COMPILER_RT_HAS_LIBDL dl MEMPROF_DYNAMIC_LIBS)
append_list_if(COMPILER_RT_HAS_LIBRT rt MEMPROF_DYNAMIC_LIBS)
append_list_if(COMPILER_RT_HAS_LIBM m MEMPROF_DYNAMIC_LIBS)
append_list_if(COMPILER_RT_HAS_LIBPTHREAD pthread MEMPROF_DYNAMIC_LIBS)
append_list_if(COMPILER_RT_HAS_LIBLOG log MEMPROF_DYNAMIC_LIBS)
# Compile MemProf sources into an object library.
add_compiler_rt_object_libraries(RTMemprof_dynamic
OS ${SANITIZER_COMMON_SUPPORTED_OS}
ARCHS ${MEMPROF_SUPPORTED_ARCH}
SOURCES ${MEMPROF_SOURCES} ${MEMPROF_CXX_SOURCES}
ADDITIONAL_HEADERS ${MEMPROF_HEADERS}
CFLAGS ${MEMPROF_DYNAMIC_CFLAGS}
DEFS ${MEMPROF_DYNAMIC_DEFINITIONS}
DEPS ${MEMPROF_DEPS})
add_compiler_rt_object_libraries(RTMemprof
ARCHS ${MEMPROF_SUPPORTED_ARCH}
SOURCES ${MEMPROF_SOURCES}
ADDITIONAL_HEADERS ${MEMPROF_HEADERS}
CFLAGS ${MEMPROF_CFLAGS}
DEFS ${MEMPROF_COMMON_DEFINITIONS}
DEPS ${MEMPROF_DEPS})
add_compiler_rt_object_libraries(RTMemprof_cxx
ARCHS ${MEMPROF_SUPPORTED_ARCH}
SOURCES ${MEMPROF_CXX_SOURCES}
ADDITIONAL_HEADERS ${MEMPROF_HEADERS}
CFLAGS ${MEMPROF_CFLAGS}
DEFS ${MEMPROF_COMMON_DEFINITIONS}
DEPS ${MEMPROF_DEPS})
add_compiler_rt_object_libraries(RTMemprof_preinit
ARCHS ${MEMPROF_SUPPORTED_ARCH}
SOURCES ${MEMPROF_PREINIT_SOURCES}
ADDITIONAL_HEADERS ${MEMPROF_HEADERS}
CFLAGS ${MEMPROF_CFLAGS}
DEFS ${MEMPROF_COMMON_DEFINITIONS}
DEPS ${MEMPROF_DEPS})
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp "")
add_compiler_rt_object_libraries(RTMemprof_dynamic_version_script_dummy
ARCHS ${MEMPROF_SUPPORTED_ARCH}
SOURCES ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp
CFLAGS ${MEMPROF_DYNAMIC_CFLAGS}
DEFS ${MEMPROF_DYNAMIC_DEFINITIONS}
DEPS ${MEMPROF_DEPS})
# Build MemProf runtimes shipped with Clang.
add_compiler_rt_component(memprof)
# Build separate libraries for each target.
set(MEMPROF_COMMON_RUNTIME_OBJECT_LIBS
RTInterception
RTSanitizerCommon
RTSanitizerCommonLibc
RTSanitizerCommonCoverage
RTSanitizerCommonSymbolizer)
add_compiler_rt_runtime(clang_rt.memprof
STATIC
ARCHS ${MEMPROF_SUPPORTED_ARCH}
OBJECT_LIBS RTMemprof_preinit
RTMemprof
${MEMPROF_COMMON_RUNTIME_OBJECT_LIBS}
CFLAGS ${MEMPROF_CFLAGS}
DEFS ${MEMPROF_COMMON_DEFINITIONS}
PARENT_TARGET memprof)
add_compiler_rt_runtime(clang_rt.memprof_cxx
STATIC
ARCHS ${MEMPROF_SUPPORTED_ARCH}
OBJECT_LIBS RTMemprof_cxx
CFLAGS ${MEMPROF_CFLAGS}
DEFS ${MEMPROF_COMMON_DEFINITIONS}
PARENT_TARGET memprof)
add_compiler_rt_runtime(clang_rt.memprof-preinit
STATIC
ARCHS ${MEMPROF_SUPPORTED_ARCH}
OBJECT_LIBS RTMemprof_preinit
CFLAGS ${MEMPROF_CFLAGS}
DEFS ${MEMPROF_COMMON_DEFINITIONS}
PARENT_TARGET memprof)
foreach(arch ${MEMPROF_SUPPORTED_ARCH})
if (UNIX)
add_sanitizer_rt_version_list(clang_rt.memprof-dynamic-${arch}
LIBS clang_rt.memprof-${arch} clang_rt.memprof_cxx-${arch}
EXTRA memprof.syms.extra)
set(VERSION_SCRIPT_FLAG
-Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/clang_rt.memprof-dynamic-${arch}.vers)
set_property(SOURCE
${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp
APPEND PROPERTY
OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/clang_rt.memprof-dynamic-${arch}.vers)
else()
set(VERSION_SCRIPT_FLAG)
endif()
set(MEMPROF_DYNAMIC_WEAK_INTERCEPTION)
add_compiler_rt_runtime(clang_rt.memprof
SHARED
ARCHS ${arch}
OBJECT_LIBS ${MEMPROF_COMMON_RUNTIME_OBJECT_LIBS}
RTMemprof_dynamic
# The only purpose of RTMemprof_dynamic_version_script_dummy is to
# carry a dependency of the shared runtime on the version script.
# Replacing it with a straightforward
# add_dependencies(clang_rt.memprof-dynamic-${arch} clang_rt.memprof-dynamic-${arch}-version-list)
# generates an order-only dependency in ninja.
RTMemprof_dynamic_version_script_dummy
${MEMPROF_DYNAMIC_WEAK_INTERCEPTION}
CFLAGS ${MEMPROF_DYNAMIC_CFLAGS}
LINK_FLAGS ${MEMPROF_DYNAMIC_LINK_FLAGS}
${VERSION_SCRIPT_FLAG}
LINK_LIBS ${MEMPROF_DYNAMIC_LIBS}
DEFS ${MEMPROF_DYNAMIC_DEFINITIONS}
PARENT_TARGET memprof)
if (SANITIZER_USE_SYMBOLS)
add_sanitizer_rt_symbols(clang_rt.memprof_cxx
ARCHS ${arch})
add_dependencies(memprof clang_rt.memprof_cxx-${arch}-symbols)
add_sanitizer_rt_symbols(clang_rt.memprof
ARCHS ${arch}
EXTRA memprof.syms.extra)
add_dependencies(memprof clang_rt.memprof-${arch}-symbols)
endif()
endforeach()
|