1

I'm using clang 7 in windows and linux to generate coverage on c++ project. In linux I can successufuly generate all coverage information simply by adding compilation flags:

-fprofile-instr-generate -fcoverage-mapping

But in windows it returns me linker errors and also llvm-cov does not exist in llvm installation dir...

So i'm guessing that clang does not support code coverage in windows? is this right?

(if not can you tell me what i'm missing in linkage stage?)

PS: linker errors go from:

lld-link.exe: error: duplicate symbol: __profn_??_GTestFactoryBase@internal@testing@@UEAAPEAXI@Z

to:

lld-link.exe: error: undefined symbol: __llvm_profile_runtime
>>> referenced by src\app\CMakeFiles\app.dir\main.cpp.obj:(__llvm_profile_runtime_user)


lld-link.exe: error: undefined symbol: __llvm_profile_register_function
>>> referenced by src\app\CMakeFiles\app.dir\main.cpp.obj:(__llvm_profile_register_functions)
>>> referenced by src\app\CMakeFiles\app.dir\main.cpp.obj:(__llvm_profile_register_functions)

PS: i'm using visual studio Build Tools to compile with clang in windows.

PS2: from what i read we need to pass "-fprofile-instr-generate" to the linker also... but don't know how this should be done...

Thanks

Nuno
  • 1,910
  • 2
  • 21
  • 33

1 Answers1

0

on windows you should use clang-cl.exe with --coverage option. This link will help you to do that... https://marco-c.github.io/2018/01/09/code-coverage-with-clang-on-windows.html

  • Hello, and welcome to stack overflow. While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. [Answers that are little more than a link may be deleted](https://stackoverflow.com/help/deleted-answers). – dbc Feb 14 '19 at 09:08