zero9178 / C-Cpp-Coverage-for-CLion

Get coverage data in CLion using gcov or llvm-cov
MIT License
38 stars 2 forks source link

No llvm-profdata specified to accompany llvm-cov on macOS #17

Open khrykin opened 5 years ago

khrykin commented 5 years ago

I'm getting this error on macOS 10.14.5 with Apple Clang:

Coverage could not be generated due to following error:
 No llvm-profdata specified to accompany llvm-cov

However, both lvm-profdata and llvm-cov are in my PATH, and I'm able to generate coverage manually in terminal.

Can you please point me to a solution here?

zero9178 commented 5 years ago

Something must have gone wrong when trying to find it. It will look in different places including the PATH however.

Either way you can always change your settings by going to Settings -> Language & Frameworks -> C/C++ Coverage where you can set the needed tools for each of your toolchains

khrykin commented 5 years ago

I looked there, but I have only gcov option...

Screen Shot 2019-11-22 at 10 13 07 PM
khrykin commented 5 years ago

It seems Apple Clang gets detected as GCC by the plugin.

Default clang path on macOS is actually for the alias which is c++, not clang, so this check doesn't pass: https://github.com/zero9178/C-Cpp-Coverage-for-CLion/blob/7923276bd426f05a66d7fc20d47402ec7c1c6410/src/main/kotlin/net/zero9178/cov/settings/CoverageGeneratorSettings.kt#L219

Screen Shot 2019-11-22 at 10 39 10 PM
zero9178 commented 5 years ago

I am not sure how to handle this as c++ is also a common name for GCC and people also still that on MacOS too. I could try doing --version first on the compiler. Biggest problem is probably that I do not have a mac to test however.

The gcov field there is actually not fixed however and you can replace the path with llvm-cov and afterwards the llvm-profdata and optional demangler fields will appear.

In hand sight I probably shouldn't make the label display either gcov or llvm-cov but rather both to avoid such problems

khrykin commented 5 years ago

@zero9178, yeah, --version check would be more reliable. I was able to workaround this by changing the compiler path in my toolchain to clang++ (which is the same alias). Still, I think the issue is worth fixing.

pjattke commented 4 years ago

@khrykin I had the same issue as you. Changing the C++ compiler in "Build, Execution, Deployment" → "Toolchains" to /usr/bin/clang++ seems to work. Thanks!

However, now after running my Google Tests with Coverage I receive an error: "Coverage could not be generated due to following error: No executable specified" (see this line).

The configuration I use to run the tests looks as follow: CleanShot 2020-01-07 at 14 26 36

I also tried to run a normal (non-testing) configuration with the coverage. However, it returns the same error.

Did you have the same issue and if yes, how did you solve it? Thanks a lot!

khrykin commented 4 years ago

@pjattke on macOS I use Clang provided by XCode, which is /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++. CMAKE_CXX_COMPILER_ID for it will be 'AppleClang', not 'Clang', so I changed the STREQUAL to MATCHES in the CMake code from the README:

if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
    add_compile_options(-fprofile-instr-generate -fcoverage-mapping)
    add_link_options(-fprofile-instr-generate)
    #Uncomment in case of linker errors
    #link_libraries(clang_rt.profile-x86_64)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
    add_compile_options(--coverage)
    #Uncomment in case of linker errors
    #link_libraries(gcov)
endif ()

This probably causes your issue.

pjattke commented 4 years ago

@khrykin Thank you, now it works! The llvm-cov path under PreferencesLanguages & FrameworksC/C++Coverage was not configured either. I copied the paths already specified at Build, Execution, DeploymentCoverage to make it work.