Fix CFG on our static-lib-only DLL projects (#16056)

Control Flow Guard requires both linker and compiler flags.

It turns out that the MSVC build rules determine whether to _link_ with
CFG based on whether it compiled anything with CFG.

It also turns out that when you don't compile anything (such as in our
DLL projects that only consume a static library!), the build rules can't
guess whether to link with CFG.

Whoops.
We need to force it.
This commit is contained in:
Dustin L. Howett 2023-09-29 13:25:01 -05:00 committed by GitHub
parent 4382a17352
commit 1b143e34a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -101,6 +101,13 @@
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
<EnableHybridCRT Condition="'$(EnableHybridCRT)'=='' and '$(ConfigurationSupportsHybridCRT)'=='true'">true</EnableHybridCRT>
<UseCrtSDKReferenceStaticWarning Condition="'$(EnableHybridCRT)'=='true'">false</UseCrtSDKReferenceStaticWarning>
<!--
We must set this to True for projects that do not contain any ClCompile entries.
The Link task guesses whether to enable CFG based on ClCompile->ControlFlowGuard.
Without any ClCompile entries, there's nothing to guess!
This impacts our dll projects that only link a lib.
-->
<LinkControlFlowGuard>true</LinkControlFlowGuard>
</PropertyGroup>
<ItemDefinitionGroup>