1 # Build for all components of the XRay runtime support library.
3 # XRay runtime library implementation files.
13 # Implementation files for all XRay modes.
14 set(XRAY_FDR_MODE_SOURCES
19 set(XRAY_BASIC_MODE_SOURCES
21 xray_basic_logging.cpp
24 set(XRAY_PROFILING_MODE_SOURCES
25 xray_profile_collector.cpp
27 xray_profiling_flags.cpp
30 # Implementation files for all XRay architectures.
33 xray_trampoline_x86_64.S
47 xray_trampoline_AArch64.S
50 set(loongarch64_SOURCES
52 xray_trampoline_loongarch64.S
57 xray_trampoline_mips.S
62 xray_trampoline_mips.S
67 xray_trampoline_mips64.S
72 xray_trampoline_mips64.S
75 set(powerpc64le_SOURCES
77 xray_trampoline_powerpc64.cpp
78 xray_trampoline_powerpc64_asm.S
83 xray_trampoline_hexagon.S
106 xray_fdr_controller.h
109 xray_fdr_log_records.h
110 xray_fdr_log_writer.h
114 xray_function_call_trie.h
115 xray_interface_internal.h
117 xray_profile_collector.h
118 xray_profiling_flags.h
119 xray_profiling_flags.inc
120 xray_recursion_guard.h
121 xray_segmented_array.h
127 # Create list of all source files for
128 # consumption by tests.
129 set(XRAY_ALL_SOURCE_FILES
131 ${XRAY_FDR_MODE_SOURCES}
132 ${XRAY_BASIC_MODE_SOURCES}
133 ${XRAY_PROFILING_MODE_SOURCES}
138 ${loongarch64_SOURCES}
143 ${powerpc64le_SOURCES}
146 list(REMOVE_DUPLICATES XRAY_ALL_SOURCE_FILES)
147 # Make list that uses absolute paths
148 set(XRAY_ALL_SOURCE_FILES_ABS_PATHS "")
149 foreach (src_file ${XRAY_ALL_SOURCE_FILES})
151 XRAY_ALL_SOURCE_FILES_ABS_PATHS
152 "${CMAKE_CURRENT_SOURCE_DIR}/${src_file}")
156 # Now put it all together...
157 include_directories(..)
158 include_directories(../../include)
161 ${COMPILER_RT_COMMON_CFLAGS}
162 ${COMPILER_RT_CXX_CFLAGS})
163 set(XRAY_COMMON_DEFINITIONS SANITIZER_COMMON_NO_REDEFINE_BUILTINS XRAY_HAS_EXCEPTIONS=1)
165 # Too many existing bugs, needs cleanup.
166 append_list_if(COMPILER_RT_HAS_WNO_FORMAT -Wno-format XRAY_CFLAGS)
168 # We don't need RTTI in XRay, so turn that off.
169 append_rtti_flag(OFF XRAY_CFLAGS)
171 set(XRAY_LINK_FLAGS ${COMPILER_RT_COMMON_LINK_FLAGS})
173 ${COMPILER_RT_UNWINDER_LINK_LIBS}
174 ${COMPILER_RT_CXX_LINK_LIBS})
177 COMPILER_RT_HAS_XRAY_COMPILER_FLAG XRAY_SUPPORTED=1 XRAY_COMMON_DEFINITIONS)
179 COMPILER_RT_BUILD_XRAY_NO_PREINIT XRAY_NO_PREINIT XRAY_COMMON_DEFINITIONS)
181 add_compiler_rt_component(xray)
183 set(XRAY_COMMON_RUNTIME_OBJECT_LIBS
185 RTSanitizerCommonLibc)
187 # XRay uses C++ standard library headers.
188 if (TARGET cxx-headers OR HAVE_LIBCXX)
189 set(XRAY_DEPS cxx-headers)
193 add_weak_symbols("sanitizer_common" WEAK_SYMBOL_LINK_FLAGS)
194 add_weak_symbols("xray" WEAK_SYMBOL_LINK_FLAGS)
196 add_compiler_rt_object_libraries(RTXray
197 OS ${XRAY_SUPPORTED_OS}
198 ARCHS ${XRAY_SUPPORTED_ARCH}
199 SOURCES ${XRAY_SOURCES}
200 ADDITIONAL_HEADERS ${XRAY_IMPL_HEADERS}
201 CFLAGS ${XRAY_CFLAGS}
202 DEFS ${XRAY_COMMON_DEFINITIONS}
204 set(XRAY_RTXRAY_ARCH_LIBS "")
205 foreach(arch ${XRAY_SUPPORTED_ARCH})
206 if(NOT ${arch} IN_LIST XRAY_SOURCE_ARCHS)
209 add_compiler_rt_object_libraries(RTXray_${arch}
210 OS ${XRAY_SUPPORTED_OS}
212 SOURCES ${${arch}_SOURCES}
213 ADDITIONAL_HEADERS ${XRAY_IMPL_HEADERS}
214 CFLAGS ${XRAY_CFLAGS}
215 DEFS ${XRAY_COMMON_DEFINITIONS}
217 list(APPEND XRAY_RTXRAY_ARCH_LIBS RTXray_${arch})
219 add_compiler_rt_object_libraries(RTXrayFDR
220 OS ${XRAY_SUPPORTED_OS}
221 ARCHS ${XRAY_SUPPORTED_ARCH}
222 SOURCES ${XRAY_FDR_MODE_SOURCES}
223 ADDITIONAL_HEADERS ${XRAY_IMPL_HEADERS}
224 CFLAGS ${XRAY_CFLAGS}
225 DEFS ${XRAY_COMMON_DEFINITIONS}
227 add_compiler_rt_object_libraries(RTXrayBASIC
228 OS ${XRAY_SUPPORTED_OS}
229 ARCHS ${XRAY_SUPPORTED_ARCH}
230 SOURCES ${XRAY_BASIC_MODE_SOURCES}
231 ADDITIONAL_HEADERS ${XRAY_IMPL_HEADERS}
232 CFLAGS ${XRAY_CFLAGS}
233 DEFS ${XRAY_COMMON_DEFINITIONS}
235 add_compiler_rt_object_libraries(RTXrayPROFILING
236 OS ${XRAY_SUPPORTED_OS}
237 ARCHS ${XRAY_SUPPORTED_ARCH}
238 SOURCES ${XRAY_PROFILING_MODE_SOURCES}
239 ADDITIONAL_HEADERS ${XRAY_IMPL_HEADERS}
240 CFLAGS ${XRAY_CFLAGS}
241 DEFS ${XRAY_COMMON_DEFINITIONS}
244 # We only support running on osx for now.
245 add_compiler_rt_runtime(clang_rt.xray
247 OS ${XRAY_SUPPORTED_OS}
248 ARCHS ${XRAY_SUPPORTED_ARCH}
249 OBJECT_LIBS ${XRAY_COMMON_RUNTIME_OBJECT_LIBS} RTXray ${XRAY_RTXRAY_ARCH_LIBS}
250 CFLAGS ${XRAY_CFLAGS}
251 DEFS ${XRAY_COMMON_DEFINITIONS}
252 LINK_FLAGS ${XRAY_LINK_FLAGS} ${WEAK_SYMBOL_LINK_FLAGS}
253 LINK_LIBS ${XRAY_LINK_LIBS}
255 add_compiler_rt_runtime(clang_rt.xray-fdr
257 OS ${XRAY_SUPPORTED_OS}
258 ARCHS ${XRAY_SUPPORTED_ARCH}
259 OBJECT_LIBS RTXrayFDR
260 CFLAGS ${XRAY_CFLAGS}
261 DEFS ${XRAY_COMMON_DEFINITIONS}
262 LINK_FLAGS ${XRAY_LINK_FLAGS} ${WEAK_SYMBOL_LINK_FLAGS}
263 LINK_LIBS ${XRAY_LINK_LIBS}
265 add_compiler_rt_runtime(clang_rt.xray-basic
267 OS ${XRAY_SUPPORTED_OS}
268 ARCHS ${XRAY_SUPPORTED_ARCH}
269 OBJECT_LIBS RTXrayBASIC
270 CFLAGS ${XRAY_CFLAGS}
271 DEFS ${XRAY_COMMON_DEFINITIONS}
272 LINK_FLAGS ${XRAY_LINK_FLAGS} ${WEAK_SYMBOL_LINK_FLAGS}
273 LINK_LIBS ${XRAY_LINK_LIBS}
275 add_compiler_rt_runtime(clang_rt.xray-profiling
277 OS ${XRAY_SUPPORTED_OS}
278 ARCHS ${XRAY_SUPPORTED_ARCH}
279 OBJECT_LIBS RTXrayPROFILING
280 CFLAGS ${XRAY_CFLAGS}
281 DEFS ${XRAY_COMMON_DEFINITIONS}
282 LINK_FLAGS ${XRAY_LINK_FLAGS} ${WEAK_SYMBOL_LINK_FLAGS}
283 LINK_LIBS ${XRAY_LINK_LIBS}
286 foreach(arch ${XRAY_SUPPORTED_ARCH})
287 if(NOT CAN_TARGET_${arch})
290 add_compiler_rt_object_libraries(RTXray
292 SOURCES ${XRAY_SOURCES} ${${arch}_SOURCES}
293 ADDITIONAL_HEADERS ${XRAY_IMPL_HEADERS}
294 CFLAGS ${XRAY_CFLAGS}
295 DEFS ${XRAY_COMMON_DEFINITIONS}
297 add_compiler_rt_object_libraries(RTXrayFDR
299 SOURCES ${XRAY_FDR_MODE_SOURCES}
300 ADDITIONAL_HEADERS ${XRAY_IMPL_HEADERS}
301 CFLAGS ${XRAY_CFLAGS}
302 DEFS ${XRAY_COMMON_DEFINITIONS}
304 add_compiler_rt_object_libraries(RTXrayBASIC
306 SOURCES ${XRAY_BASIC_MODE_SOURCES}
307 ADDITIONAL_HEADERS ${XRAY_IMPL_HEADERS}
308 CFLAGS ${XRAY_CFLAGS}
309 DEFS ${XRAY_COMMON_DEFINITIONS}
311 add_compiler_rt_object_libraries(RTXrayPROFILING
313 SOURCES ${XRAY_PROFILING_MODE_SOURCES}
314 ADDITIONAL_HEADERS ${XRAY_IMPL_HEADERS}
315 CFLAGS ${XRAY_CFLAGS}
316 DEFS ${XRAY_COMMON_DEFINITIONS}
319 # Common XRay archive for instrumented binaries.
320 add_compiler_rt_runtime(clang_rt.xray
323 CFLAGS ${XRAY_CFLAGS}
324 LINK_FLAGS ${XRAY_LINK_FLAGS}
325 LINK_LIBS ${XRAY_LINK_LIBS}
326 DEFS ${XRAY_COMMON_DEFINITIONS}
327 OBJECT_LIBS ${XRAY_COMMON_RUNTIME_OBJECT_LIBS} RTXray
329 # FDR mode runtime archive (addon for clang_rt.xray)
330 add_compiler_rt_runtime(clang_rt.xray-fdr
333 CFLAGS ${XRAY_CFLAGS}
334 LINK_FLAGS ${XRAY_LINK_FLAGS}
335 LINK_LIBS ${XRAY_LINK_LIBS}
336 DEFS ${XRAY_COMMON_DEFINITIONS}
337 OBJECT_LIBS RTXrayFDR
339 # Basic mode runtime archive (addon for clang_rt.xray)
340 add_compiler_rt_runtime(clang_rt.xray-basic
343 CFLAGS ${XRAY_CFLAGS}
344 LINK_FLAGS ${XRAY_LINK_FLAGS}
345 LINK_LIBS ${XRAY_LINK_LIBS}
346 DEFS ${XRAY_COMMON_DEFINITIONS}
347 OBJECT_LIBS RTXrayBASIC
349 # Profiler Mode runtime
350 add_compiler_rt_runtime(clang_rt.xray-profiling
353 CFLAGS ${XRAY_CFLAGS}
354 LINK_FLAGS ${XRAY_LINK_FLAGS}
355 LINK_LIBS ${XRAY_LINK_LIBS}
356 DEFS ${XRAY_COMMON_DEFINITIONS}
357 OBJECT_LIBS RTXrayPROFILING
362 if(COMPILER_RT_INCLUDE_TESTS)
363 add_subdirectory(tests)