[Proposal] Switch to the Universal CRT on Windows.

Adam Wilson flyboynw at gmail.com
Wed Jul 1 01:24:05 UTC 2026


I recently got hit by a rather esoteric bug that looked like a 
real bug, but was actually not a bug, but also kind of a bug. 
Specifically, on Windows the printf `%zd` format would fail with 
a Segfault. The simple fix was to delete `%zd` and use `%d` with 
a cast to a fixed size int type. But it was the wrong fix.

The actual root cause is that I was running `build.d` and 
`build.d` decided to use the 13 year old MSVCR120.dll, which does 
not support `%zd` printf formats. Despite the fact that I have 
the most modern C++ build tools and SDK's that you can get 
installed on my machine. (I work on Windows for a living, to my 
enduring shame)

The result is that we ship a fallback CRT that doesn't even 
support building the compiler itself. Egg, meet face.

The solution is pretty straight-forward. Use the Universal CRT 
for everything on Windows.

And it turns out that there is another reason to abandon 
everything but UCRT. MINGW64 is now deprecated in favor of UCRT. 
(See blog post 
[here](https://www.msys2.org/news/#2026-03-15-deprecating-the-mingw64-environment)) Therefore, we will be required to make this change at some point in the near future because MinGW is forcing us too. Moving to UCRT will also allow us to deprecate and eventually remove the giant bag of hacks that is our MINGW64 support.

Anybody not using Windows 10 or greater will need to install the 
UCRT as a minimum from 
[here](https://support.microsoft.com/en-us/topic/update-for-universal-c-runtime-in-windows-322bf30f-4735-bb94-3949-49f5c49f4732).
However, I think this is acceptable because our policy is that we 
only officially support the versions of Windows that Microsoft 
does for ESU, which means Win10 22H2 (until October 2028) or 
Win11. And since UCRT has been back-ported to older systems by 
Microsoft itself, it's an easy problem to handle for people 
deploying D-code.

Note for Walter: You will need at least the 2015 Build Tools on 
Win7, which you can get 
[here](https://www.microsoft.com/en-us/download/details.aspx?id=48159). Or if you want something a little newer, the VS2017 build tools are [here](https://aka.ms/vs/15/release/vs_buildtools.exe).

I have posted a PR 
[here](https://github.com/dlang/dmd/pull/23345). This PR 
deprecates (but still allows) the msvcr120 fallback path as well 
as updating various detection routines to include the latest 
versions of VS and deprecate anything prior to VS2015. If no 
WinSDK or VS installation is detected then the compiler throws an 
error.


More information about the Digitalmars-d mailing list