Skip to content

[CMake] Fix MSVC runtime selection and add official Release cache - #8804

Draft
Alex Sepkowski (alsepkow) wants to merge 4 commits into
microsoft:mainfrom
alsepkow:user/alsepkow/fix-msvc-runtime-selection
Draft

[CMake] Fix MSVC runtime selection and add official Release cache#8804
Alex Sepkowski (alsepkow) wants to merge 4 commits into
microsoft:mainfrom
alsepkow:user/alsepkow/fix-msvc-runtime-selection

Conversation

@alsepkow

@alsepkow Alex Sepkowski (alsepkow) commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Make the existing LLVM_USE_CRT_<CONFIG> settings control the MSBuild runtime-library property generated by modern CMake, and add the initial cache composition point for official Release policy.

CMake's CMP0091 runtime-library abstraction emits <RuntimeLibrary> in Visual Studio projects. The current ChooseMSVCCRT.cmake implementation instead edits CMAKE_<LANG>_FLAGS_<CONFIG>, which can leave an explicit /MT competing with CMake's generated /MD selection. Translate the existing MD, MDd, MT, and MTd values to CMAKE_MSVC_RUNTIME_LIBRARY so the requested runtime is authoritative. Configurations without an explicit override retain CMake's normal DLL-runtime defaults.

cmake/caches/OfficialRelease.cmake currently composes PredefinedParams.cmake and selects LLVM_USE_CRT_RELEASE=MT. This is intentionally an initial, narrow cache rather than a claim that all DXCBuild release policy has moved upstream. It does not configure versioning, signing, symbol packaging, artifact publication, or size-first optimization policy. Additional generally useful release settings can move upstream independently before the cache is documented as reproducing the complete compiler configuration used by DXCBuild.

Testing:

  • Configured an x64 build with Visual Studio 18 2026 using only OfficialRelease.cmake for CRT selection.
  • Verified all 85 generated native target projects contain <RuntimeLibrary>MultiThreaded</RuntimeLibrary> for Release and MultiThreadedDebugDLL for Debug. The only projects without runtime properties were CMake's two configure-time compiler-identification probes.
  • Built the Release llvm-tblgen target successfully through the official cache.
  • Verified dumpbin /dependents reports only KERNEL32.dll, with no VCRUNTIME, MSVCP, UCRT, or API-set CRT imports.

No release note is needed because this changes build-system behavior rather than compiler-visible behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 0f4d0e10-e926-4bce-b36b-0abebc08f6dc
Compose the standard DXC cache with static Release CRT selection and document the reproducible Visual Studio configure and build commands.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@alsepkow Alex Sepkowski (alsepkow) changed the title [CMake] Fix MSVC runtime library selection [CMake] Fix MSVC runtime selection and add official Release cache Aug 20, 2026
Keep the initial cache focused on CRT policy until the remaining DXCBuild release settings move upstream and build equivalence is demonstrated.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Name the MSVC runtime switches and the legacy CMake flag variables inspected for compatibility.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

1 participant