Skip to content

Replace MSVCR120.dll fallback with the Universal CRT on Windows.#23345

Merged
LightBender merged 7 commits into
dlang:masterfrom
LightBender:win-ucrt
Jul 3, 2026
Merged

Replace MSVCR120.dll fallback with the Universal CRT on Windows.#23345
LightBender merged 7 commits into
dlang:masterfrom
LightBender:win-ucrt

Conversation

@LightBender

@LightBender LightBender commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

This PR deprecates the MSVCR120.dll fallback when DMD cannot locate the Windows SDK or Visual Studio installations and requires the use the Universal CRT. It also updated some of the fallback detection paths to include newer versions of Visual Studio and deprecates detection of versions of VS that do not support UCRT.

A more detailed NG post about the reasons for this PR is located here: https://forum.dlang.org/thread/wtfjroxawypsyuhmqotl@forum.dlang.org

This PR was generated with LLM's.
Model Name: Opus 4.8
Prompt:
We are looking to deprecate all non-UCRT C runtimes, including the default/fallback MSVCR120 runtime that does not support "%zd" and the MinGW support as MingGW is deprecating MINGW64 support in favor if UCRT (here: https://www.msys2.org/news/#2026-03-15-deprecating-the-mingw64-environment). Next we want to deprecate support for all versions of Visual Studio prior to 2015 as those versions do not support the UCRT. The desired goal of this plan is that UCRT is the only CRT library used by DMD on Windows. We want to keep the "-mscrtlib" override in case the user wishes to provide a different CRT. We also need to make sure the detection logic for library paths and linker paths is up to date for the most recent versions of the Windows SDK and UCRT, as well as the detection logic for the linker.

@LightBender LightBender requested a review from WalterBright July 1, 2026 01:27
Comment thread compiler/src/dmd/main.d
Comment thread compiler/src/dmd/main.d Outdated
…vcrt120 is selected automatically, allowing the user to still explicitly override the with that library.
Comment thread compiler/src/dmd/vsoptions.d Outdated
@rainers

rainers commented Jul 1, 2026

Copy link
Copy Markdown
Member

We don't have to deprecate the MinGW stuff, we could just switch from msvcrt120.lib to ucrtbase.lib that is already in the mingw library folder. The only complication is that it needs an additional library vcruntime140.lib to be passed on the linker command line.

The additions to the VS detection look good but for the support of future platform versions as mentioned.

@LightBender

Copy link
Copy Markdown
Contributor Author

@rainers That is a really good idea. I've updated the pull to implement this request.

Comment thread compiler/src/dmd/vsoptions.d Outdated
Comment thread compiler/src/dmd/vsoptions.d Outdated
@LightBender

Copy link
Copy Markdown
Contributor Author

@rainers That made things quite a bit simpler. If everything looks good to you, please go ahead and merge it.
@WalterBright any objections?

@LightBender LightBender changed the title Deprecate MSVCR120.dll fallback and replace with the Universal CRT. Replace MSVCR120.dll fallback with the Universal CRT on Windows. Jul 2, 2026

@rainers rainers left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, looks much cleaner. Just a few non-critical nitpicks...

Comment thread compiler/src/dmd/vsoptions.d Outdated
return na < nb ? -1 : 1;
if (!hasA && !hasB)
return 0;
if (*a) ++a; // skip separator (typically '.')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same here.
Not sure if it is worth skipping/comparing multiple non-numeric characters.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think this is acceptable because non-numerics are not typically part of any MSFT version specifier. And version postfix data as-in SemVer is not comparable using </> anyways so it can never be deterministic in finding the "latest" version. Likewise, the prefix v in SemVer would always be skipped as well. So IMO, skipping non-numerics is reasonable here.

Comment thread compiler/src/dmd/vsoptions.d Outdated
@LightBender LightBender merged commit c18285a into dlang:master Jul 3, 2026
41 checks passed
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