How do I merge multiple PDB files?

bltxd picture bltxd · Feb 9, 2009 · Viewed 10.2k times · Source

We are currently using a single command line tool to build our product on both Windows and Linux.

Si far its works nicely, allowing us to build out of source and with finer dependencies than what any of our previous build system allowed. This buys us great incremental and parallel build capabilities.

To describe shortly the build process, we get the usual:

.cpp -- cl.exe --> .obj and .pdb
multiple .obj and .pdb -- cl.exe --> single .dll .lib .pdb
multiple .obj and .pdb -- cl.exe --> single .exe .pdb

The msvc C/C++ compiler supports it adequately.

Recently the need to build a few static libraries emerged. From what we gathered, the process to build a static library is:

multiple .cpp -- cl.exe --> multiple .obj and a single .pdb
multiple .obj -- lib.exe --> a single .lib

The single .pdb means that cl.exe should only be executed once for all the .cpp sources. This single execution means that we can't parallelize the build for this static library. This is really unfortunate.

We investigated a bit further and according to the documentation (and the available command line options):

  • cl.exe does not know how to build static libraries
  • lib.exe does not know how to build .pdb files

Does anybody know a way to merge multiple PDB files ? Are we doomed to have slow builds for static libraries ? How do tools like Incredibuild work around this issue ?

Answer

Preet Sangha picture Preet Sangha · Mar 19, 2009

I've not done C++ for a long time but from this article, it appears that this is a performance trick to stop the recreation of symbols for common headers.

You could try /Z7 to embed info in each obj, and not create a PDB and then link and recreate it with a rebase as in this article.