-fprofile-arcs 链接器选项是什么意思?

Kam*_*Kam 6 linux linker gcc

我想在我的应用程序中进行代码覆盖,因此premake.lua我添加了以下内容:

if options["coverage"] then
    tinsert(package.buildoptions, {"-fprofile-arcs", "-ftest-coverage"})
    tinsert(package.links, "gcov") 
end
Run Code Online (Sandbox Code Playgroud)

然后我运行了以下命令:

premake --coverage --target gnu ; make
Run Code Online (Sandbox Code Playgroud)

直到我添加以下内容后才起作用:

 if options["coverage"] then
    tinsert(package.buildoptions, {"-fprofile-arcs", "-ftest-coverage"})
    tinsert(package.linkoptions, {"-fprofile-arcs"})
    tinsert(package.links, "gcov")
 end
Run Code Online (Sandbox Code Playgroud)

这是互联网上提出的解决方案。我的问题是我在这个-fprofile-arcs链接器标志上找到了 0 个文档...它有什么作用?它记录在哪里?

chi*_*ill 5

该选项不会提供给链接器。它由编译器驱动程序(gcc、g++)解释。

编译时,该选项只是传递给编译器(cc1、cc1plus)。

链接时,选项的作用是编译器驱动程序仅-lgcov在链接器命令行上包含 。