Skip to content

Commit

Permalink
Enable the Hybrid CRT for all C++ projects (#15010)
Browse files Browse the repository at this point in the history
The less we need the C++ runtime, the better.

I measured this as growing our package by a fair amount...
but less than the size of XamlHost and all the forwarders combined.

Reducing our dependency surface makes us easier to deploy and more
reliable.

_as of 1.17 (2022-10)_

| **File**                | **Before** | **After** |        **Delta** |
| ----------------------- | ----------:| ---------:| ----------------:|
| `OpenConsole`           |  1,273,344 | 1,359,360 |   +86,016 (84kb) |
| `TerminalApp`           |  2,037,248 | 2,120,704 |   +83,456 (82kb) |
| `TerminalControl`       |  1,412,608 | 1,502,720 |   +90,112 (88kb) |
| `TerminalSettingsModel` |  1,510,912 | 1,621,504 | +110,592 (108kb) |
| `wt`                    |     97,280 |   122,368 |   +25,088 (25kb) |
| `WindowsTerminal`       |    508,928 |   575,488 |   +66,560 (65kb) |
| **MSIX Overall**        |  6,488,301 | 6,799,017 | +310,716 (303kb) |

(cherry picked from commit b6bb3e0)
Service-Card-Id: 88536379
Service-Version: 1.17
  • Loading branch information
DHowett committed Mar 31, 2023
1 parent a33fdcf commit d8c8e78
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/common.build.post.props
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<AdditionalOptions>%(AdditionalOptions) /defaultlib:ucrtd.lib</AdditionalOptions>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(EnableHybridCRT)'=='true' and '$(Configuration)'=='Release'">
<ItemDefinitionGroup Condition="'$(EnableHybridCRT)'=='true' and ('$(Configuration)'=='Release' or '$(Configuration)'=='AuditMode')">
<ClCompile>
<!-- We use MultiThreaded, rather than MultiThreadedDLL, to avoid DLL dependencies on VCRUNTIME140.dll and MSVCP140.dll. -->
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
Expand Down
14 changes: 14 additions & 0 deletions src/common.build.pre.props
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,26 @@

<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />

<PropertyGroup>
<!--
We don't need to use HybridCRT for Fuzzing, so just skip it entirely.
Fuzzing requires the address sanitizer runtime library plus the fuzzing
harness. They're probably not compatible.
Audit, however, *does* require linking components built in Release mode...
-->
<ConfigurationSupportsHybridCRT Condition="'$(Configuration)'=='Fuzzing'">false</ConfigurationSupportsHybridCRT>
<ConfigurationSupportsHybridCRT Condition="'$(ConfigurationSupportsHybridCRT)'==''">true</ConfigurationSupportsHybridCRT>
</PropertyGroup>

<!-- For ALL build types-->
<PropertyGroup Label="Configuration">
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<LinkIncremental>false</LinkIncremental>
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
<EnableHybridCRT Condition="'$(EnableHybridCRT)'=='' and '$(ConfigurationSupportsHybridCRT)'=='true'">true</EnableHybridCRT>
<UseCrtSDKReferenceStaticWarning Condition="'$(EnableHybridCRT)'=='true'">false</UseCrtSDKReferenceStaticWarning>
</PropertyGroup>

<ItemDefinitionGroup>
Expand Down

0 comments on commit d8c8e78

Please sign in to comment.