【问题标题】:Can clang-cl flags -fprofile-instr-generate -fcoverage-mapping be used in windowsclang-cl flags -fprofile-instr-generate -fcoverage-mapping 可以在windows中使用吗
【发布时间】:2018-12-01 12:13:23
【问题描述】:

我在 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 构建工具在 windows 中使用 clang 进行编译。

PS2:根据我的阅读,我们还需要将“-fprofile-instr-generate”传递给链接器......但不知道应该如何完成......

谢谢

【问题讨论】:

    标签: c++ windows clang llvm-clang visual-studio-2017-build-tools


    【解决方案1】:

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

    【讨论】:

    猜你喜欢
    • 2015-03-25
    • 2014-08-27
    • 1970-01-01
    • 1970-01-01
    • 2019-03-16
    • 2022-06-11
    • 1970-01-01
    • 2016-11-17
    • 1970-01-01
    相关资源
    最近更新 更多