Add hybrid CRT link for Windows binaries#40890
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the top-level CMake configuration to adopt the “hybrid CRT” linking model for Windows binaries: keep /MT (static C++ runtime/STL) while forcing the Universal CRT to be dynamically linked (ucrt.dll) via linker default-lib overrides.
Changes:
- Adds linker flags to suppress
libucrt(.lib|d.lib)and explicitly link againstucrt(.lib|d.lib)in Release/Debug builds. - Documents the hybrid CRT intent and links to the reference guidance.
OneBlue
left a comment
There was a problem hiding this comment.
I think this is a great change, and we should definitely merge it.
Agreed that we should wait after the initial release though. One thing that we should validate before merging this is whether this causes us any issues on WS 2022 (specifically on the ServerCore SKU), since we've had runtime dependencies issues in this SKU in the past.
If this runs without issues on WS 2022 ServerCore, I think we should merge it (after the 2.9 release).
Blocking for now, but will unblock after 2.9 is out.
|
There is certainly a reduction in size when compared to another build from the same time, but it isn't as much as I would have hoped for. |
Summary of the Pull Request
Configures hybrid static linkage for Windows binaries in the build. See https://aka.ms/hybridcrt for details on this model.
PR Checklist
Detailed Description of the Pull Request / Additional comments
The Windows binaries are all already statically linking the runtime. Switching to the hybrid model will cut non-trivial size from every binary, without adding any new dependency requirements.
I also understand if we want to wait on taking this until after a significant release so it may have more time to stabilize.
Validation Steps Performed
Built debug locally, ran an arbitrary test.