@@ -452,17 +452,35 @@ function set_build_options_for_host() {
452452 SWIFT_HOST_VARIANT_ARCH=$architecture
453453
454454 case ${host} in
455- android-aarch64)
456- SWIFT_HOST_TRIPLE=" aarch64-unknown-linux-android"
457- llvm_target_arch=" AArch64"
458- ;;
459- android-armv7)
460- SWIFT_HOST_TRIPLE=" armv7-unknown-linux-androideabi"
461- llvm_target_arch=" ARM"
462- ;;
463- android-x86_64)
464- SWIFT_HOST_TRIPLE=" x86_64-unknown-linux-android${ANDROID_API_LEVEL} "
465- llvm_target_arch=" X86"
455+ android-* )
456+ # Clang uses a different sysroot natively on Android in the Termux
457+ # app, which the Termux build scripts pass in through a $PREFIX
458+ # variable.
459+ if [[ " ${PREFIX} " ]] ; then
460+ llvm_cmake_options+=(
461+ -DDEFAULT_SYSROOT:STRING=" $( dirname ${PREFIX} ) "
462+ )
463+ fi
464+ # Android doesn't support building all of compiler-rt yet.
465+ if [[ ! $( is_cross_tools_host " ${host} " ) ]] ; then
466+ llvm_cmake_options+=(
467+ -DCOMPILER_RT_INCLUDE_TESTS:BOOL=FALSE
468+ )
469+ fi
470+ case ${host} in
471+ android-aarch64)
472+ SWIFT_HOST_TRIPLE=" aarch64-unknown-linux-android"
473+ llvm_target_arch=" AArch64"
474+ ;;
475+ android-armv7)
476+ SWIFT_HOST_TRIPLE=" armv7-unknown-linux-androideabi"
477+ llvm_target_arch=" ARM"
478+ ;;
479+ android-x86_64)
480+ SWIFT_HOST_TRIPLE=" x86_64-unknown-linux-android${ANDROID_API_LEVEL} "
481+ llvm_target_arch=" X86"
482+ ;;
483+ esac
466484 ;;
467485 linux-armv6)
468486 SWIFT_HOST_TRIPLE=" armv6-unknown-linux-gnueabihf"
@@ -1756,7 +1774,8 @@ for host in "${ALL_HOSTS[@]}"; do
17561774 )
17571775 fi
17581776
1759- if [[ ! " ${SKIP_BUILD_ANDROID} " ]]; then
1777+ if [[ ! " ${SKIP_BUILD_ANDROID} " ]] ||
1778+ [[ $( is_cross_tools_host ${host} ) && " ${host} " == " android-" * ]]; then
17601779 cmake_options=(
17611780 " ${cmake_options[@]} "
17621781 -DSWIFT_ANDROID_NDK_PATH:STRING=" ${ANDROID_NDK} "
@@ -2447,6 +2466,8 @@ for host in "${ALL_HOSTS[@]}"; do
24472466 elif [[ " $( uname -s) " == " Haiku" ]] ; then
24482467 HOST_CXX_HEADERS_DIR=" /boot/system/develop/headers/c++"
24492468 elif [[ " ${ANDROID_DATA} " ]] ; then
2469+ # This means we're building natively on Android in the Termux
2470+ # app, which supplies the $PREFIX variable.
24502471 HOST_CXX_HEADERS_DIR=" $PREFIX /include/c++"
24512472 else # Linux
24522473 HOST_CXX_HEADERS_DIR=" /usr/include/c++"
0 commit comments