Tarantool development patches archive
 help / color / mirror / Atom feed
* [PATCH 1/1] Fix gcov on Mac
@ 2018-12-17 11:58 Vladislav Shpilevoy
  2018-12-18 10:11 ` Vladimir Davydov
  0 siblings, 1 reply; 7+ messages in thread
From: Vladislav Shpilevoy @ 2018-12-17 11:58 UTC (permalink / raw)
  To: tarantool-patches; +Cc: vdavydov.dev

---
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")
-- 
2.17.2 (Apple Git-113)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/1] Fix gcov on Mac
  2018-12-17 11:58 [PATCH 1/1] Fix gcov on Mac Vladislav Shpilevoy
@ 2018-12-18 10:11 ` Vladimir Davydov
  2018-12-21  9:58   ` Alexander Turenko
  0 siblings, 1 reply; 7+ messages in thread
From: Vladimir Davydov @ 2018-12-18 10:11 UTC (permalink / raw)
  To: Alexander Turenko; +Cc: Vladislav Shpilevoy, tarantool-patches

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")

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/1] Fix gcov on Mac
  2018-12-18 10:11 ` Vladimir Davydov
@ 2018-12-21  9:58   ` Alexander Turenko
  2018-12-21 10:54     ` [tarantool-patches] " Vladislav Shpilevoy
  2018-12-21 13:39     ` Vladislav Shpilevoy
  0 siblings, 2 replies; 7+ messages in thread
From: Alexander Turenko @ 2018-12-21  9:58 UTC (permalink / raw)
  To: Vladislav Shpilevoy; +Cc: Vladimir Davydov, tarantool-patches

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")

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [tarantool-patches] Re: [PATCH 1/1] Fix gcov on Mac
  2018-12-21  9:58   ` Alexander Turenko
@ 2018-12-21 10:54     ` Vladislav Shpilevoy
  2018-12-21 13:39     ` Vladislav Shpilevoy
  1 sibling, 0 replies; 7+ messages in thread
From: Vladislav Shpilevoy @ 2018-12-21 10:54 UTC (permalink / raw)
  To: Alexander Turenko; +Cc: Vladimir Davydov, tarantool-patches

Thanks. Actually I do not care how gcov should be
enabled, so any solution is ok for me.

On 21/12/2018 12:58, Alexander Turenko wrote:
> 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")

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [tarantool-patches] Re: [PATCH 1/1] Fix gcov on Mac
  2018-12-21  9:58   ` Alexander Turenko
  2018-12-21 10:54     ` [tarantool-patches] " Vladislav Shpilevoy
@ 2018-12-21 13:39     ` Vladislav Shpilevoy
  2018-12-21 13:46       ` Alexander Turenko
  2018-12-21 15:33       ` Vladimir Davydov
  1 sibling, 2 replies; 7+ messages in thread
From: Vladislav Shpilevoy @ 2018-12-21 13:39 UTC (permalink / raw)
  To: tarantool-patches, Alexander Turenko; +Cc: Vladimir Davydov

New version here and on the branch:

commit f5ebb59e481ee5fbf991330d6625638ccd42de70
Author: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Date:   Fri Dec 21 16:38:32 2018 +0300

     Fix gcov on Mac

diff --git a/cmake/profile.cmake b/cmake/profile.cmake
index 278399155..ca80bd9c5 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})

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [tarantool-patches] Re: [PATCH 1/1] Fix gcov on Mac
  2018-12-21 13:39     ` Vladislav Shpilevoy
@ 2018-12-21 13:46       ` Alexander Turenko
  2018-12-21 15:33       ` Vladimir Davydov
  1 sibling, 0 replies; 7+ messages in thread
From: Alexander Turenko @ 2018-12-21 13:46 UTC (permalink / raw)
  To: Vladislav Shpilevoy; +Cc: tarantool-patches, Vladimir Davydov

I'm OK.

WBR, Alexander Turenko.

On Fri, Dec 21, 2018 at 04:39:39PM +0300, Vladislav Shpilevoy wrote:
> New version here and on the branch:
> 
> commit f5ebb59e481ee5fbf991330d6625638ccd42de70
> Author: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
> Date:   Fri Dec 21 16:38:32 2018 +0300
> 
>     Fix gcov on Mac
> 
> diff --git a/cmake/profile.cmake b/cmake/profile.cmake
> index 278399155..ca80bd9c5 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})

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [tarantool-patches] Re: [PATCH 1/1] Fix gcov on Mac
  2018-12-21 13:39     ` Vladislav Shpilevoy
  2018-12-21 13:46       ` Alexander Turenko
@ 2018-12-21 15:33       ` Vladimir Davydov
  1 sibling, 0 replies; 7+ messages in thread
From: Vladimir Davydov @ 2018-12-21 15:33 UTC (permalink / raw)
  To: Vladislav Shpilevoy; +Cc: tarantool-patches, Alexander Turenko

On Fri, Dec 21, 2018 at 04:39:39PM +0300, Vladislav Shpilevoy wrote:
> New version here and on the branch:
> 
> commit f5ebb59e481ee5fbf991330d6625638ccd42de70
> Author: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
> Date:   Fri Dec 21 16:38:32 2018 +0300
> 
>     Fix gcov on Mac
> 
> diff --git a/cmake/profile.cmake b/cmake/profile.cmake
> index 278399155..ca80bd9c5 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})

Pushed to 2.1 and 1.10.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-12-21 15:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-17 11:58 [PATCH 1/1] Fix gcov on Mac Vladislav Shpilevoy
2018-12-18 10:11 ` Vladimir Davydov
2018-12-21  9:58   ` Alexander Turenko
2018-12-21 10:54     ` [tarantool-patches] " Vladislav Shpilevoy
2018-12-21 13:39     ` Vladislav Shpilevoy
2018-12-21 13:46       ` Alexander Turenko
2018-12-21 15:33       ` Vladimir Davydov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox