Skip to content

Add hybrid CRT link for Windows binaries#40890

Open
JohnMcPMS wants to merge 2 commits into
microsoft:masterfrom
JohnMcPMS:hybrid-static
Open

Add hybrid CRT link for Windows binaries#40890
JohnMcPMS wants to merge 2 commits into
microsoft:masterfrom
JohnMcPMS:hybrid-static

Conversation

@JohnMcPMS

Copy link
Copy Markdown
Member

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

  • Closes: Link to issue #xxx
  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

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.

@JohnMcPMS JohnMcPMS requested a review from a team as a code owner June 24, 2026 18:40
Copilot AI review requested due to automatic review settings June 24, 2026 18:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 against ucrt(.lib|d.lib) in Release/Debug builds.
  • Documents the hybrid CRT intent and links to the reference guidance.

Comment thread CMakeLists.txt Outdated

@OneBlue OneBlue left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@JohnMcPMS

Copy link
Copy Markdown
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants