brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.9 KiB · 2846f02 Raw
136 lines · plain
1add_compiler_rt_component(nsan)2 3include_directories(..)4 5set(NSAN_SOURCES6  nsan.cpp7  nsan_allocator.cpp8  nsan_flags.cpp9  nsan_interceptors.cpp10  nsan_malloc_linux.cpp11  nsan_new_delete.cpp12  nsan_stats.cpp13  nsan_suppressions.cpp14  nsan_thread.cpp15)16 17set(NSAN_PREINIT_SOURCES18  nsan_preinit.cpp)19 20set(NSAN_HEADERS21  nsan.h22  nsan_flags.h23  nsan_flags.inc24  nsan_platform.h25  nsan_stats.h26  nsan_suppressions.h27)28 29set(NSAN_DYNAMIC_LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS})30 31set(NSAN_CFLAGS ${SANITIZER_COMMON_CFLAGS})32append_rtti_flag(OFF NSAN_CFLAGS)33 34set(NSAN_DYNAMIC_CFLAGS ${NSAN_CFLAGS})35 36set(NSAN_COMMON_RUNTIME_OBJECT_LIBS37  RTInterception38  RTSanitizerCommon39  RTSanitizerCommonLibc40  RTSanitizerCommonCoverage41  RTSanitizerCommonSymbolizer42  RTSanitizerCommonSymbolizerInternal43  RTUbsan)44 45set(NSAN_DYNAMIC_LIBS46  ${COMPILER_RT_UNWINDER_LINK_LIBS}47  ${SANITIZER_CXX_ABI_LIBRARIES}48  ${SANITIZER_COMMON_LINK_LIBS})49 50append_list_if(COMPILER_RT_HAS_LIBDL dl NSAN_DYNAMIC_LIBS)51append_list_if(COMPILER_RT_HAS_LIBRT rt NSAN_DYNAMIC_LIBS)52append_list_if(COMPILER_RT_HAS_LIBM m NSAN_DYNAMIC_LIBS)53append_list_if(COMPILER_RT_HAS_LIBPTHREAD pthread NSAN_DYNAMIC_LIBS)54 55# Compile sources into an object library.56 57add_compiler_rt_object_libraries(RTNsan_dynamic58  ARCHS ${NSAN_SUPPORTED_ARCH}59  SOURCES ${NSAN_SOURCES}60  ADDITIONAL_HEADERS ${NSAN_HEADERS}61  CFLAGS ${NSAN_CFLAGS})62 63if(NOT APPLE)64  add_compiler_rt_object_libraries(RTNsan65      ARCHS ${NSAN_SUPPORTED_ARCH}66      SOURCES ${NSAN_SOURCES}67      ADDITIONAL_HEADERS ${NSAN_HEADERS}68      CFLAGS ${NSAN_CFLAGS})69 70  add_compiler_rt_object_libraries(RTNsan_preinit71    ARCHS ${NSAN_SUPPORTED_ARCH}72    SOURCES ${NSAN_PREINIT_SOURCES}73    ADDITIONAL_HEADERS ${NSAN_HEADERS}74    CFLAGS ${NSAN_CFLAGS})75 76  file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp "")77  add_compiler_rt_object_libraries(RTNsan_dynamic_version_script_dummy78    ARCHS ${NSAN_SUPPORTED_ARCH}79    SOURCES ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp80    CFLAGS ${NSAN_DYNAMIC_CFLAGS})81endif()82 83add_compiler_rt_runtime(84  clang_rt.nsan85  STATIC86  ARCHS ${NSAN_SUPPORTED_ARCH}87  OBJECT_LIBS RTNsan_preinit RTNsan88              ${NSAN_COMMON_RUNTIME_OBJECT_LIBS}89  CFLAGS ${NSAN_CFLAGS}90  PARENT_TARGET nsan)91 92if(NOT APPLE)93  foreach(arch ${NSAN_SUPPORTED_ARCH})94    if (COMPILER_RT_HAS_VERSION_SCRIPT)95      add_sanitizer_rt_version_list(clang_rt.nsan-dynamic-${arch}96                                    LIBS clang_rt.nsan-${arch}97                                    EXTRA nsan.syms.extra)98      set(VERSION_SCRIPT_FLAG99           -Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/clang_rt.nsan-dynamic-${arch}.vers)100      # The Solaris 11.4 linker supports a subset of GNU ld version scripts,101      # but requires a special option to enable it.102      if (COMPILER_RT_HAS_GNU_VERSION_SCRIPT_COMPAT)103          list(APPEND VERSION_SCRIPT_FLAG -Wl,-z,gnu-version-script-compat)104      endif()105      set_property(SOURCE106        ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp107        APPEND PROPERTY108        OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/clang_rt.nsan-dynamic-${arch}.vers)109    else()110      set(VERSION_SCRIPT_FLAG)111    endif()112 113    add_compiler_rt_runtime(114      clang_rt.nsan115      SHARED116      ARCHS ${arch}117      OBJECT_LIBS ${NSAN_COMMON_RUNTIME_OBJECT_LIBS}118        RTNsan_dynamic119        # The only purpose of RTNsan_dynamic_version_script_dummy is to120        # carry a dependency of the shared runtime on the version script.121        # Replacing it with a straightforward122        # add_dependencies(clang_rt.nsan-dynamic-${arch} clang_rt.nsan-dynamic-${arch}-version-list)123        # generates an order-only dependency in ninja.124        RTNsan_dynamic_version_script_dummy125      CFLAGS ${NSAN_DYNAMIC_CFLAGS}126      LINK_FLAGS ${NSAN_DYNAMIC_LINK_FLAGS}127        ${VERSION_SCRIPT_FLAG}128      LINK_LIBS ${NSAN_DYNAMIC_LIBS}129      PARENT_TARGET nsan)130  endforeach()131endif()132 133if(COMPILER_RT_INCLUDE_TESTS)134  add_subdirectory(tests)135endif()136