-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CMake]Fully delete the deprecated LLVM_USE_CRT* #66850
Conversation
@llvm/pr-subscribers-clang ChangesNotes
Full diff: https://github.com/llvm/llvm-project/pull/66850.diff 7 Files Affected:
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 different choices for different build configurations (for
-# multi-config generators), but translating multiple differing 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.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks mostly good to me, but a few cases might need setting CMAKE_MSVC_RUNTIME_LIBRARY
instead of the removed variable.
The commit message needs improving though. This isn't related to the discussion about crt allocators at all.
Instead the commit message should explain that this setting is deprecated by the new CMake mechanism that we now prefer, mention that this was already marked as deprecated since July (referencing the commit c6bd873), and mention that the current release branch, 17.x, still contains this option in deprecated form (so people upgrading through each major release won't have a silent break, but will get deprecation about using the old option form and have a chance to change it before it is removed).
@@ -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 "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This case here seems to lack a corresponding setting of CMAKE_MSVC_RUNTIME_LIBRARY
- I guess we should add that to make this a proper no-op?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's been set at Line 57?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I didn't see that one.
@@ -70,10 +70,6 @@ foreach(variable ${_FUCHSIA_BOOTSTRAP_PASSTHROUGH}) | |||
endif() | |||
endforeach() | |||
|
|||
if(WIN32) | |||
set(LLVM_USE_CRT_RELEASE "MT" CACHE STRING "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here - we should probably set CMAKE_MSVC_RUNTIME_LIBRARY
instead of just removing the setting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, maybe Line57 is enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean line 91 here? Ok, that's also present elsewhere here.
@@ -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)$") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I wonder how I had missed this one while doing the deprecation cleanup...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, the PR seems fine code-wise then - please update the commit message (PR description) and this should be fine.
@@ -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 "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I didn't see that one.
@@ -70,10 +70,6 @@ foreach(variable ${_FUCHSIA_BOOTSTRAP_PASSTHROUGH}) | |||
endif() | |||
endforeach() | |||
|
|||
if(WIN32) | |||
set(LLVM_USE_CRT_RELEASE "MT" CACHE STRING "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean line 91 here? Ok, that's also present elsewhere here.
This has been deprecated in favor of CMake's CMAKE_MSVC_RUNTIME_LIBRARY in c6bd873 . Current release branch still contains it in deprecated status so no existing end-users will be affected
Updated the commit message @mstorsjo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks. (But let's wait with landing it until e.g. tomorrow, in case someone else has comments on it.)
I think this should be fine to land now. Do you have commit access, or do you want me to push the button? |
Push the button for me please :D |
…RT_RELEASE This was made an error in llvm/llvm-project#66850. Bug: 1485646 Change-Id: Id106d4f9beeea7299befa4d866a75dd3153ba3b5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4887702 Commit-Queue: Amy Huang <[email protected]> Commit-Queue: Arthur Eubanks <[email protected]> Reviewed-by: Amy Huang <[email protected]> Cr-Commit-Position: refs/heads/main@{#1200349}
This unveiled an interesting problem in our builds: |
(because our script was still using LLVM_USE_CRT_RELEASE) |
I |
The old flags were removed upstream: llvm#66850
The old flags were removed upstream: llvm#66850
The old flags were removed upstream: llvm#66850
The old flags were removed upstream: llvm#66850
The old flags were removed upstream: llvm#66850
The old flags were removed upstream: llvm#66850
This has been deprecated in favor of CMake's CMAKE_MSVC_RUNTIME_LIBRARY in c6bd873 .
Current release branch still contains it in deprecated status so no existing end-users will be affected