|
6 | 6 | # on Windows platform.
|
7 | 7 | #
|
8 | 8 | # NOTE: the build requires a development ARM Linux root filesystem to use
|
9 |
| -# proper target platform depended library and header files: |
10 |
| -# - create <full-path-to-clang-configs> directory and put the clang configuration |
11 |
| -# file named <TOOLCHAIN_TARGET_TRIPLE>.cfg into it. |
12 |
| -# - add the `--sysroot=<path-to-develop-arm-linux-root-fs>` argument into |
13 |
| -# this configuration file. |
14 |
| -# - add other necessary target depended clang arguments there, |
15 |
| -# such as '-mcpu=cortex-a78' & etc. |
| 9 | +# proper target platform depended library and header files. |
| 10 | +# |
| 11 | +# The build generates a proper clang configuration file with stored |
| 12 | +# --sysroot argument for specified target triple. Also it is possible |
| 13 | +# to specify configuration path via CMake arguments, such as |
| 14 | +# -DCLANG_CONFIG_FILE_USER_DIR=<full-path-to-clang-configs> |
| 15 | +# and/or |
| 16 | +# -DCLANG_CONFIG_FILE_SYSTEM_DIR=<full-path-to-clang-configs> |
16 | 17 | #
|
17 | 18 | # See more details here: https://clang.llvm.org/docs/UsersManual.html#configuration-files
|
18 | 19 | #
|
19 | 20 | # Configure:
|
20 | 21 | # cmake -G Ninja ^
|
21 | 22 | # -DTOOLCHAIN_TARGET_TRIPLE=aarch64-unknown-linux-gnu ^
|
| 23 | +# -DTOOLCHAIN_TARGET_SYSROOTFS=<path-to-develop-arm-linux-root-fs> ^ |
| 24 | +# -DTOOLCHAIN_SHARED_LIBS=OFF ^ |
22 | 25 | # -DCMAKE_INSTALL_PREFIX=../install ^
|
23 |
| -# -DCLANG_CONFIG_FILE_USER_DIR=<full-path-to-clang-configs> ^ |
24 | 26 | # -DCMAKE_CXX_FLAGS="-D__OPTIMIZE__" ^
|
25 | 27 | # -DREMOTE_TEST_HOST="<hostname>" ^
|
26 | 28 | # -DREMOTE_TEST_USER="<ssh_user_name>" ^
|
@@ -81,6 +83,20 @@ endif()
|
81 | 83 |
|
82 | 84 | message(STATUS "Toolchain target triple: ${TOOLCHAIN_TARGET_TRIPLE}")
|
83 | 85 |
|
| 86 | +if (DEFINED TOOLCHAIN_TARGET_SYSROOTFS) |
| 87 | + message(STATUS "Toolchain target sysroot: ${TOOLCHAIN_TARGET_SYSROOTFS}") |
| 88 | + # Store the --sysroot argument for the compiler-rt test flags. |
| 89 | + set(sysroot_flags --sysroot='${TOOLCHAIN_TARGET_SYSROOTFS}') |
| 90 | + # Generate the clang configuration file for the specified target triple |
| 91 | + # and store --sysroot in this file. |
| 92 | + file(WRITE "${CMAKE_BINARY_DIR}/bin/${TOOLCHAIN_TARGET_TRIPLE}.cfg" ${sysroot_flags}) |
| 93 | +endif() |
| 94 | + |
| 95 | +# Build the shared libraries for libc++/libc++abi/libunwind. |
| 96 | +if (NOT DEFINED TOOLCHAIN_SHARED_LIBS) |
| 97 | + set(TOOLCHAIN_SHARED_LIBS OFF) |
| 98 | +endif() |
| 99 | + |
84 | 100 | if (NOT DEFINED LLVM_TARGETS_TO_BUILD)
|
85 | 101 | if ("${TOOLCHAIN_TARGET_TRIPLE}" MATCHES "^(armv|arm32)+")
|
86 | 102 | set(LLVM_TARGETS_TO_BUILD "ARM" CACHE STRING "")
|
@@ -183,20 +199,21 @@ set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_COMPILER_RT_CAN_EXECUTE_TESTS
|
183 | 199 |
|
184 | 200 | set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_COMPILER_RT_USE_BUILTINS_LIBRARY ON CACHE BOOL "")
|
185 | 201 | set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_COMPILER_RT_CXX_LIBRARY libcxx CACHE STRING "")
|
186 |
| -# Tell Clang to seach C++ headers alongside with the just-built binaries for the C++ compiler-rt tests. |
187 |
| -set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_COMPILER_RT_TEST_COMPILER_CFLAGS "--stdlib=libc++" CACHE STRING "") |
188 |
| - |
| 202 | +# The compiler-rt tests disable the clang configuration files during the execution by setting CLANG_NO_DEFAULT_CONFIG=1 |
| 203 | +# and drops out the --sysroot from there. Provide it explicity via the test flags here if target sysroot has been specified. |
| 204 | +set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_COMPILER_RT_TEST_COMPILER_CFLAGS "--stdlib=libc++ ${sysroot_flags}" CACHE STRING "") |
| 205 | + |
189 | 206 | set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
|
190 |
| -set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "") |
| 207 | +set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBUNWIND_ENABLE_SHARED ${TOOLCHAIN_SHARED_LIBS} CACHE BOOL "") |
191 | 208 |
|
192 | 209 | set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
|
193 | 210 | set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
|
194 | 211 | set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
|
195 | 212 | set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS OFF CACHE BOOL "")
|
196 |
| -set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "") |
| 213 | +set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXXABI_ENABLE_SHARED ${TOOLCHAIN_SHARED_LIBS} CACHE BOOL "") |
197 | 214 |
|
198 | 215 | set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
|
199 |
| -set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "") |
| 216 | +set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_ENABLE_SHARED ${TOOLCHAIN_SHARED_LIBS} CACHE BOOL "") |
200 | 217 | set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_ABI_VERSION ${LIBCXX_ABI_VERSION} CACHE STRING "")
|
201 | 218 | set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_CXX_ABI "libcxxabi" CACHE STRING "") #!!!
|
202 | 219 | set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS ON CACHE BOOL "")
|
|
0 commit comments