Skip to content

Commit 7d29718

Browse files
authored
[CMake] Update CMake cache file for the Win-to-Arm cross toolchains. NFC. (#93363)
* allow configuration for the target specific compiler flags. * allow lld linker for all linker outputs: shared, module and exe. * allow configuration of libc++ ABI version. * set MSVC runtime library to MultiThreadedDLL/MultiThreadedDebugDLL on Windows build hosts. * install UCRT libraries on Windows build hosts
1 parent 85cf2e5 commit 7d29718

File tree

1 file changed

+35
-3
lines changed

1 file changed

+35
-3
lines changed

clang/cmake/caches/CrossWinToARMLinux.cmake

+35-3
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@ endif()
8989

9090
message(STATUS "Toolchain target to build: ${LLVM_TARGETS_TO_BUILD}")
9191

92+
# Allow to override libc++ ABI version. Use 2 by default.
93+
if (NOT DEFINED LIBCXX_ABI_VERSION)
94+
set(LIBCXX_ABI_VERSION 2)
95+
endif()
96+
97+
message(STATUS "Toolchain's Libc++ ABI version: ${LIBCXX_ABI_VERSION}")
98+
9299
if (NOT DEFINED CMAKE_BUILD_TYPE)
93100
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "")
94101
endif()
@@ -109,8 +116,15 @@ set(CLANG_DEFAULT_OBJCOPY "llvm-objcopy" CACHE STRING "")
109116
set(CLANG_DEFAULT_RTLIB "compiler-rt" CACHE STRING "")
110117
set(CLANG_DEFAULT_UNWINDLIB "libunwind" CACHE STRING "")
111118

112-
if(WIN32)
113-
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded" CACHE STRING "")
119+
if (NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY AND WIN32)
120+
#Note: Always specify MT DLL for the LLDB build configurations on Windows host.
121+
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
122+
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDebugDLL" CACHE STRING "")
123+
else()
124+
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL" CACHE STRING "")
125+
endif()
126+
# Grab all ucrt/vcruntime related DLLs into the binary installation folder.
127+
set(CMAKE_INSTALL_UCRT_LIBRARIES ON CACHE BOOL "")
114128
endif()
115129

116130
# Set up RPATH for the target runtime/builtin libraries.
@@ -127,6 +141,15 @@ set(BUILTINS_${TOOLCHAIN_TARGET_TRIPLE}_CMAKE_INSTALL_RPATH
127141
set(BUILTINS_${TOOLCHAIN_TARGET_TRIPLE}_CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE BOOL "")
128142
set(BUILTINS_${TOOLCHAIN_TARGET_TRIPLE}_LLVM_CMAKE_DIR "${LLVM_PROJECT_DIR}/llvm/cmake/modules" CACHE PATH "")
129143

144+
if (DEFINED TOOLCHAIN_TARGET_COMPILER_FLAGS)
145+
foreach(lang C;CXX;ASM)
146+
set(BUILTINS_${TOOLCHAIN_TARGET_TRIPLE}_CMAKE_${lang}_FLAGS "${TOOLCHAIN_TARGET_COMPILER_FLAGS}" CACHE STRING "")
147+
endforeach()
148+
endif()
149+
foreach(type SHARED;MODULE;EXE)
150+
set(BUILTINS_${TOOLCHAIN_TARGET_TRIPLE}_CMAKE_${type}_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "")
151+
endforeach()
152+
130153
set(LLVM_RUNTIME_TARGETS "${TOOLCHAIN_TARGET_TRIPLE}" CACHE STRING "")
131154
set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR ON CACHE BOOL "")
132155

@@ -137,6 +160,15 @@ set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_CMAKE_SYSROOT
137160
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_CMAKE_INSTALL_RPATH "${RUNTIMES_INSTALL_RPATH}" CACHE STRING "")
138161
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE BOOL "")
139162

163+
if (DEFINED TOOLCHAIN_TARGET_COMPILER_FLAGS)
164+
foreach(lang C;CXX;ASM)
165+
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_CMAKE_${lang}_FLAGS "${TOOLCHAIN_TARGET_COMPILER_FLAGS}" CACHE STRING "")
166+
endforeach()
167+
endif()
168+
foreach(type SHARED;MODULE;EXE)
169+
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_CMAKE_${type}_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "")
170+
endforeach()
171+
140172
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_COMPILER_RT_BUILD_BUILTINS ON CACHE BOOL "")
141173
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_COMPILER_RT_BUILD_SANITIZERS OFF CACHE BOOL "")
142174
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_COMPILER_RT_BUILD_XRAY OFF CACHE BOOL "")
@@ -164,7 +196,7 @@ set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXXABI_ENABLE_SHARED
164196

165197
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
166198
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
167-
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_ABI_VERSION 2 CACHE STRING "")
199+
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_ABI_VERSION ${LIBCXX_ABI_VERSION} CACHE STRING "")
168200
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_CXX_ABI "libcxxabi" CACHE STRING "") #!!!
169201
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS ON CACHE BOOL "")
170202

0 commit comments

Comments
 (0)