1 # Build for the undefined behavior sanitizer runtime support library.
11 set(UBSAN_STANDALONE_SOURCES
12 ubsan_init_standalone.cc
18 ubsan_type_hash_itanium.cc
19 ubsan_type_hash_win.cc
22 include_directories(..)
24 set(UBSAN_CFLAGS ${SANITIZER_COMMON_CFLAGS})
25 append_no_rtti_flag(UBSAN_CFLAGS)
26 set(UBSAN_STANDALONE_CFLAGS ${SANITIZER_COMMON_CFLAGS})
27 append_no_rtti_flag(UBSAN_STANDALONE_CFLAGS)
28 set(UBSAN_CXXFLAGS ${SANITIZER_COMMON_CFLAGS})
30 add_custom_target(ubsan)
33 set(UBSAN_COMMON_SOURCES ${UBSAN_SOURCES})
34 if(SANITIZER_CAN_USE_CXXABI)
35 list(APPEND UBSAN_COMMON_SOURCES ${UBSAN_CXX_SOURCES})
38 # Common parts of UBSan runtime.
39 add_compiler_rt_object_libraries(RTUbsan
40 OS ${SANITIZER_COMMON_SUPPORTED_OS}
41 ARCHS ${UBSAN_COMMON_SUPPORTED_ARCH}
42 SOURCES ${UBSAN_COMMON_SOURCES}
43 CFLAGS ${UBSAN_CXXFLAGS})
45 if(COMPILER_RT_HAS_UBSAN)
46 # Initializer of standalone UBSan runtime.
47 add_compiler_rt_object_libraries(RTUbsan_standalone
48 OS ${SANITIZER_COMMON_SUPPORTED_OS}
49 ARCHS ${UBSAN_SUPPORTED_ARCH}
50 SOURCES ${UBSAN_STANDALONE_SOURCES}
51 CFLAGS ${UBSAN_STANDALONE_CFLAGS})
53 add_compiler_rt_runtime(clang_rt.ubsan
55 OS ${SANITIZER_COMMON_SUPPORTED_OS}
56 ARCHS ${UBSAN_SUPPORTED_ARCH}
65 # Common parts of UBSan runtime.
66 add_compiler_rt_object_libraries(RTUbsan
67 ARCHS ${UBSAN_COMMON_SUPPORTED_ARCH}
68 SOURCES ${UBSAN_SOURCES} CFLAGS ${UBSAN_CFLAGS})
69 # C++-specific parts of UBSan runtime. Requires a C++ ABI library.
70 add_compiler_rt_object_libraries(RTUbsan_cxx
71 ARCHS ${UBSAN_COMMON_SUPPORTED_ARCH}
72 SOURCES ${UBSAN_CXX_SOURCES} CFLAGS ${UBSAN_CXXFLAGS})
74 if(COMPILER_RT_HAS_UBSAN)
75 # Initializer of standalone UBSan runtime.
76 add_compiler_rt_object_libraries(RTUbsan_standalone
77 ARCHS ${UBSAN_SUPPORTED_ARCH}
78 SOURCES ${UBSAN_STANDALONE_SOURCES} CFLAGS ${UBSAN_STANDALONE_CFLAGS})
80 # Standalone UBSan runtimes.
81 add_compiler_rt_runtime(clang_rt.ubsan_standalone
83 ARCHS ${UBSAN_SUPPORTED_ARCH}
84 OBJECT_LIBS RTSanitizerCommon
88 CFLAGS ${UBSAN_CFLAGS}
91 add_compiler_rt_runtime(clang_rt.ubsan_standalone_cxx
93 ARCHS ${UBSAN_SUPPORTED_ARCH}
94 OBJECT_LIBS RTUbsan_cxx
95 CFLAGS ${UBSAN_CXXFLAGS}
99 set(ARCHS_FOR_SYMBOLS ${UBSAN_SUPPORTED_ARCH})
100 list(REMOVE_ITEM ARCHS_FOR_SYMBOLS i386 i686)
101 add_sanitizer_rt_symbols(clang_rt.ubsan_standalone
102 ARCHS ${ARCHS_FOR_SYMBOLS}
104 EXTRA ubsan.syms.extra)
105 add_sanitizer_rt_symbols(clang_rt.ubsan_standalone_cxx
106 ARCHS ${ARCHS_FOR_SYMBOLS}
108 EXTRA ubsan.syms.extra)
113 add_dependencies(compiler-rt ubsan)