From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Fri, 21 Dec 2018 12:58:47 +0300 From: Alexander Turenko Subject: Re: [PATCH 1/1] Fix gcov on Mac Message-ID: <20181221095847.pgzzjfmnx2gvum37@tkn_work_nb> References: <0b5a8c7bdf150d855e500e1dfa971bf47ec70daf.1545047861.git.v.shpilevoy@tarantool.org> <20181218101108.wt5vd2sxztx7d4pc@esperanza> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20181218101108.wt5vd2sxztx7d4pc@esperanza> To: Vladislav Shpilevoy Cc: Vladimir Davydov , tarantool-patches@freelists.org List-ID: I think we should check for __gcov_flush on Mac OS too, because it is in the libraries; for me in: /Applications/Xcode83.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/8.1.0/lib/darwin/libclang_rt.profile_tvos.a /Applications/Xcode83.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/8.1.0/lib/darwin/libclang_rt.profile_tvossim.a Don't sure which one is actually used. But we should not add -lgcov (it assumed by -ftest-coverage on GCC, but not on clang). This patch works for me on Mac OS (and should on Linux too): diff --git a/cmake/profile.cmake b/cmake/profile.cmake index 02d622187..3e8f1499b 100644 --- a/cmake/profile.cmake +++ b/cmake/profile.cmake @@ -1,4 +1,6 @@ -check_library_exists (gcov __gcov_flush "" HAVE_GCOV) +set(CMAKE_REQUIRED_FLAGS "-fprofile-arcs -ftest-coverage") +check_library_exists("" __gcov_flush "" HAVE_GCOV) +set(CMAKE_REQUIRED_FLAGS "") set(ENABLE_GCOV_DEFAULT OFF) option(ENABLE_GCOV "Enable integration with gcov, a code coverage program" ${ENABLE_GCOV_DEFAULT}) WBR, Alexander Turenko. On Tue, Dec 18, 2018 at 01:11:08PM +0300, Vladimir Davydov wrote: > Alexander, please take a look. > > On Mon, Dec 17, 2018 at 02:58:21PM +0300, Vladislav Shpilevoy wrote: > > --- > > https://github.com/tarantool/tarantool/tree/gerold103/enable-gcov-on-mac > > > > cmake/profile.cmake | 12 +++++++----- > > 1 file changed, 7 insertions(+), 5 deletions(-) > > > > diff --git a/cmake/profile.cmake b/cmake/profile.cmake > > index 278399155..866c8a787 100644 > > --- a/cmake/profile.cmake > > +++ b/cmake/profile.cmake > > @@ -1,12 +1,16 @@ > > -check_library_exists (gcov __gcov_flush "" HAVE_GCOV) > > +check_library_exists(gcov __gcov_flush "" HAVE_GCOV) > > > > set(ENABLE_GCOV_DEFAULT OFF) > > option(ENABLE_GCOV "Enable integration with gcov, a code coverage program" ${ENABLE_GCOV_DEFAULT}) > > > > if (ENABLE_GCOV) > > if (NOT HAVE_GCOV) > > - message (FATAL_ERROR > > - "ENABLE_GCOV option requested but gcov library is not found") > > + if (CMAKE_COMPILER_IS_CLANG) > > + message(WARNING "GCOV is available on clang from 3.0.0") > > + set(HAVE_GCOV 1) > > + else() > > + message(FATAL_ERROR "ENABLE_GCOV option requested but gcov library is not found") > > + endif() > > endif() > > > > add_compile_flags("C;CXX" > > @@ -18,8 +22,6 @@ if (ENABLE_GCOV) > > set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -ftest-coverage") > > set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fprofile-arcs") > > set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -ftest-coverage") > > - > > - # add_library(gcov SHARED IMPORTED) > > endif() > > > > if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")