Home | History | Annotate | Download | only in sanitizer_common
      1 # Build system for the common Sanitizer runtime support library components.
      2 # These components are shared between AddressSanitizer and ThreadSanitizer.
      3 
      4 set(SANITIZER_SOURCES
      5   sanitizer_allocator.cc
      6   sanitizer_common.cc
      7   sanitizer_flags.cc
      8   sanitizer_libc.cc
      9   sanitizer_linux.cc
     10   sanitizer_mac.cc
     11   sanitizer_platform_limits_posix.cc
     12   sanitizer_posix.cc
     13   sanitizer_printf.cc
     14   sanitizer_stackdepot.cc
     15   sanitizer_stacktrace.cc
     16   sanitizer_suppressions.cc
     17   sanitizer_symbolizer_itanium.cc
     18   sanitizer_symbolizer_linux.cc
     19   sanitizer_symbolizer_mac.cc
     20   sanitizer_symbolizer_win.cc
     21   sanitizer_thread_registry.cc
     22   sanitizer_win.cc)
     23 
     24 set(SANITIZER_LIBCDEP_SOURCES
     25   sanitizer_common_libcdep.cc
     26   sanitizer_linux_libcdep.cc
     27   sanitizer_posix_libcdep.cc
     28   sanitizer_stoptheworld_linux_libcdep.cc
     29   sanitizer_symbolizer_libcdep.cc
     30   sanitizer_symbolizer_linux_libcdep.cc
     31   sanitizer_symbolizer_posix_libcdep.cc)
     32 
     33 # Explicitly list all sanitizer_common headers. Not all of these are
     34 # included in sanitizer_common source files, but we need to depend on
     35 # headers when building our custom unit tests.
     36 set(SANITIZER_HEADERS
     37   sanitizer_allocator.h
     38   sanitizer_allocator_internal.h
     39   sanitizer_atomic_clang.h
     40   sanitizer_atomic_msvc.h
     41   sanitizer_atomic.h
     42   sanitizer_common.h
     43   sanitizer_common_interceptors.inc
     44   sanitizer_common_interceptors_ioctl.inc
     45   sanitizer_common_interceptors_scanf.inc
     46   sanitizer_common_syscalls.inc
     47   sanitizer_flags.h
     48   sanitizer_internal_defs.h
     49   sanitizer_lfstack.h
     50   sanitizer_libc.h
     51   sanitizer_linux.h
     52   sanitizer_list.h
     53   sanitizer_mutex.h
     54   sanitizer_placement_new.h
     55   sanitizer_platform_interceptors.h
     56   sanitizer_procmaps.h
     57   sanitizer_quarantine.h
     58   sanitizer_report_decorator.h
     59   sanitizer_stackdepot.h
     60   sanitizer_stacktrace.h
     61   sanitizer_symbolizer.h
     62   sanitizer_thread_registry.h)
     63 
     64 set(SANITIZER_CFLAGS
     65   ${SANITIZER_COMMON_CFLAGS}
     66   -fno-rtti)
     67 
     68 set(SANITIZER_RUNTIME_LIBRARIES)
     69 if(APPLE)
     70   # Build universal binary on APPLE.
     71   add_compiler_rt_osx_object_library(RTSanitizerCommon
     72     ARCH ${SANITIZER_COMMON_SUPPORTED_ARCH}
     73     SOURCES ${SANITIZER_SOURCES} ${SANITIZER_LIBCDEP_SOURCES}
     74     CFLAGS ${SANITIZER_CFLAGS})
     75   list(APPEND SANITIZER_RUNTIME_LIBRARIES RTSanitizerCommon.osx)
     76 elseif(ANDROID)
     77   add_library(RTSanitizerCommon.arm.android OBJECT
     78     ${SANITIZER_SOURCES} ${SANITIZER_LIBCDEP_SOURCES})
     79   set_target_compile_flags(RTSanitizerCommon.arm.android
     80     ${SANITIZER_CFLAGS})
     81   list(APPEND SANITIZER_RUNTIME_LIBRARIES RTSanitizerCommon.arm.android)
     82 else()
     83   # Otherwise, build separate libraries for each target.
     84   foreach(arch ${SANITIZER_COMMON_SUPPORTED_ARCH})
     85     add_compiler_rt_object_library(RTSanitizerCommon ${arch}
     86       SOURCES ${SANITIZER_SOURCES} CFLAGS ${SANITIZER_CFLAGS})
     87     add_compiler_rt_object_library(RTSanitizerCommonLibc ${arch}
     88       SOURCES ${SANITIZER_LIBCDEP_SOURCES} CFLAGS ${SANITIZER_CFLAGS})
     89     add_compiler_rt_static_runtime(clang_rt.san-${arch} ${arch}
     90       SOURCES $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
     91               $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
     92       CFLAGS ${SANITIZER_CFLAGS})
     93     list(APPEND SANITIZER_RUNTIME_LIBRARIES RTSanitizerCommon.${arch})
     94   endforeach()
     95 endif()
     96 
     97 # Unit tests for common sanitizer runtime.
     98 if(LLVM_INCLUDE_TESTS)
     99   add_subdirectory(tests)
    100 endif()
    101