[0.4.10][CMAKE] Fix 9 MSVC2010SP1 x86 dbg warnings LNK4221 CORE-18104 CORE-14373
authorJoachim Henze <Joachim.Henze@reactos.org>
Thu, 31 Mar 2022 16:28:22 +0000 (18:28 +0200)
committerJoachim Henze <Joachim.Henze@reactos.org>
Thu, 31 Mar 2022 16:28:22 +0000 (18:28 +0200)
commit9aa325fd144afbe32fe7a232ed521b36b8a64ddd
tree5cc74d515a9eab9c3373f870331c28aa8e34a94f
parent3a6f944d1f3d296e8be1cb3d002284e98aa6b8ab
[0.4.10][CMAKE] Fix 9 MSVC2010SP1 x86 dbg warnings LNK4221 CORE-18104 CORE-14373

by always unconditionally enabling "String Pooling" /GF

Pros:
- consistency between the toolchains, as GCC always has this enabled
- shrinks the binary sizes for MSVC dbg builds
- smaller binaries will also make relocations less probable with MSVC dbg and a given set of (often outdated) precalculated base-addresses
- interestingly it also fixes/hides some linker warnings LNK4221

which can be observed with MSVC 2010SP1 (16.0.40219.1) x86 target in dbg configuration, here example from releases/0.4.7:
[819/11751] Linking C static library dll\opengl\mesa\main\mesa_main.lib
precomp.h.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library

[830/11751] Linking C static library dll\opengl\mesa\math\mesa_math.lib
precomp.h.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library

[858/11751] Linking C static library dll\opengl\mesa\swrast\mesa_swrast.lib
precomp.h.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library

[879/11751] Linking C static library dll\opengl\mesa\tnl\mesa_tnl.lib
precomp.h.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library

[897/11751] Linking C static library dll\opengl\mesa\vbo\mesa_vbo.lib
precomp.h.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library

[1602/11751] Linking C static library sdk\lib\3rdparty\adns\adns.lib
internal.h.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library

[4327/11751] Linking C static library sdk\lib\tdilib\tdilib.lib
precomp.h.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library

[11714/11751] Linking C static library win32ss\user\winsrv\consrv.lib
consrv.h.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library

[11726/11751] Linking C static library win32ss\user\winsrv\concfg\concfg.lib
precomp.h.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library

It manages to make all the mentioned 9 LNK4221 disappear without introducing any other warnings into those modules, or into any other module.
Ftr I do not understand why String Pooling hides those LNK4221. But its effectiveness is evident.
But some other LNK4221 in other modules do still remain after it. Their count is not 0 afterwards, just significantly reduced.

Cons:
- String Pooling may slightly increase the build time, but the impact is negligible, even on my 12 year-old PC.
- String Pooling may make lousy code crash, that illegally wants to write into string constants, like we saw it for ROSTESTS298 for example.
  But that is actually not a bad thing. That test was also broken beforehand and crashed even on real Windows.
  We didn't find any similar problems within the 'productive code' yet.

fix is a partial pick of:
0.4.12-dev-354-g 5e673f311854a125c3347ae00c924d347972003c
and its addendum
0.4.12-dev-655-g 237110604b52fa45e10058b074770471081843be [CMAKE] msvc.cmake: Remove 2 now redundant '/GF' (#1239)
sdk/cmake/msvc.cmake