8

Even though I know I will probably get bashed for asking this question I'll still go ahead and ask it since it literally drives me nuts. I'm hoping maybe one of you has some insight on the matter.

Compiling MS's WIN32 default ('non-empty' setting) project on VS2013 yields a binary size~16kb. Compiling the same project on VS2015 Update3 yields a binary size~105kb (more than 6x as large!).

I double and triple checked the final command line parameters passed to cl.exe and link.exe and they appear identical (project settings). Even changes in the project settings - favor size over speed - don't help (binary still 105kb). What the heck is going here ? I even installed VS2015 on a second computer in order to rule out a 'defective' installation - same results (105kb). Reaching out for help since I'm done at this point.

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
PIp3dr3am
  • 91
  • 3
  • I noticed when running `DUMPBIN /HEADERS` on a binary compiled in VS2015 there is a new PE section called `.gfids` that wasn't in VS2013 or previous versions. Could this be it? – Govind Parmar Dec 29 '16 at 20:47
  • @WeatherVane: Even if that were the case, it'd be in both binaries, since the OP was using identical compiler and linker switches. That said, by default, debug information is never compiled into executable images. – IInspectable Dec 29 '16 at 20:51
  • I just compiled "Hello World!" program with MSVC 2009 (48k) and MSVC 2015 (98k), both from the command line, both with similar MAKEFILE, both on Win 7, both are 32-bit executables. Hmmm. – Weather Vane Dec 29 '16 at 20:58
  • you use static linked `CRT` in both case ? only `CRT` statically linked code can give this huge size. not `.gfids` – RbMm Dec 29 '16 at 21:05
  • @RbMm static, yes. I never use dynamic linking since a) requires the dynamic libraries to be present on the client's machine, and b) if they are and they get updated, then the testing and verification process is broken. Code size does not matter much to me, since the archived source file history greatly exceeds the executable release build archive. – Weather Vane Dec 29 '16 at 21:14
  • @WeatherVane - so think this is new version of static CRT libs grow self size – RbMm Dec 29 '16 at 21:15

1 Answers1

9

I don't have VS 2013 installed at the moment, but I just did a quick test comparing VS 2010 and VS 2015. In each version, I created a "Win32 Project" (Windows Application, Non-Empty, No ATL, No MFC). The resulting file sizes for the 32-bit Release build are:

VS 2010: 57,344
VS 2015: 104,448

Running dumpbin /headers on both executables shows slight differences in the code size, but the main difference seems to be the resources:

VS 2010 .rsrc size: 0xC200 (about 49K)
VS 2015 .rsrc size: 0x17200 (about 92K)

Upon closer inspection, the icon resources in the VS2015 version have more alternatives (different sizes, different bit depths). So that appears to be the bulk of the size difference in my test case.

EDIT: Comparison of executable size broken down by PE section:

+---------+-----------------+-----------------+-------+
| Section |     VS 2010     |     VS 2015     | Change|
|         | (hex)  | (dec)  | (hex)  | (dec)  | (dec) |
+---------+--------+--------+--------+--------+-------+
| .text   | 0xC00  | 3072   | 0x1000 | 4096   |  1024 |
| .rdata  | 0x800  | 2048   | 0xC00  | 3072   |  1024 |
| .data   | 0x200  | 512    | 0x200  | 512    |     0 |
| .rsrc   | 0xC200 | 49664  | 0x17200| 94720  | 45056 |
| .reloc  | 0x400  | 1024   | 0x200  | 512    |  -512 |
| .gfids  | n/a    | n/a    | 0x200  | 512    |   512 |
+---------+--------+--------+--------+--------+-------+
                                        Total | 47104 |

So, when you exclude .rsrc, the total difference is 2K.

cbranch
  • 4,709
  • 2
  • 27
  • 25
  • Your numbers show, that the VS 2010 resources are almost twice the size of the VS 2015 resources. Is this a typo? – IInspectable Dec 29 '16 at 21:17
  • This bears out my test results mentioned in comment under the question. – Weather Vane Dec 29 '16 at 21:18
  • @IInspectable: Yes, typo -- I had it backwards. Fixed. – cbranch Dec 29 '16 at 21:18
  • 1
    I'll confirm similar numbers between VS2013 and VS2015. `VS 2013 0x2000 .rsrc` as compared with `VS 2015 0x18000 .rsrc`. My binaries are 15kB and 105kB between 2013 and 2015, so the 90kB all due to the increase in `.rsrc` size. – Chris O Dec 30 '16 at 02:09
  • Still, though, an increase of 43 kB in resource section size does not fully explain a growth of 89 kB in executable image size. – IInspectable Dec 30 '16 at 10:55
  • Thank you all so much for helping to solve the puzzle for me! Thanx cbranch for explaining in great detail - the resources it was indeed. I should have looked into the project directory itself - it contains two .ico files each one 46kb in size, so 92 kb in total. 92kb for two .ico files ? Insane.... – PIp3dr3am Dec 30 '16 at 19:19