[PATCH] D155233: [CMake] Switch the CMP0091 policy (MSVC_RUNTIME_LIBRARY) to the new behaviour

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 13 13:59:41 PDT 2023


mstorsjo created this revision.
mstorsjo added reviewers: hans, thakis, rnk, glandium, dschuff, sunho, phosek.
Herald added subscribers: ekilmer, Enna1, hiraditya.
Herald added a project: All.
mstorsjo requested review of this revision.
Herald added projects: Sanitizers, LLVM.
Herald added a subscriber: Sanitizers.

With the new behaviour, the /MD or similar options aren't added to
e.g. CMAKE_CXX_FLAGS_RELEASE, but are added separately by CMake.
They can be changed by the cmake variable
CMAKE_MSVC_RUNTIME_LIBRARY or with the target property
MSVC_RUNTIME_LIBRARY.

LLVM has had its own custom CMake flags, e.g. LLVM_USE_CRT_RELEASE,
which affects which CRT is used for release mode builds. Deprecate
these and direct users to use CMAKE_MSVC_RUNTIME_LIBRARY directly
instead (and do a best effort attempt at setting CMAKE_MSVC_RUNTIME_LIBRARY
based on the existing LLVM_USE_CRT_ flags). This only handles the
simple cases, it doesn't handle multi-config generators with
different LLVM_USE_CRT_* variables for different configs though,
but that's probably fine - we should move over to the new upstream
CMake mechanism anyway, and push users towards that.

Change code in compiler-rt, that previously tried to override the
CRT choice to /MT, to set CMAKE_MSVC_RUNTIME_LIBRARY instead of
meddling in the old variables.

This resolves the policy issue in
https://github.com/llvm/llvm-project/issues/63286, and should
handle the issues that were observed originally when the
minimum CMake version was bumped, in
https://github.com/llvm/llvm-project/issues/62719 and
https://github.com/llvm/llvm-project/issues/62739.

I'm tagging people who were involved in the previous reported
issues, @hans, @glandium, @dschuff - I'd appreciate if you could
test this in your build configs (I've tried to test the cases
mentioned).

Also @sunho, this touches the ORC runtime library on Windows,
can you verify that it still works as intended in your setups?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D155233

Files:
  cmake/Modules/CMakePolicy.cmake
  compiler-rt/CMakeLists.txt
  compiler-rt/lib/orc/CMakeLists.txt
  llvm/CMakeLists.txt
  llvm/cmake/modules/ChooseMSVCCRT.cmake
  llvm/docs/CMake.rst
  llvm/lib/Support/CMakeLists.txt

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155233.540179.patch
Type: text/x-patch
Size: 8065 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230713/2555b619/attachment.bin>


More information about the llvm-commits mailing list