gpt4 book ai didi

c++ - 可以在 Windows 中使用 clang-cl 标志 -fprofile-instr-generate -fcoverage-mapping

转载 作者:太空宇宙 更新时间:2023-11-04 12:42:24 24 4
gpt4 key购买 nike

我在 Windows 和 Linux 中使用 clang 7 来生成 C++ 项目的覆盖率。在 linux 中,我可以通过添加编译标志成功地生成所有覆盖信息:

-fprofile-instr-generate -fcoverage-mapping

但在 Windows 中,它返回链接器错误,而且 llvm-cov 在 llvm 安装目录中不存在......

所以我猜 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”传递给链接器……但不知道该怎么做……

谢谢

最佳答案

在 Windows 上,您应该使用带有 --coverage 选项的 clang-cl.exe。此链接将帮助您做到这一点... https://marco-c.github.io/2018/01/09/code-coverage-with-clang-on-windows.html

关于c++ - 可以在 Windows 中使用 clang-cl 标志 -fprofile-instr-generate -fcoverage-mapping,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53570642/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com