当我仅使用链接器选项 /LTCG时,为什么Visual Studio在Linker命令行中显示选项 /PGD

Why does Visual Studio show the option /PGD in the linker command line when I use just the linker option /LTCG?

本文关键字:选项 Studio Visual Linker PGD 显示 命令行 为什么 链接 LTCG      更新时间:2023-10-16

如果仅在Release模式下构建一个项目,该模式仅包含带有int main() {}.cpp文件,则在Configuration Properties > Linker > Command Line中看到选项/PGD:"C:Users*****DocumentsVisual StudioProjectssolution nameReleaseproject name.pgd",就好像链接器应该为配置文件创建数据库 - 对该项目的指导优化。

但显然是不是,因为链接器在发行版构建中使用的/LTCG选项仅为/LTCG,而不是/LTCG:PGINSTRUMENT。为了证实这一点,可以检查上述Release目录中没有任何.pgd文件。

为什么Visual Studio在项目的命令行中有此选项(/PGD)?

P.S。我正在使用VS2017进行此模拟,但我相信在Visual Studio的先前版本中,结果应该相同。

每个Visual Studio项目默认设置了/PGD选项,默认路径为$(OutDir)$(TargetName).pgd。除非您使用/LTCG:PG*选项明确启用PGO,否则此设置无效。