LNK1201 Visual C++ 2010 大型项目无法生成 PDB

我们已经完成了 MSDN WRT 到这个错误(除了 #5 ).不同机器上的三个不同的人遇到了同样的问题.PDB 已创建,但在中间某处失败.

We have gone through the points listed on MSDN WRT to this error ( except for #5 ). Three different people on different machines are getting the same problem. The PDB is created, but fails somewhere in the middle.

详情:

  • 67 个静态库
  • 4.27 GB 的静态库
  • 1048575 字节 - 链接器失败时 PDB 的大小
  • PDB 的最后几兆字节为空(零)
  • 发布构建成功 &生成一个 PDB(我们打开它,exe 中没有调试信息)
  • 发布版本 PDB 不到 1 GB.

我们已禁用病毒扫描程序.用 procmon.exe 观察,当链接器失败时,没有发现与 PDB 的可疑交互.

We have disabled virus scanners. Watched with procmon.exe and saw no suspicions interactions with the PDB when the linker failed.

相关问题建议对 PDB 的限制约为 1 GB- 任何人/方式来确认?

Related question suggests ~1 GB limit on PDB's - anyone/way to confirm that?

更新 &解决方案:

@Barry 和 Chromium 团队提出了解决方案.这里是实现该解决方案的 Chromium 构建系统的补丁.

@Barry and the chromium team have come up with the solution. Here is the patch to the Chromium build system that implements the resolution.

详情
PDB 在内部使用虚拟文件系统:MSF.当链接器创建 PDB 文件时,它默认为(显然不可配置)2 kB 页面大小.显然&幸运的是,当编译器创建它的 PDB 时,它会将页面大小默认为 4 kB.这个编译器 PDB 可以被提升并用作链接器 PDB 的基础.

Details
The PDB uses a virtual filesystem internally: MSF. When the linker creates the PDB file it defaults to an ( apparently non-configurable ) 2 kB page size. Apparently & fortunately when the compiler creates its PDB it defaults the page size to 4 kB. This compiler PDB can be hoisted and used as a base for the linker PDB.

更好的解决方案作为链接您的 exe 或 dll 的项目的预链接事件,我们可以提升编译器以生成我们所需的初始 PDB:

Better solution As a Pre-Link Event on the project that is linking your exe or dll we can hoist the compiler to generate our required initial PDB:

cl -c "dummy_empty.cpp" /Zi /Fd"$(TargetDir)$(TargetName).pdb" 

原始解决方案
使用空的 cpp 文件创建 C++ 静态库项目,配置Porgram 数据库文件名"以输出默认值以外的内容.使用一些项目构建事件(我使用预链接事件")将先前创建的 PDB 复制到链接器期望的任何位置(请参阅 Linker->Generate Program Database File )以创建其 PDB.幸运的是,链接器将采用 PDB 中的复制并使用其 4 kB 页面大小.这将花费一些时间和一些空间,最多允许 2GB PDB.

Original Solution
Make a C++ static library project with an empty cpp file, configure the 'Porgram Database File Name' to output something other than the default. Use some project build events ( I used 'Pre-Link Event') to copy in the previously created PDB into wherever you linker is expecting ( see Linker->Generate Program Database File ) to create its PDB. Fortunately the linker will adopt the copied in PDB and use its 4 kB page size. This will buy some time, and some space allowing up to a 2GB PDB.

推荐答案

pdb 大小确实有 1GB 的最大限制.有一些技巧可以将其扩展到 2GB(更多信息可以在 这里).基本上你必须自己生成初始 pdb 文件,而不是编译器.

There is indeed a max limit of 1GB for the pdb size. There is some trick to extend this to 2GB (more info about that can be found Here). Basically you have to generate the initial pdb file yourself instead of the compiler.

您可以做的其他事情是对您的模板代码进行一些主动提升,因为这也可能会影响您的 pdb 大小.

Other things you could do is do some active hoisting on your template code as this might effect your pdb sizes also.

相关文章