Skip to content

Commit 653109e

Browse files
committed
[TYSan][CMake] CMake build fixes
TYSan CMake build follows patterns used by other sanitizers, but there's also a number of issues, like referring to undefined variables, which breaks the build in some cases (such as cross-compiling). This change addresses the issues.
1 parent 5b74fb7 commit 653109e

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

compiler-rt/lib/tysan/CMakeLists.txt

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,25 @@ include_directories(..)
33
# Runtime library sources and build flags.
44
set(TYSAN_SOURCES
55
tysan.cpp
6-
tysan_interceptors.cpp)
6+
tysan_interceptors.cpp
7+
)
8+
9+
SET(TYSAN_HEADERS
10+
tysan_flags.inc
11+
)
12+
713
set(TYSAN_COMMON_CFLAGS ${SANITIZER_COMMON_CFLAGS})
814
append_rtti_flag(OFF TYSAN_COMMON_CFLAGS)
915
# Prevent clang from generating libc calls.
1016
append_list_if(COMPILER_RT_HAS_FFREESTANDING_FLAG -ffreestanding TYSAN_COMMON_CFLAGS)
1117

18+
set(TYSAN_COMMON_DEFINITIONS "")
19+
set(TYSAN_DYNAMIC_DEFINITIONS ${TYSAN_COMMON_DEFINITIONS})
20+
21+
set(TYSAN_DYNAMIC_CFLAGS ${TYSAN_COMMON_CFLAGS})
22+
23+
# Compile TYSan sources into an object library.
24+
1225
add_compiler_rt_object_libraries(RTTysan_dynamic
1326
OS ${SANITIZER_COMMON_SUPPORTED_OS}
1427
ARCHS ${TYSAN_SUPPORTED_ARCH}
@@ -47,17 +60,18 @@ if(APPLE)
4760
DEFS ${TYSAN_COMMON_DEFINITIONS}
4861
PARENT_TARGET tysan)
4962
else()
63+
set(TYSAN_CFLAGS ${TYSAN_COMMON_CFLAGS})
64+
append_list_if(COMPILER_RT_HAS_FPIE_FLAG -fPIE TYSAN_CFLAGS)
65+
5066
foreach(arch ${TYSAN_SUPPORTED_ARCH})
51-
set(TYSAN_CFLAGS ${TYSAN_COMMON_CFLAGS})
52-
append_list_if(COMPILER_RT_HAS_FPIE_FLAG -fPIE TYSAN_CFLAGS)
5367
add_compiler_rt_runtime(clang_rt.tysan
5468
STATIC
5569
ARCHS ${arch}
5670
SOURCES ${TYSAN_SOURCES}
57-
$<TARGET_OBJECTS:RTInterception.${arch}>
58-
$<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
59-
$<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
60-
$<TARGET_OBJECTS:RTSanitizerCommonSymbolizer.${arch}>
71+
OBJECT_LIBS RTInterception
72+
RTSanitizerCommon
73+
RTSanitizerCommonLibc
74+
RTSanitizerCommonSymbolizer
6175
CFLAGS ${TYSAN_CFLAGS}
6276
PARENT_TARGET tysan)
6377
endforeach()

0 commit comments

Comments
 (0)