4

I am wondering why under VS 2013 the /Zi compiler option almost doubles the size of the build static library.

As far as I understand the /Zi option, all generated debugging information is stored in a .pdb file and only a link to that file is added for each .obj file.

It seems that only for .exe and .dlls the file size keeps the same regardless of whether the option is /Zi or None.

I can test this only with VS 2013, so I have no idea if this happens also with other version of VS.

1 Answers1

0

This mainly comes from the increase of the .debug$S section. The reason is that when PDB is used, not everything about debug is put into the pdb, the debug symbols are still kept in the .debug$S section in theh object/lib file. What is put into pdb at least contains type information, this is the reason that .debug$T become very small when /Zi or /ZI is used, i.e. it only contains pointer to pdb file in those cases.

You can use

dumpbin.exe your_lib.lib

to show the result.

For a large lib the size can increase from 4MB to 20MB.

For a very simple lib:

no debug:

       4 .bss
      60 .chks64
     138 .debug$S
      D2 .drectve
      18 .pdata
       8 .rtc$IMZ
       8 .rtc$TMZ
      2C .text$mn
      10 .xdata

/Zi:

       4 .bss
      98 .chks64
     848 .debug$S
      E0 .debug$T
     113 .drectve
       4 .msvcjmc
      18 .pdata
       8 .rtc$IMZ
       8 .rtc$TMZ
      76 .text$mn
      10 .xdata

/ZI:

       4 .bss
      C0 .chks64
    1454 .debug$S
      E0 .debug$T
     135 .drectve
       4 .msvcjmc
      18 .pdata
       8 .rtc$IMZ
       8 .rtc$TMZ
      89 .text$mn
      20 .xdata

/Z7: Debug info embed into .debug$P section now, and the .debug$S also shrink a little.

       4 .bss
      98 .chks64
    1210 .debug$P
     848 .debug$S
     78C .debug$T
     113 .drectve
       4 .msvcjmc
      18 .pdata
       8 .rtc$IMZ
       8 .rtc$TMZ
      76 .text$mn
      10 .xdata
jw_
  • 1,663
  • 18
  • 32