Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
khrykin opened this issue Nov 22, 2019 · 8 comments
Open

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

khrykin opened this issue Nov 22, 2019 · 8 comments

Comments

@khrykin
Copy link

khrykin commented Nov 22, 2019

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
Copy link
Owner

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
Copy link
Author

khrykin commented Nov 22, 2019

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

Screen Shot 2019-11-22 at 10 13 07 PM

@khrykin
Copy link
Author

khrykin commented Nov 22, 2019

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:

if (compiler != null && compiler.contains("clang", true)) {

Screen Shot 2019-11-22 at 10 39 10 PM

@zero9178
Copy link
Owner

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
Copy link
Author

khrykin commented Nov 23, 2019

@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
Copy link

pjattke commented Jan 7, 2020

@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
Copy link
Author

khrykin commented Jan 7, 2020

@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
Copy link

pjattke commented Jan 7, 2020

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants