[clang] 618e5d2 - [CMake] Fully delete the deprecated LLVM_USE_CRT* (#66850)

via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 21 03:25:10 PDT 2023


Author: Zhang
Date: 2023-09-21T13:25:06+03:00
New Revision: 618e5d2c2d8e0c288c37b883ece553ca4f994c2e

URL: https://github.com/llvm/llvm-project/commit/618e5d2c2d8e0c288c37b883ece553ca4f994c2e
DIFF: https://github.com/llvm/llvm-project/commit/618e5d2c2d8e0c288c37b883ece553ca4f994c2e.diff

LOG: [CMake] Fully delete the deprecated LLVM_USE_CRT* (#66850)

This has been deprecated in favor of CMake's CMAKE_MSVC_RUNTIME_LIBRARY
in c6bd873403a8ac6538a3fe3b3c2fe39c16b146a6 .
Current release branch still contains it in deprecated status so no
existing end-users will be affected.

Added: 
    

Modified: 
    clang/cmake/caches/CrossWinToARMLinux.cmake
    clang/cmake/caches/Fuchsia-stage2.cmake
    clang/cmake/caches/Fuchsia.cmake
    llvm/cmake/modules/HandleLLVMOptions.cmake
    llvm/cmake/modules/LLVMConfig.cmake.in
    llvm/docs/CMake.rst

Removed: 
    llvm/cmake/modules/ChooseMSVCCRT.cmake


################################################################################
diff  --git a/clang/cmake/caches/CrossWinToARMLinux.cmake b/clang/cmake/caches/CrossWinToARMLinux.cmake
index e6f5650eac4668f..bbb4b9e71be2d3d 100644
--- a/clang/cmake/caches/CrossWinToARMLinux.cmake
+++ b/clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -95,7 +95,6 @@ set(CLANG_DEFAULT_LINKER                    "lld" CACHE STRING "")
 
 if(WIN32)
   set(CMAKE_MSVC_RUNTIME_LIBRARY            "MultiThreaded" CACHE STRING "")
-  set(LLVM_USE_CRT_RELEASE                  "MT" CACHE STRING "")
 endif()
 
 # Set up RPATH for the target runtime/builtin libraries.

diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake b/clang/cmake/caches/Fuchsia-stage2.cmake
index bc4d9f1462b1814..803d41a2c87179a 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -30,7 +30,6 @@ set(LLDB_ENABLE_CURSES OFF CACHE BOOL "")
 set(LLDB_ENABLE_LIBEDIT OFF CACHE BOOL "")
 
 if(WIN32)
-  set(LLVM_USE_CRT_RELEASE "MT" CACHE STRING "")
   set(FUCHSIA_DISABLE_DRIVER_BUILD ON)
 endif()
 

diff  --git a/clang/cmake/caches/Fuchsia.cmake b/clang/cmake/caches/Fuchsia.cmake
index c599f141f9e5b1b..9c68be0bfe54b69 100644
--- a/clang/cmake/caches/Fuchsia.cmake
+++ b/clang/cmake/caches/Fuchsia.cmake
@@ -70,10 +70,6 @@ foreach(variable ${_FUCHSIA_BOOTSTRAP_PASSTHROUGH})
   endif()
 endforeach()
 
-if(WIN32)
-  set(LLVM_USE_CRT_RELEASE "MT" CACHE STRING "")
-endif()
-
 set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
 set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
 set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")

diff  --git a/llvm/cmake/modules/ChooseMSVCCRT.cmake b/llvm/cmake/modules/ChooseMSVCCRT.cmake
deleted file mode 100644
index 6d52ac97bac2092..000000000000000
--- a/llvm/cmake/modules/ChooseMSVCCRT.cmake
+++ /dev/null
@@ -1,58 +0,0 @@
-# The macro choose_msvc_crt() takes a list of possible
-# C runtimes to choose from, in the form of compiler flags,
-# to present to the user. (MTd for /MTd, etc)
-#
-# The macro is invoked at the end of the file.
-#
-# This mechanism is deprecated, but kept for transitioning users.
-#
-# This reads the LLVM_USE_CRT_<CONFIG> options and sets
-# CMAKE_MSVC_RUNTIME_LIBRARY accordingly. The previous mechanism allowed
-# setting 
diff erent choices for 
diff erent build configurations (for
-# multi-config generators), but translating multiple 
diff ering choices to
-# the corresponding CMAKE_MSVC_RUNTIME_LIBRARY generator expression isn't
-# supported by this transitional helper.
-
-macro(choose_msvc_crt MSVC_CRT)
-  if(LLVM_USE_CRT)
-    message(FATAL_ERROR
-      "LLVM_USE_CRT is deprecated. Use the CMAKE_BUILD_TYPE-specific
-variables (LLVM_USE_CRT_DEBUG, etc) instead.")
-  endif()
-
-  foreach(build_type ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE})
-    string(TOUPPER "${build_type}" build)
-    if (NOT "${LLVM_USE_CRT_${build}}" STREQUAL "")
-      if (NOT ${LLVM_USE_CRT_${build}} IN_LIST ${MSVC_CRT})
-        message(FATAL_ERROR
-          "Invalid value for LLVM_USE_CRT_${build}: ${LLVM_USE_CRT_${build}}. Valid options are one of: ${${MSVC_CRT}}")
-      endif()
-      set(library "MultiThreaded")
-      if ("${LLVM_USE_CRT_${build}}" MATCHES "d$")
-        set(library "${library}Debug")
-      endif()
-      if ("${LLVM_USE_CRT_${build}}" MATCHES "^MD")
-        set(library "${library}DLL")
-      endif()
-      if(${runtime_library_set})
-        message(WARNING "Conflicting LLVM_USE_CRT_* options")
-      else()
-        message(WARNING "The LLVM_USE_CRT_* options are deprecated, use the CMake provided CMAKE_MSVC_RUNTIME_LIBRARY setting instead")
-      endif()
-      set(CMAKE_MSVC_RUNTIME_LIBRARY "${library}" CACHE STRING "" FORCE)
-      message(STATUS "Using VC++ CRT: ${CMAKE_MSVC_RUNTIME_LIBRARY}")
-      set(runtime_library_set 1)
-    endif()
-  endforeach(build_type)
-endmacro(choose_msvc_crt MSVC_CRT)
-
-
-# List of valid CRTs for MSVC
-set(MSVC_CRT
-  MD
-  MDd
-  MT
-  MTd)
-
-choose_msvc_crt(MSVC_CRT)
-

diff  --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 4e87c6d1c3eb868..f72c41aaffb5061 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -470,7 +470,6 @@ endif()
 option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON)
 
 if( MSVC )
-  include(ChooseMSVCCRT)
 
   # Add definitions that make MSVC much less annoying.
   add_compile_definitions(
@@ -951,7 +950,7 @@ if(LLVM_USE_SANITIZER)
       endif()
       # Prepare ASAN runtime if needed
       if (LLVM_USE_SANITIZER MATCHES ".*Address.*")
-        if (${LLVM_USE_CRT_${uppercase_CMAKE_BUILD_TYPE}} MATCHES "^(MT|MTd)$")
+        if (${CMAKE_MSVC_RUNTIME_LIBRARY} MATCHES "^(MultiThreaded|MultiThreadedDebug)$")
           append("/wholearchive:clang_rt.asan-${arch}.lib /wholearchive:clang_rt.asan_cxx-${arch}.lib"
             CMAKE_EXE_LINKER_FLAGS)
           append("/wholearchive:clang_rt.asan_dll_thunk-${arch}.lib"

diff  --git a/llvm/cmake/modules/LLVMConfig.cmake.in b/llvm/cmake/modules/LLVMConfig.cmake.in
index 42dfd607f7e651a..5465e981f235545 100644
--- a/llvm/cmake/modules/LLVMConfig.cmake.in
+++ b/llvm/cmake/modules/LLVMConfig.cmake.in
@@ -14,10 +14,7 @@ set(LLVM_PACKAGE_BUGREPORT @PACKAGE_BUGREPORT@)
 
 set(LLVM_BUILD_TYPE @CMAKE_BUILD_TYPE@)
 
-set(LLVM_USE_CRT_DEBUG @LLVM_USE_CRT_DEBUG@)
-set(LLVM_USE_CRT_MINSIZEREL @LLVM_USE_CRT_MINSIZEREL@)
-set(LLVM_USE_CRT_RELEASE @LLVM_USE_CRT_RELEASE@)
-set(LLVM_USE_CRT_RELWITHDEBINFO @LLVM_USE_CRT_RELWITHDEBINFO@)
+set(CMAKE_MSVC_RUNTIME_LIBRARY @CMAKE_MSVC_RUNTIME_LIBRARY@)
 
 set(LLVM_USE_SPLIT_DWARF @LLVM_USE_SPLIT_DWARF@)
 

diff  --git a/llvm/docs/CMake.rst b/llvm/docs/CMake.rst
index 67f740447ed7bfb..4d894212fb11d47 100644
--- a/llvm/docs/CMake.rst
+++ b/llvm/docs/CMake.rst
@@ -777,12 +777,6 @@ enabled sub-projects. Nearly all of these variable names begin with
   ``LLVM_USE_SANITIZER`` contains ``Undefined``. This can be used to override
   the default set of UBSan flags.
 
-**LLVM_USE_CRT_{target}**:STRING
-  On Windows, tells which version of the C runtime library (CRT) should be used.
-  For example, -DLLVM_USE_CRT_RELEASE=MT would statically link the CRT into the
-  LLVM tools and library. This is deprecated; use ``CMAKE_MSVC_RUNTIME_LIBRARY``
-  instead.
-
 **LLVM_USE_INTEL_JITEVENTS**:BOOL
   Enable building support for Intel JIT Events API. Defaults to OFF.
 


        


More information about the cfe-commits mailing list