Skip to content

windows: msvc: avoid depending on ucrtbased.dll by statically linking to ucrt in debug mode #24207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 19, 2025

Conversation

marler8997
Copy link
Contributor

@marler8997 marler8997 commented Jun 17, 2025

In debug builds, this change updates all cmake targets to statically link to the "Universal C Runtime Library" (ucrt) by default. This adds about 1 to 2 megabytes but also removes th runtime dependency on ucrtbased.dll, which is only available on machines that have installed the Windows SDK (and added the ucrtbased.dll parent directory to the system PATH environment variable).

@alexrp
Copy link
Member

alexrp commented Jun 18, 2025

I would rather we only avoid linking ucrtbased.dll, but still link ucrtbase.dll dynamically. The latter is part of the OS so I don't really see any value in linking it statically.

@marler8997
Copy link
Contributor Author

@alexrp I think that's a reasonable position, I also considered this solution and didn't have a strong opinion that one was better than the other. I'll let you be the "tie breaker" and I'll update the PR with your suggested variation.

@marler8997 marler8997 changed the title windows: msvc: statically link to "Universal C Runtime" by default windows: msvc: avoid depending on ucrtbased.dll by statically linking to ucrt in debug mode Jun 18, 2025
@alexrp alexrp enabled auto-merge (rebase) June 19, 2025 06:40
@alexrp alexrp merged commit f5a327c into ziglang:master Jun 19, 2025
10 checks passed
@marler8997 marler8997 deleted the msvcStaticUcrt branch June 19, 2025 15:31
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.

2 participants