LNK1201 Visual C++ 2010 Large project failing to g

2019-02-02 15:52发布

问题:

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.

Details:

  • 67 static libraries
  • 4.27 GB of static libraries
  • 1048575 bytes - size of PDB when linker fails
  • The last couple of megabytes of the PDB are null ( zero's )
  • Release build succeeds & produces a PDB ( we have it turn on, with no debugging info in the exe )
  • Release build PDB is just under 1 GB.

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

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

UPDATE & SOLUTION:

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

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.

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" 

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.

回答1:

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.

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



回答2:

I put together a test program with 1000 cpp files, each cpp with one function, that instantiated 500 unique template types.

Link.exe failed when the PDB file reached: 1048575 KB.

Appears to be some sort of hard limit at 1 GB in the PDB format or in LINK.exe.



回答3:

Have you tried to reduce the number of parallel builds. A setting sometwhere in the IDE. On VC9 we had a similar problem and our only solution was to reduce the number of local builds. Could it be a memory problem as well? Are you using VC 10 SP1?