@@ -26,21 +26,64 @@ set(LLVM_DEFAULT_TARGET_TRIPLE aarch64-unknown-windows-msvc CACHE STRING "")
2626set (LLVM_APPEND_VC_REV NO CACHE BOOL "" )
2727set (LLVM_ENABLE_PER_TARGET_RUNTIME_DIR YES CACHE BOOL "" )
2828set (LLVM_ENABLE_PYTHON YES CACHE BOOL "" )
29- set (LLVM_RUNTIME_TARGETS
29+
30+ set (default_targets
31+ x86_64-unknown-windows-msvc
3032 aarch64-unknown-windows-msvc
31- CACHE STRING "" )
33+ i686-unknown-windows-msvc )
34+ # Build the android builtins if NDK path is provided.
35+ if (NOT "$ENV{NDKPATH} " STREQUAL "" )
36+ list (APPEND default_targets
37+ aarch64-unknown-linux-android
38+ x86_64-unknown-linux-android
39+ i686-unknown-linux-android
40+ armv7-unknown-linux-androideabi)
41+ endif ()
42+
43+ set (LLVM_BUILTIN_TARGETS ${default_targets} CACHE STRING "" )
44+ set (LLVM_RUNTIME_TARGETS ${default_targets} CACHE STRING "" )
45+
3246foreach (target ${LLVM_RUNTIME_TARGETS} )
3347 set (RUNTIMES_${target} _LLVM_ENABLE_RUNTIMES
3448 compiler-rt
3549 CACHE STRING "" )
3650 set (RUNTIMES_${target} _CMAKE_MT mt CACHE STRING "" )
3751 set (RUNTIMES_${target} _CMAKE_SYSTEM_NAME Windows CACHE STRING "" )
3852 set (RUNTIMES_${target} _CMAKE_BUILD_TYPE Release CACHE STRING "" )
53+ set (RUNTIMES_${target} _COMPILER_RT_BUILD_BUILTINS YES CACHE BOOL "" )
3954 set (RUNTIMES_${target} _COMPILER_RT_BUILD_CRT NO CACHE BOOL "" )
4055 set (RUNTIMES_${target} _COMPILER_RT_BUILD_LIBFUZZER NO CACHE BOOL "" )
56+ set (RUNTIMES_${target} _COMPILER_RT_BUILD_ORC NO CACHE BOOL "" )
4157 set (RUNTIMES_${target} _COMPILER_RT_BUILD_PROFILE YES CACHE BOOL "" )
58+ set (RUNTIMES_${target} _COMPILER_RT_BUILD_XRAY NO CACHE BOOL "" )
59+ # Sanitizers will be configured, but not built. We have separate build
60+ # steps for that, because we need a different shell for each target.
4261 set (RUNTIMES_${target} _COMPILER_RT_BUILD_SANITIZERS NO CACHE BOOL "" )
43- set (RUNTIMES_${target} _COMPILER_RT_BUILD_XRAY NO CACHE BOOL "" )
62+ endforeach ()
63+
64+ foreach (target ${LLVM_BUILTIN_TARGETS} )
65+ set (BUILTINS_${target} _CMAKE_MT mt CACHE STRING "" )
66+ if (${target} MATCHES windows-msvc )
67+ set (BUILTINS_${target} _CMAKE_SYSTEM_NAME Windows CACHE STRING "" )
68+ elseif (${target} MATCHES linux-android)
69+ # Use a single 'linux' directory and arch-based lib names on Android.
70+ set (BUILTINS_${target} _LLVM_ENABLE_PER_TARGET_RUNTIME_DIR NO CACHE BOOL "" )
71+ set (BUILTINS_${target} _CMAKE_SYSTEM_NAME Android CACHE STRING "" )
72+ if (${target} MATCHES aarch64)
73+ set (BUILTINS_${target} _CMAKE_ANDROID_ARCH_ABI arm64-v8a CACHE STRING "" )
74+ elseif (${target} MATCHES armv7)
75+ set (BUILTINS_${target} _CMAKE_ANDROID_ARCH_ABI armeabi-v7a CACHE STRING "" )
76+ elseif (${target} MATCHES i686)
77+ set (BUILTINS_${target} _CMAKE_ANDROID_ARCH_ABI i686 CACHE STRING "" )
78+ else ()
79+ set (BUILTINS_${target} _CMAKE_ANDROID_ARCH_ABI x86_64 CACHE STRING "" )
80+ endif ()
81+ set (BUILTINS_${target} _CMAKE_ANDROID_NDK $ENV{NDKPATH} CACHE PATH "" )
82+ set (BUILTINS_${target} _CMAKE_ANDROID_API 21 CACHE STRING "" )
83+ set (BUILTINS_${target} _CMAKE_C_COMPILER_TARGET "${target} 21" CACHE STRING "" )
84+ set (BUILTINS_${target} _CMAKE_CXX_COMPILER_TARGET "${target} 21" CACHE STRING "" )
85+ endif ()
86+ set (BUILTINS_${target} _CMAKE_BUILD_TYPE Release CACHE STRING "" )
4487endforeach ()
4588
4689set (LLVM_TARGETS_TO_BUILD AArch64 ARM WebAssembly X86 CACHE STRING "" )
@@ -165,6 +208,7 @@ set(LLVM_DISTRIBUTION_COMPONENTS
165208 libclang
166209 libclang-headers
167210 LTO
211+ builtins
168212 runtimes
169213 ${LLVM_TOOLCHAIN_TOOLS}
170214 ${CLANG_TOOLS}
0 commit comments