Index: include/CMakeLists.txt =================================================================== --- include/CMakeLists.txt +++ include/CMakeLists.txt @@ -1,4 +1,7 @@ if (COMPILER_RT_BUILD_SANITIZERS) + set(GCOV_COMPAT_HEADERS + gcov.h) + set(SANITIZER_HEADERS sanitizer/allocator_interface.h sanitizer/asan_interface.h @@ -20,6 +23,7 @@ endif(COMPILER_RT_BUILD_XRAY) set(COMPILER_RT_HEADERS + ${GCOV_COMPAT_HEADERS} ${SANITIZER_HEADERS} ${XRAY_HEADERS}) @@ -41,6 +45,10 @@ add_dependencies(compiler-rt compiler-rt-headers) set_target_properties(compiler-rt-headers PROPERTIES FOLDER "Compiler-RT Misc") +# Install gcov compat headers. +install(FILES ${GCOV_COMPAT_HEADERS} + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ + DESTINATION ${COMPILER_RT_INSTALL_PATH}/include) # Install sanitizer headers. install(FILES ${SANITIZER_HEADERS} PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ Index: include/gcov.h =================================================================== --- include/gcov.h +++ include/gcov.h @@ -0,0 +1,24 @@ +/*===---------------------------- gcov.h ----------------------------------===*\ +|* +|* The LLVM Compiler Infrastructure +|* +|* This file is distributed under the University of Illinois Open Source +|* License. See LICENSE.TXT for details. +|* +|*===----------------------------------------------------------------------===*| +|* +|* This file provides symbols for calls which are available to end-users when +|* using gcov(3). +|* +\*===----------------------------------------------------------------------===*/ + +#ifndef COMPILER_RT_GCOV_H +#define COMPILER_RT_GCOV_H + +/* + * - Write profile information/counters out to their appropriate GCDA files. + * - Reset profile counters to zero. + */ +extern void __gcov_flush(void); + +#endif Index: lib/profile/CMakeLists.txt =================================================================== --- lib/profile/CMakeLists.txt +++ lib/profile/CMakeLists.txt @@ -55,6 +55,8 @@ InstrProfilingRuntime.cc InstrProfilingUtil.c) +include_directories(../../include) + if(WIN32) list(APPEND PROFILE_SOURCES WindowsMMap.c) endif() Index: lib/profile/GCDAProfiling.c =================================================================== --- lib/profile/GCDAProfiling.c +++ lib/profile/GCDAProfiling.c @@ -29,6 +29,8 @@ #include #include +#include + #if defined(_WIN32) #include "WindowsMMap.h" #else