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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
| # Build for all components of the XRay runtime support library.
# XRay runtime library implementation files.
set(XRAY_SOURCES
xray_buffer_queue.cpp
xray_init.cpp
xray_flags.cpp
xray_interface.cpp
xray_log_interface.cpp
xray_utils.cpp
)
# Implementation files for all XRay modes.
set(XRAY_FDR_MODE_SOURCES
xray_fdr_flags.cpp
xray_fdr_logging.cpp
)
set(XRAY_BASIC_MODE_SOURCES
xray_basic_flags.cpp
xray_basic_logging.cpp
)
set(XRAY_PROFILING_MODE_SOURCES
xray_profile_collector.cpp
xray_profiling.cpp
xray_profiling_flags.cpp
)
# Implementation files for all XRay architectures.
set(x86_64_SOURCES
xray_x86_64.cpp
xray_trampoline_x86_64.S
)
set(arm_SOURCES
xray_arm.cpp
xray_trampoline_arm.S
)
set(armhf_SOURCES
${arm_SOURCES}
)
set(aarch64_SOURCES
xray_AArch64.cpp
xray_trampoline_AArch64.S
)
set(mips_SOURCES
xray_mips.cpp
xray_trampoline_mips.S
)
set(mipsel_SOURCES
xray_mips.cpp
xray_trampoline_mips.S
)
set(mips64_SOURCES
xray_mips64.cpp
xray_trampoline_mips64.S
)
set(mips64el_SOURCES
xray_mips64.cpp
xray_trampoline_mips64.S
)
set(powerpc64le_SOURCES
xray_powerpc64.cpp
xray_trampoline_powerpc64.cpp
xray_trampoline_powerpc64_asm.S
)
set(XRAY_IMPL_HEADERS
xray_allocator.h
xray_basic_flags.h
xray_basic_flags.inc
xray_basic_logging.h
xray_buffer_queue.h
xray_defs.h
xray_fdr_controller.h
xray_fdr_flags.h
xray_fdr_flags.inc
xray_fdr_log_records.h
xray_fdr_log_writer.h
xray_fdr_logging.h
xray_flags.h
xray_flags.inc
xray_function_call_trie.h
xray_interface_internal.h
xray_powerpc64.inc
xray_profile_collector.h
xray_profiling_flags.h
xray_profiling_flags.inc
xray_recursion_guard.h
xray_segmented_array.h
xray_tsc.h
xray_utils.h
xray_x86_64.inc
)
# Create list of all source files for
# consumption by tests.
set(XRAY_ALL_SOURCE_FILES
${XRAY_SOURCES}
${XRAY_FDR_MODE_SOURCES}
${XRAY_BASIC_MODE_SOURCES}
${XRAY_PROFILING_MODE_SOURCES}
${x86_64_SOURCES}
${arm_SOURCES}
${armhf_SOURCES}
${mips_SOURCES}
${mipsel_SOURCES}
${mips64_SOURCES}
${mips64el_SOURCES}
${powerpc64le_SOURCES}
${XRAY_IMPL_HEADERS}
)
list(REMOVE_DUPLICATES XRAY_ALL_SOURCE_FILES)
# Make list that uses absolute paths
set(XRAY_ALL_SOURCE_FILES_ABS_PATHS "")
foreach (src_file ${XRAY_ALL_SOURCE_FILES})
list(APPEND
XRAY_ALL_SOURCE_FILES_ABS_PATHS
"${CMAKE_CURRENT_SOURCE_DIR}/${src_file}")
endforeach()
# Now put it all together...
include_directories(..)
include_directories(../../include)
set(XRAY_CFLAGS ${SANITIZER_COMMON_CFLAGS})
set(XRAY_COMMON_DEFINITIONS XRAY_HAS_EXCEPTIONS=1)
# We don't need RTTI in XRay, so turn that off.
append_rtti_flag(OFF XRAY_CFLAGS)
append_list_if(
COMPILER_RT_HAS_XRAY_COMPILER_FLAG XRAY_SUPPORTED=1 XRAY_COMMON_DEFINITIONS)
append_list_if(
COMPILER_RT_BUILD_XRAY_NO_PREINIT XRAY_NO_PREINIT XRAY_COMMON_DEFINITIONS)
add_compiler_rt_component(xray)
set(XRAY_COMMON_RUNTIME_OBJECT_LIBS
RTSanitizerCommon
RTSanitizerCommonLibc)
if (TARGET cxx-headers OR HAVE_LIBCXX)
set(XRAY_DEPS cxx-headers)
endif()
if (APPLE)
set(XRAY_LINK_LIBS ${SANITIZER_COMMON_LINK_LIBS})
add_asm_sources(XRAY_ASM_SOURCES xray_trampoline_x86_64.S)
add_weak_symbols("sanitizer_common" WEAK_SYMBOL_LINK_FLAGS)
add_weak_symbols("xray" WEAK_SYMBOL_LINK_FLAGS)
add_compiler_rt_object_libraries(RTXray
OS ${XRAY_SUPPORTED_OS}
ARCHS ${XRAY_SUPPORTED_ARCH}
SOURCES ${XRAY_SOURCES} ${x86_64_SOURCES}
ADDITIONAL_HEADERS ${XRAY_IMPL_HEADERS}
CFLAGS ${XRAY_CFLAGS}
DEFS ${XRAY_COMMON_DEFINITIONS}
DEPS ${XRAY_DEPS})
add_compiler_rt_object_libraries(RTXrayFDR
OS ${XRAY_SUPPORTED_OS}
ARCHS ${XRAY_SUPPORTED_ARCH}
SOURCES ${XRAY_FDR_MODE_SOURCES}
ADDITIONAL_HEADERS ${XRAY_IMPL_HEADERS}
CFLAGS ${XRAY_CFLAGS}
DEFS ${XRAY_COMMON_DEFINITIONS}
DEPS ${XRAY_DEPS})
add_compiler_rt_object_libraries(RTXrayBASIC
OS ${XRAY_SUPPORTED_OS}
ARCHS ${XRAY_SUPPORTED_ARCH}
SOURCES ${XRAY_BASIC_MODE_SOURCES}
ADDITIONAL_HEADERS ${XRAY_IMPL_HEADERS}
CFLAGS ${XRAY_CFLAGS}
DEFS ${XRAY_COMMON_DEFINITIONS}
DEPS ${XRAY_DEPS})
add_compiler_rt_object_libraries(RTXrayPROFILING
OS ${XRAY_SUPPORTED_OS}
ARCHS ${XRAY_SUPPORTED_ARCH}
SOURCES ${XRAY_PROFILING_MODE_SOURCES}
ADDITIONAL_HEADERS ${XRAY_IMPL_HEADERS}
CFLAGS ${XRAY_CFLAGS}
DEFS ${XRAY_COMMON_DEFINITIONS}
DEPS ${XRAY_DEPS})
# We only support running on osx for now.
add_compiler_rt_runtime(clang_rt.xray
STATIC
OS ${XRAY_SUPPORTED_OS}
ARCHS ${XRAY_SUPPORTED_ARCH}
OBJECT_LIBS RTXray
RTSanitizerCommon
RTSanitizerCommonLibc
CFLAGS ${XRAY_CFLAGS}
DEFS ${XRAY_COMMON_DEFINITIONS}
LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS} ${WEAK_SYMBOL_LINK_FLAGS}
LINK_LIBS ${XRAY_LINK_LIBS}
PARENT_TARGET xray)
add_compiler_rt_runtime(clang_rt.xray-fdr
STATIC
OS ${XRAY_SUPPORTED_OS}
ARCHS ${XRAY_SUPPORTED_ARCH}
OBJECT_LIBS RTXrayFDR
CFLAGS ${XRAY_CFLAGS}
DEFS ${XRAY_COMMON_DEFINITIONS}
LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS} ${WEAK_SYMBOL_LINK_FLAGS}
LINK_LIBS ${XRAY_LINK_LIBS}
PARENT_TARGET xray)
add_compiler_rt_runtime(clang_rt.xray-basic
STATIC
OS ${XRAY_SUPPORTED_OS}
ARCHS ${XRAY_SUPPORTED_ARCH}
OBJECT_LIBS RTXrayBASIC
CFLAGS ${XRAY_CFLAGS}
DEFS ${XRAY_COMMON_DEFINITIONS}
LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS} ${WEAK_SYMBOL_LINK_FLAGS}
LINK_LIBS ${XRAY_LINK_LIBS}
PARENT_TARGET xray)
add_compiler_rt_runtime(clang_rt.xray-profiling
STATIC
OS ${XRAY_SUPPORTED_OS}
ARCHS ${XRAY_SUPPORTED_ARCH}
OBJECT_LIBS RTXrayPROFILING
CFLAGS ${XRAY_CFLAGS}
DEFS ${XRAY_COMMON_DEFINITIONS}
LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS} ${WEAK_SYMBOL_LINK_FLAGS}
LINK_LIBS ${XRAY_LINK_LIBS}
PARENT_TARGET xray)
else() # not Apple
foreach(arch ${XRAY_SUPPORTED_ARCH})
if(NOT CAN_TARGET_${arch})
continue()
endif()
add_compiler_rt_object_libraries(RTXray
ARCHS ${arch}
SOURCES ${XRAY_SOURCES} ${${arch}_SOURCES}
ADDITIONAL_HEADERS ${XRAY_IMPL_HEADERS}
CFLAGS ${XRAY_CFLAGS}
DEFS ${XRAY_COMMON_DEFINITIONS}
DEPS ${XRAY_DEPS})
add_compiler_rt_object_libraries(RTXrayFDR
ARCHS ${arch}
SOURCES ${XRAY_FDR_MODE_SOURCES}
ADDITIONAL_HEADERS ${XRAY_IMPL_HEADERS}
CFLAGS ${XRAY_CFLAGS}
DEFS ${XRAY_COMMON_DEFINITIONS}
DEPS ${XRAY_DEPS})
add_compiler_rt_object_libraries(RTXrayBASIC
ARCHS ${arch}
SOURCES ${XRAY_BASIC_MODE_SOURCES}
ADDITIONAL_HEADERS ${XRAY_IMPL_HEADERS}
CFLAGS ${XRAY_CFLAGS}
DEFS ${XRAY_COMMON_DEFINITIONS}
DEPS ${XRAY_DEPS})
add_compiler_rt_object_libraries(RTXrayPROFILING
ARCHS ${arch}
SOURCES ${XRAY_PROFILING_MODE_SOURCES}
ADDITIONAL_HEADERS ${XRAY_IMPL_HEADERS}
CFLAGS ${XRAY_CFLAGS}
DEFS ${XRAY_COMMON_DEFINITIONS}
DEPS ${XRAY_DEPS})
# Common XRay archive for instrumented binaries.
add_compiler_rt_runtime(clang_rt.xray
STATIC
ARCHS ${arch}
CFLAGS ${XRAY_CFLAGS}
DEFS ${XRAY_COMMON_DEFINITIONS}
OBJECT_LIBS ${XRAY_COMMON_RUNTIME_OBJECT_LIBS} RTXray
PARENT_TARGET xray)
# FDR mode runtime archive (addon for clang_rt.xray)
add_compiler_rt_runtime(clang_rt.xray-fdr
STATIC
ARCHS ${arch}
CFLAGS ${XRAY_CFLAGS}
DEFS ${XRAY_COMMON_DEFINITIONS}
OBJECT_LIBS RTXrayFDR
PARENT_TARGET xray)
# Basic mode runtime archive (addon for clang_rt.xray)
add_compiler_rt_runtime(clang_rt.xray-basic
STATIC
ARCHS ${arch}
CFLAGS ${XRAY_CFLAGS}
DEFS ${XRAY_COMMON_DEFINITIONS}
OBJECT_LIBS RTXrayBASIC
PARENT_TARGET xray)
# Profiler Mode runtime
add_compiler_rt_runtime(clang_rt.xray-profiling
STATIC
ARCHS ${arch}
CFLAGS ${XRAY_CFLAGS}
DEFS ${XRAY_COMMON_DEFINITIONS}
OBJECT_LIBS RTXrayPROFILING
PARENT_TARGET xray)
endforeach()
endif() # not Apple
if(COMPILER_RT_INCLUDE_TESTS)
add_subdirectory(tests)
endif()
|