brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.2 KiB · e6d99da Raw
211 lines · plain
1# Build for the Memory Profiler runtime support library.2 3set(MEMPROF_SOURCES4  memprof_allocator.cpp5  memprof_descriptions.cpp6  memprof_flags.cpp7  memprof_interceptors.cpp8  memprof_interceptors_memintrinsics.cpp9  memprof_linux.cpp10  memprof_malloc_linux.cpp11  memprof_mibmap.cpp12  memprof_posix.cpp13  memprof_rawprofile.cpp14  memprof_rtl.cpp15  memprof_shadow_setup.cpp16  memprof_stack.cpp17  memprof_stats.cpp18  memprof_thread.cpp19  )20 21set(MEMPROF_CXX_SOURCES22  memprof_new_delete.cpp23  )24 25set(MEMPROF_PREINIT_SOURCES26  memprof_preinit.cpp27  )28 29SET(MEMPROF_HEADERS30  memprof_allocator.h31  memprof_descriptions.h32  memprof_flags.h33  memprof_flags.inc34  memprof_init_version.h35  memprof_interceptors.h36  memprof_interceptors_memintrinsics.h37  memprof_interface_internal.h38  memprof_internal.h39  memprof_mapping.h40  memprof_mibmap.h41  memprof_rawprofile.h42  memprof_stack.h43  memprof_stats.h44  memprof_thread.h45  )46 47include_directories(..)48include_directories(../../include)49 50set(MEMPROF_CFLAGS ${SANITIZER_COMMON_CFLAGS})51set(MEMPROF_COMMON_DEFINITIONS "")52 53# Too many existing bugs, needs cleanup.54append_list_if(COMPILER_RT_HAS_WNO_FORMAT -Wno-format MEMPROF_CFLAGS)55 56append_rtti_flag(OFF MEMPROF_CFLAGS)57 58set(MEMPROF_DYNAMIC_LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS})59 60set(MEMPROF_DYNAMIC_DEFINITIONS61  ${MEMPROF_COMMON_DEFINITIONS} MEMPROF_DYNAMIC=1)62 63set(MEMPROF_DYNAMIC_CFLAGS ${MEMPROF_CFLAGS})64append_list_if(COMPILER_RT_HAS_FTLS_MODEL_INITIAL_EXEC65  -ftls-model=initial-exec MEMPROF_DYNAMIC_CFLAGS)66 67set(MEMPROF_DYNAMIC_LIBS68  ${COMPILER_RT_UNWINDER_LINK_LIBS}69  ${SANITIZER_CXX_ABI_LIBRARIES}70  ${SANITIZER_COMMON_LINK_LIBS})71 72append_list_if(COMPILER_RT_HAS_LIBDL dl MEMPROF_DYNAMIC_LIBS)73append_list_if(COMPILER_RT_HAS_LIBRT rt MEMPROF_DYNAMIC_LIBS)74append_list_if(COMPILER_RT_HAS_LIBM m MEMPROF_DYNAMIC_LIBS)75append_list_if(COMPILER_RT_HAS_LIBPTHREAD pthread MEMPROF_DYNAMIC_LIBS)76append_list_if(COMPILER_RT_HAS_LIBLOG log MEMPROF_DYNAMIC_LIBS)77 78# Compile MemProf sources into an object library.79 80add_compiler_rt_object_libraries(RTMemprof_dynamic81  OS ${SANITIZER_COMMON_SUPPORTED_OS}82  ARCHS ${MEMPROF_SUPPORTED_ARCH}83  SOURCES ${MEMPROF_SOURCES} ${MEMPROF_CXX_SOURCES}84  ADDITIONAL_HEADERS ${MEMPROF_HEADERS}85  CFLAGS ${MEMPROF_DYNAMIC_CFLAGS}86  DEFS ${MEMPROF_DYNAMIC_DEFINITIONS}87  DEPS ${MEMPROF_DEPS})88 89add_compiler_rt_object_libraries(RTMemprof90  ARCHS ${MEMPROF_SUPPORTED_ARCH}91  SOURCES ${MEMPROF_SOURCES}92  ADDITIONAL_HEADERS ${MEMPROF_HEADERS}93  CFLAGS ${MEMPROF_CFLAGS}94  DEFS ${MEMPROF_COMMON_DEFINITIONS}95  DEPS ${MEMPROF_DEPS})96add_compiler_rt_object_libraries(RTMemprof_cxx97  ARCHS ${MEMPROF_SUPPORTED_ARCH}98  SOURCES ${MEMPROF_CXX_SOURCES}99  ADDITIONAL_HEADERS ${MEMPROF_HEADERS}100  CFLAGS ${MEMPROF_CFLAGS}101  DEFS ${MEMPROF_COMMON_DEFINITIONS}102  DEPS ${MEMPROF_DEPS})103add_compiler_rt_object_libraries(RTMemprof_preinit104  ARCHS ${MEMPROF_SUPPORTED_ARCH}105  SOURCES ${MEMPROF_PREINIT_SOURCES}106  ADDITIONAL_HEADERS ${MEMPROF_HEADERS}107  CFLAGS ${MEMPROF_CFLAGS}108  DEFS ${MEMPROF_COMMON_DEFINITIONS}109  DEPS ${MEMPROF_DEPS})110 111file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp "")112add_compiler_rt_object_libraries(RTMemprof_dynamic_version_script_dummy113  ARCHS ${MEMPROF_SUPPORTED_ARCH}114  SOURCES ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp115  CFLAGS ${MEMPROF_DYNAMIC_CFLAGS}116  DEFS ${MEMPROF_DYNAMIC_DEFINITIONS}117  DEPS ${MEMPROF_DEPS})118 119# Build MemProf runtimes shipped with Clang.120add_compiler_rt_component(memprof)121 122# Build separate libraries for each target.123 124set(MEMPROF_COMMON_RUNTIME_OBJECT_LIBS125  RTInterception126  RTSanitizerCommon127  RTSanitizerCommonLibc128  RTSanitizerCommonCoverage129  RTSanitizerCommonSymbolizer130  # FIXME: hangs.131  # RTSanitizerCommonSymbolizerInternal132)133 134add_compiler_rt_runtime(clang_rt.memprof135  STATIC136  ARCHS ${MEMPROF_SUPPORTED_ARCH}137  OBJECT_LIBS RTMemprof_preinit138              RTMemprof139              ${MEMPROF_COMMON_RUNTIME_OBJECT_LIBS}140  CFLAGS ${MEMPROF_CFLAGS}141  DEFS ${MEMPROF_COMMON_DEFINITIONS}142  PARENT_TARGET memprof)143 144add_compiler_rt_runtime(clang_rt.memprof_cxx145  STATIC146  ARCHS ${MEMPROF_SUPPORTED_ARCH}147  OBJECT_LIBS RTMemprof_cxx148  CFLAGS ${MEMPROF_CFLAGS}149  DEFS ${MEMPROF_COMMON_DEFINITIONS}150  PARENT_TARGET memprof)151 152add_compiler_rt_runtime(clang_rt.memprof-preinit153  STATIC154  ARCHS ${MEMPROF_SUPPORTED_ARCH}155  OBJECT_LIBS RTMemprof_preinit156  CFLAGS ${MEMPROF_CFLAGS}157  DEFS ${MEMPROF_COMMON_DEFINITIONS}158  PARENT_TARGET memprof)159 160foreach(arch ${MEMPROF_SUPPORTED_ARCH})161  if (UNIX)162    add_sanitizer_rt_version_list(clang_rt.memprof-dynamic-${arch}163                                  LIBS clang_rt.memprof-${arch} clang_rt.memprof_cxx-${arch}164                                  EXTRA memprof.syms.extra)165    set(VERSION_SCRIPT_FLAG166         -Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/clang_rt.memprof-dynamic-${arch}.vers)167    set_property(SOURCE168      ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp169      APPEND PROPERTY170      OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/clang_rt.memprof-dynamic-${arch}.vers)171  else()172    set(VERSION_SCRIPT_FLAG)173  endif()174 175  set(MEMPROF_DYNAMIC_WEAK_INTERCEPTION)176 177  add_compiler_rt_runtime(clang_rt.memprof178    SHARED179    ARCHS ${arch}180    OBJECT_LIBS ${MEMPROF_COMMON_RUNTIME_OBJECT_LIBS}181            RTMemprof_dynamic182            # The only purpose of RTMemprof_dynamic_version_script_dummy is to183            # carry a dependency of the shared runtime on the version script.184            # Replacing it with a straightforward185            # add_dependencies(clang_rt.memprof-dynamic-${arch} clang_rt.memprof-dynamic-${arch}-version-list)186            # generates an order-only dependency in ninja.187            RTMemprof_dynamic_version_script_dummy188            ${MEMPROF_DYNAMIC_WEAK_INTERCEPTION}189    CFLAGS ${MEMPROF_DYNAMIC_CFLAGS}190    LINK_FLAGS ${MEMPROF_DYNAMIC_LINK_FLAGS}191              ${VERSION_SCRIPT_FLAG}192    LINK_LIBS ${MEMPROF_DYNAMIC_LIBS}193    DEFS ${MEMPROF_DYNAMIC_DEFINITIONS}194    PARENT_TARGET memprof)195 196  if (SANITIZER_USE_SYMBOLS)197    add_sanitizer_rt_symbols(clang_rt.memprof_cxx198      ARCHS ${arch})199    add_dependencies(memprof clang_rt.memprof_cxx-${arch}-symbols)200    add_sanitizer_rt_symbols(clang_rt.memprof201      ARCHS ${arch}202      EXTRA memprof.syms.extra)203    add_dependencies(memprof clang_rt.memprof-${arch}-symbols)204  endif()205endforeach()206 207 208if(COMPILER_RT_INCLUDE_TESTS)209  add_subdirectory(tests)210endif()211