Skip to content

Commit b4693e0

Browse files
authored
[CMake] Update CMake cache file for the Win-to-Arm cross toolchains. NFC. (#87113)
Review the actual component parameters and update the cache file accordingly. Also fixed the C++ test builds for the compiler-rt component.
1 parent dc4cfdb commit b4693e0

File tree

1 file changed

+32
-10
lines changed

1 file changed

+32
-10
lines changed

clang/cmake/caches/CrossWinToARMLinux.cmake

+32-10
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
# cmake --build . --target check-cxxabi-<TOOLCHAIN_TARGET_TRIPLE>
3030
# cmake --build . --target check-unwind-<TOOLCHAIN_TARGET_TRIPLE>
3131
# cmake --build . --target check-cxx-<TOOLCHAIN_TARGET_TRIPLE>
32+
# (another way to execute the tests)
33+
# python bin/llvm-lit.py -v --threads=32 runtimes/runtimes-<TOOLCHAIN_TARGET_TRIPLE>bins/libunwind/test 2>&1 | tee libunwind-tests.log
34+
# python bin/llvm-lit.py -v --threads=32 runtimes/runtimes-<TOOLCHAIN_TARGET_TRIPLE>-bins/libcxxabi/test 2>&1 | tee libcxxabi-tests.log
35+
# python bin/llvm-lit.py -v --threads=32 runtimes/runtimes-<TOOLCHAIN_TARGET_TRIPLE>-bins/libcxx/test 2>&1 | tee libcxx-tests.log
36+
3237

3338
# LLVM_PROJECT_DIR is the path to the llvm-project directory.
3439
# The right way to compute it would probably be to use "${CMAKE_SOURCE_DIR}/../",
@@ -42,9 +47,6 @@ if (NOT DEFINED DEFAULT_SYSROOT)
4247
message(WARNING "DEFAULT_SYSROOT must be specified for the cross toolchain build.")
4348
endif()
4449

45-
if (NOT DEFINED LLVM_TARGETS_TO_BUILD)
46-
set(LLVM_TARGETS_TO_BUILD "ARM" CACHE STRING "")
47-
endif()
4850
if (NOT DEFINED LLVM_ENABLE_ASSERTIONS)
4951
set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
5052
endif()
@@ -56,7 +58,7 @@ if (NOT DEFINED LLVM_ENABLE_RUNTIMES)
5658
endif()
5759

5860
if (NOT DEFINED TOOLCHAIN_TARGET_TRIPLE)
59-
set(TOOLCHAIN_TARGET_TRIPLE "armv7-unknown-linux-gnueabihf")
61+
set(TOOLCHAIN_TARGET_TRIPLE "aarch64-unknown-linux-gnu")
6062
else()
6163
#NOTE: we must normalize specified target triple to a fully specified triple,
6264
# including the vendor part. It is necessary to synchronize the runtime library
@@ -74,24 +76,38 @@ else()
7476
string(REPLACE ";" "-" TOOLCHAIN_TARGET_TRIPLE "${TOOLCHAIN_TARGET_TRIPLE}")
7577
endif()
7678

79+
message(STATUS "Toolchain target triple: ${TOOLCHAIN_TARGET_TRIPLE}")
80+
81+
if (NOT DEFINED LLVM_TARGETS_TO_BUILD)
82+
if ("${TOOLCHAIN_TARGET_TRIPLE}" MATCHES "^(armv|arm32)+")
83+
set(LLVM_TARGETS_TO_BUILD "ARM" CACHE STRING "")
84+
endif()
85+
if ("${TOOLCHAIN_TARGET_TRIPLE}" MATCHES "^(aarch64|arm64)+")
86+
set(LLVM_TARGETS_TO_BUILD "AArch64" CACHE STRING "")
87+
endif()
88+
endif()
89+
90+
message(STATUS "Toolchain target to build: ${LLVM_TARGETS_TO_BUILD}")
91+
7792
if (NOT DEFINED CMAKE_BUILD_TYPE)
7893
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "")
7994
endif()
8095

81-
message(STATUS "Toolchain target triple: ${TOOLCHAIN_TARGET_TRIPLE}")
82-
8396
set(CMAKE_CROSSCOMPILING ON CACHE BOOL "")
8497
set(CMAKE_CL_SHOWINCLUDES_PREFIX "Note: including file: " CACHE STRING "")
8598
# Required if COMPILER_RT_DEFAULT_TARGET_ONLY is ON
8699
set(CMAKE_C_COMPILER_TARGET "${TOOLCHAIN_TARGET_TRIPLE}" CACHE STRING "")
87100
set(CMAKE_CXX_COMPILER_TARGET "${TOOLCHAIN_TARGET_TRIPLE}" CACHE STRING "")
88101

89-
set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR ON CACHE BOOL "")
90102
set(LLVM_DEFAULT_TARGET_TRIPLE "${TOOLCHAIN_TARGET_TRIPLE}" CACHE STRING "")
91103
set(LLVM_TARGET_ARCH "${TOOLCHAIN_TARGET_TRIPLE}" CACHE STRING "")
92104
set(LLVM_LIT_ARGS "-vv ${LLVM_LIT_ARGS}" CACHE STRING "" FORCE)
93105

106+
set(CLANG_DEFAULT_CXX_STDLIB "libc++" CACHE STRING "")
94107
set(CLANG_DEFAULT_LINKER "lld" CACHE STRING "")
108+
set(CLANG_DEFAULT_OBJCOPY "llvm-objcopy" CACHE STRING "")
109+
set(CLANG_DEFAULT_RTLIB "compiler-rt" CACHE STRING "")
110+
set(CLANG_DEFAULT_UNWINDLIB "libunwind" CACHE STRING "")
95111

96112
if(WIN32)
97113
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded" CACHE STRING "")
@@ -109,9 +125,10 @@ set(BUILTINS_${TOOLCHAIN_TARGET_TRIPLE}_CMAKE_SYSTEM_NAME
109125
set(BUILTINS_${TOOLCHAIN_TARGET_TRIPLE}_CMAKE_SYSROOT "${DEFAULT_SYSROOT}" CACHE STRING "")
110126
set(BUILTINS_${TOOLCHAIN_TARGET_TRIPLE}_CMAKE_INSTALL_RPATH "${RUNTIMES_INSTALL_RPATH}" CACHE STRING "")
111127
set(BUILTINS_${TOOLCHAIN_TARGET_TRIPLE}_CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE BOOL "")
112-
128+
set(BUILTINS_${TOOLCHAIN_TARGET_TRIPLE}_LLVM_CMAKE_DIR "${LLVM_PROJECT_DIR}/llvm/cmake/modules" CACHE PATH "")
113129

114130
set(LLVM_RUNTIME_TARGETS "${TOOLCHAIN_TARGET_TRIPLE}" CACHE STRING "")
131+
set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR ON CACHE BOOL "")
115132

116133
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LLVM_ENABLE_RUNTIMES "${LLVM_ENABLE_RUNTIMES}" CACHE STRING "")
117134

@@ -125,13 +142,16 @@ set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_COMPILER_RT_BUILD_SANITIZERS
125142
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_COMPILER_RT_BUILD_XRAY OFF CACHE BOOL "")
126143
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_COMPILER_RT_BUILD_LIBFUZZER OFF CACHE BOOL "")
127144
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_COMPILER_RT_BUILD_PROFILE OFF CACHE BOOL "")
128-
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_COMPILER_RT_BUILD_CRT OFF CACHE BOOL "")
145+
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_COMPILER_RT_BUILD_CRT ON CACHE BOOL "")
129146
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_COMPILER_RT_BUILD_ORC OFF CACHE BOOL "")
130147
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_COMPILER_RT_DEFAULT_TARGET_ONLY ON CACHE BOOL "")
131148
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_COMPILER_RT_INCLUDE_TESTS ON CACHE BOOL "")
132149
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_COMPILER_RT_CAN_EXECUTE_TESTS ON CACHE BOOL "")
133150

134151
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_COMPILER_RT_USE_BUILTINS_LIBRARY ON CACHE BOOL "")
152+
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_COMPILER_RT_CXX_LIBRARY libcxx CACHE STRING "")
153+
# Tell Clang to seach C++ headers alongside with the just-built binaries for the C++ compiler-rt tests.
154+
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_COMPILER_RT_TEST_COMPILER_CFLAGS "--stdlib=libc++" CACHE STRING "")
135155

136156
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
137157
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
@@ -148,8 +168,10 @@ set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_ABI_VERSION
148168
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_CXX_ABI "libcxxabi" CACHE STRING "") #!!!
149169
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS ON CACHE BOOL "")
150170

151-
171+
# Avoid searching for the python3 interpreter during the runtimes configuration for the cross builds.
172+
# It starts searching the python3 package using the target's sysroot path, that usually is not compatible with the build host.
152173
find_package(Python3 COMPONENTS Interpreter)
174+
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_Python3_EXECUTABLE ${Python3_EXECUTABLE} CACHE PATH "")
153175

154176
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBUNWIND_TEST_PARAMS_default "${RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_TEST_PARAMS}")
155177
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXXABI_TEST_PARAMS_default "${RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_TEST_PARAMS}")

0 commit comments

Comments
 (0)