118 lines
4.8 KiB
Diff
118 lines
4.8 KiB
Diff
|
commit 47d94da23587b7343b1fcddf44c2db24f2ed5331
|
||
|
Date: Fri Dec 4 21:08:59 2020 +0530
|
||
|
|
||
|
[android] Support building the host tools and with the static stdlib
|
||
|
|
||
|
diff --git a/swift/stdlib/public/runtime/CMakeLists.txt b/swift/stdlib/public/runtime/CMakeLists.txt
|
||
|
index fd8e29ae1a85..b1bc4ea4a92a 100644
|
||
|
--- a/swift/stdlib/public/runtime/CMakeLists.txt
|
||
|
+++ b/swift/stdlib/public/runtime/CMakeLists.txt
|
||
|
@@ -116,7 +116,7 @@ add_swift_target_library(swiftRuntime OBJECT_LIBRARY
|
||
|
|
||
|
set(ELFISH_SDKS)
|
||
|
set(COFF_SDKS)
|
||
|
-foreach(sdk ${SWIFT_CONFIGURED_SDKS})
|
||
|
+foreach(sdk ${SWIFT_SDKS})
|
||
|
if("${SWIFT_SDK_${sdk}_OBJECT_FORMAT}" STREQUAL "ELF")
|
||
|
list(APPEND ELFISH_SDKS ${sdk})
|
||
|
elseif("${SWIFT_SDK_${sdk}_OBJECT_FORMAT}" STREQUAL "COFF")
|
||
|
@@ -144,7 +144,7 @@ add_swift_target_library(swiftImageRegistrationObjectCOFF
|
||
|
SWIFT_COMPILE_FLAGS ${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS}
|
||
|
INSTALL_IN_COMPONENT none)
|
||
|
|
||
|
-foreach(sdk ${SWIFT_CONFIGURED_SDKS})
|
||
|
+foreach(sdk ${SWIFT_SDKS})
|
||
|
foreach(arch ${SWIFT_SDK_${sdk}_ARCHITECTURES})
|
||
|
set(arch_subdir "${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${arch}")
|
||
|
set(arch_suffix "${SWIFT_SDK_${sdk}_LIB_SUBDIR}-${arch}")
|
||
|
@@ -224,11 +224,18 @@ foreach(sdk ${SWIFT_CONFIGURED_SDKS})
|
||
|
set(libicu_data_a ${ICU_UC_LIBDIR}/libicudata.a)
|
||
|
endif()
|
||
|
endif()
|
||
|
+ set(libpthread -lpthread)
|
||
|
+ set(android_libraries)
|
||
|
+ if(${sdk} STREQUAL ANDROID)
|
||
|
+ set(android_libraries -llog)
|
||
|
+ set(libpthread)
|
||
|
+ endif()
|
||
|
|
||
|
set(linkfile ${lowercase_sdk}/static-stdlib-args.lnk)
|
||
|
file(WRITE "${SWIFTSTATICLIB_DIR}/${linkfile}" "
|
||
|
-ldl
|
||
|
--lpthread
|
||
|
+${libpthread}
|
||
|
+${android_libraries}
|
||
|
-lswiftCore
|
||
|
${libicu_i18n_a}
|
||
|
${libicu_uc_a}
|
||
|
diff --git a/swift/utils/build-script-impl b/swift/utils/build-script-impl
|
||
|
index 268d23de155a..d33ab94d1bd8 100755
|
||
|
--- a/swift/utils/build-script-impl
|
||
|
+++ b/swift/utils/build-script-impl
|
||
|
@@ -452,17 +452,35 @@ function set_build_options_for_host() {
|
||
|
SWIFT_HOST_VARIANT_ARCH=$architecture
|
||
|
|
||
|
case ${host} in
|
||
|
- android-aarch64)
|
||
|
- SWIFT_HOST_TRIPLE="aarch64-unknown-linux-android${ANDROID_API_LEVEL}"
|
||
|
- llvm_target_arch="AArch64"
|
||
|
- ;;
|
||
|
- android-armv7)
|
||
|
- SWIFT_HOST_TRIPLE="armv7-unknown-linux-androideabi${ANDROID_API_LEVEL}"
|
||
|
- llvm_target_arch="ARM"
|
||
|
- ;;
|
||
|
- android-x86_64)
|
||
|
- SWIFT_HOST_TRIPLE="x86_64-unknown-linux-android${ANDROID_API_LEVEL}"
|
||
|
- llvm_target_arch="X86"
|
||
|
+ android-*)
|
||
|
+ # Clang uses a different sysroot natively on Android in the Termux
|
||
|
+ # app, which the Termux build scripts pass in through a $PREFIX
|
||
|
+ # variable.
|
||
|
+ if [[ "${PREFIX}" ]] ; then
|
||
|
+ llvm_cmake_options+=(
|
||
|
+ -DDEFAULT_SYSROOT:STRING="$(dirname ${PREFIX})"
|
||
|
+ )
|
||
|
+ fi
|
||
|
+ # Android doesn't support building all of compiler-rt yet.
|
||
|
+ if [[ ! $(is_cross_tools_host "${host}") ]] ; then
|
||
|
+ llvm_cmake_options+=(
|
||
|
+ -DCOMPILER_RT_INCLUDE_TESTS:BOOL=FALSE
|
||
|
+ )
|
||
|
+ fi
|
||
|
+ case ${host} in
|
||
|
+ android-aarch64)
|
||
|
+ SWIFT_HOST_TRIPLE="aarch64-unknown-linux-android${ANDROID_API_LEVEL}"
|
||
|
+ llvm_target_arch="AArch64"
|
||
|
+ ;;
|
||
|
+ android-armv7)
|
||
|
+ SWIFT_HOST_TRIPLE="armv7-unknown-linux-androideabi${ANDROID_API_LEVEL}"
|
||
|
+ llvm_target_arch="ARM"
|
||
|
+ ;;
|
||
|
+ android-x86_64)
|
||
|
+ SWIFT_HOST_TRIPLE="x86_64-unknown-linux-android${ANDROID_API_LEVEL}"
|
||
|
+ llvm_target_arch="X86"
|
||
|
+ ;;
|
||
|
+ esac
|
||
|
;;
|
||
|
linux-armv6)
|
||
|
SWIFT_HOST_TRIPLE="armv6-unknown-linux-gnueabihf"
|
||
|
@@ -1756,7 +1774,8 @@ for host in "${ALL_HOSTS[@]}"; do
|
||
|
)
|
||
|
fi
|
||
|
|
||
|
- if [[ ! "${SKIP_BUILD_ANDROID}" ]]; then
|
||
|
+ if [[ ! "${SKIP_BUILD_ANDROID}" ]] ||
|
||
|
+ [[ $(is_cross_tools_host ${host}) && "${host}" == "android-"* ]]; then
|
||
|
cmake_options=(
|
||
|
"${cmake_options[@]}"
|
||
|
-DSWIFT_ANDROID_NDK_PATH:STRING="${ANDROID_NDK}"
|
||
|
@@ -2447,6 +2466,8 @@ for host in "${ALL_HOSTS[@]}"; do
|
||
|
elif [[ "$(uname -s)" == "Haiku" ]] ; then
|
||
|
HOST_CXX_HEADERS_DIR="/boot/system/develop/headers/c++"
|
||
|
elif [[ "${ANDROID_DATA}" ]] ; then
|
||
|
+ # This means we're building natively on Android in the Termux
|
||
|
+ # app, which supplies the $PREFIX variable.
|
||
|
HOST_CXX_HEADERS_DIR="$PREFIX/include/c++"
|
||
|
else # Linux
|
||
|
HOST_CXX_HEADERS_DIR="/usr/include/c++"
|