Skip to content

Commit 9a88ede

Browse files
authored
[TYSan][CMake] CMake build fixes (llvm#121224)
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 fb365ac commit 9a88ede

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

compiler-rt/lib/tysan/CMakeLists.txt

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +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.h
11+
tysan_flags.inc
12+
tysan_platform.h
13+
)
14+
715
set(TYSAN_COMMON_CFLAGS ${SANITIZER_COMMON_CFLAGS})
816
append_rtti_flag(OFF TYSAN_COMMON_CFLAGS)
917
# Prevent clang from generating libc calls.
1018
append_list_if(COMPILER_RT_HAS_FFREESTANDING_FLAG -ffreestanding TYSAN_COMMON_CFLAGS)
19+
set(TYSAN_DYNAMIC_CFLAGS ${TYSAN_COMMON_CFLAGS})
20+
21+
set(TYSAN_COMMON_DEFINITIONS "")
22+
set(TYSAN_DYNAMIC_DEFINITIONS ${TYSAN_COMMON_DEFINITIONS} TYSAN_DYNAMIC=1)
23+
24+
# Compile TYSan sources into an object library.
1125

1226
add_compiler_rt_object_libraries(RTTysan_dynamic
1327
OS ${SANITIZER_COMMON_SUPPORTED_OS}
@@ -47,17 +61,18 @@ if(APPLE)
4761
DEFS ${TYSAN_COMMON_DEFINITIONS}
4862
PARENT_TARGET tysan)
4963
else()
64+
set(TYSAN_CFLAGS ${TYSAN_COMMON_CFLAGS})
65+
append_list_if(COMPILER_RT_HAS_FPIE_FLAG -fPIE TYSAN_CFLAGS)
66+
5067
foreach(arch ${TYSAN_SUPPORTED_ARCH})
51-
set(TYSAN_CFLAGS ${TYSAN_COMMON_CFLAGS})
52-
append_list_if(COMPILER_RT_HAS_FPIE_FLAG -fPIE TYSAN_CFLAGS)
5368
add_compiler_rt_runtime(clang_rt.tysan
5469
STATIC
5570
ARCHS ${arch}
5671
SOURCES ${TYSAN_SOURCES}
57-
$<TARGET_OBJECTS:RTInterception.${arch}>
58-
$<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
59-
$<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
60-
$<TARGET_OBJECTS:RTSanitizerCommonSymbolizer.${arch}>
72+
OBJECT_LIBS RTInterception
73+
RTSanitizerCommon
74+
RTSanitizerCommonLibc
75+
RTSanitizerCommonSymbolizer
6176
CFLAGS ${TYSAN_CFLAGS}
6277
PARENT_TARGET tysan)
6378
endforeach()

0 commit comments

Comments
 (0)