• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Build for the minimal undefined behavior sanitizer runtime support library.
2
3set(UBSAN_MINIMAL_SOURCES
4  ubsan_minimal_handlers.cpp
5  )
6
7include_directories(..)
8
9set(UBSAN_CFLAGS ${SANITIZER_COMMON_CFLAGS})
10append_rtti_flag(OFF UBSAN_CFLAGS)
11
12set(UBSAN_LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS})
13
14set(UBSAN_DYNAMIC_LIBS ${SANITIZER_COMMON_LINK_LIBS})
15
16add_compiler_rt_component(ubsan-minimal)
17
18# Common parts of minimal UBSan runtime.
19add_compiler_rt_object_libraries(RTUbsan_minimal
20  OS ${SANITIZER_COMMON_SUPPORTED_OS}
21  ARCHS ${UBSAN_COMMON_SUPPORTED_ARCH}
22  SOURCES ${UBSAN_MINIMAL_SOURCES} CFLAGS ${UBSAN_CFLAGS})
23
24
25if(COMPILER_RT_HAS_UBSAN_MINIMAL)
26  # Standalone minimal UBSan runtimes.
27  add_compiler_rt_runtime(clang_rt.ubsan_minimal
28    STATIC
29    OS ${SANITIZER_COMMON_SUPPORTED_OS}
30    ARCHS ${UBSAN_SUPPORTED_ARCH}
31    OBJECT_LIBS RTUbsan_minimal
32    CFLAGS ${UBSAN_CFLAGS}
33    PARENT_TARGET ubsan-minimal)
34
35  add_compiler_rt_runtime(clang_rt.ubsan_minimal
36    SHARED
37    OS ${SANITIZER_COMMON_SUPPORTED_OS}
38    ARCHS ${UBSAN_SUPPORTED_ARCH}
39    OBJECT_LIBS RTUbsan_minimal
40    CFLAGS ${UBSAN_CFLAGS}
41    LINK_FLAGS ${UBSAN_LINK_FLAGS}
42    LINK_LIBS ${UBSAN_DYNAMIC_LIBS}
43    PARENT_TARGET ubsan-minimal)
44
45  if (SANITIZER_USE_SYMBOLS AND NOT APPLE)
46    set(ARCHS_FOR_SYMBOLS ${UBSAN_SUPPORTED_ARCH})
47    list(REMOVE_ITEM ARCHS_FOR_SYMBOLS i386 i686)
48    add_sanitizer_rt_symbols(clang_rt.ubsan_minimal
49      ARCHS ${ARCHS_FOR_SYMBOLS}
50      PARENT_TARGET ubsan-minimal
51      EXTRA ubsan.syms.extra)
52  endif()
53endif()
54