我在 windows 和 linux 中使用 clang 7 来生成 c++ 项目的覆盖率。在 linux 中,我可以通过添加编译标志成功地生成所有覆盖信息:
-fprofile-instr-generate -fcoverage-mapping
但在 Windows 中,它返回链接器错误,并且 llvm 安装目录中不存在 llvm-cov ......
所以我猜clang不支持Windows中的代码覆盖率?这是正确的吗?
(如果不是,你能告诉我我在链接阶段缺少什么吗?)
PS:链接器错误来自:
lld-link.exe: error: duplicate symbol: __profn_??_GTestFactoryBase@internal@testing@@UEAAPEAXI@Z
至:
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:我正在使用Visual Studio Build Tools 在Windows 中使用clang 进行编译。
PS2:根据我的阅读,我们还需要将“-fprofile-instr-generate”传递给链接器......但不知道应该如何完成......
谢谢