diff --git a/swift/utils/build-script-impl b/swift/utils/build-script-impl
index b1d060328bc..218c9215260 100755
--- a/swift/utils/build-script-impl
+++ b/swift/utils/build-script-impl
@@ -690,6 +690,8 @@ function set_build_options_for_host() {
                     ;;
                 android-aarch64)
                     SWIFT_HOST_VARIANT_ARCH="aarch64"
+                    SWIFT_HOST_TRIPLE="aarch64-unknown-linux-android"
+                    llvm_target_arch="AArch64"
                     ;;
                 esac
         ;;
@@ -703,6 +705,8 @@ function set_build_options_for_host() {
     llvm_cmake_options+=(
         -DLLVM_TOOL_COMPILER_RT_BUILD:BOOL="$(false_true ${SKIP_BUILD_COMPILER_RT})"
         -DLLVM_BUILD_EXTERNAL_COMPILER_RT:BOOL="$(false_true ${SKIP_BUILD_COMPILER_RT})"
+        -DDEFAULT_SYSROOT:STRING="$(dirname @TERMUX_PREFIX@)"
+        -DCOMPILER_RT_INCLUDE_TESTS:BOOL="OFF"
     )
 
     # If we are asked to not generate test targets for LLVM and or Swift,
@@ -1028,7 +1032,7 @@ function make_relative_symlink() {
 CROSS_COMPILE_HOSTS=($CROSS_COMPILE_HOSTS)
 for t in "${CROSS_COMPILE_HOSTS[@]}"; do
     case ${t} in
-        iphone* | appletv* | watch* | linux-armv6 | linux-armv7 )
+        iphone* | appletv* | watch* | linux-armv6 | linux-armv7 | android-aarch64 )
             ;;
         *)
             echo "Unknown host to cross-compile for: ${t}"
@@ -1060,7 +1064,7 @@ function get_host_install_destdir() {
             # If this is one of the hosts we should lipo, install in to a temporary subdirectory.
             local host_install_destdir="${BUILD_DIR}/intermediate-install/${host}"
         else
-            local host_install_destdir="${INSTALL_DESTDIR}/${host}"
+            local host_install_destdir="${INSTALL_DESTDIR}"
         fi
     else
         local host_install_destdir="${INSTALL_DESTDIR}"
@@ -1422,6 +1426,26 @@ function swift_c_flags() {
     fi
 }
 
+function android_cross_cmake_options() {
+    local -n options=$1
+    options+=(
+        -DCMAKE_SYSTEM_NAME=Android
+        -DCMAKE_SYSTEM_VERSION=@TERMUX_PKG_API_LEVEL@
+        -DCMAKE_SYSTEM_PROCESSOR=@TERMUX_ARCH@
+        -DCMAKE_ANDROID_STANDALONE_TOOLCHAIN="@TERMUX_STANDALONE_TOOLCHAIN@"
+        -DCMAKE_C_FLAGS="$CFLAGS --target=$CCTERMUX_HOST_PLATFORM $CPPFLAGS"
+        -DCMAKE_CXX_FLAGS="$CXXFLAGS --target=$CCTERMUX_HOST_PLATFORM $CPPFLAGS"
+        -DCMAKE_EXE_LINKER_FLAGS="$LDFLAGS --target=$CCTERMUX_HOST_PLATFORM"
+        -DCMAKE_MODULE_LINKER_FLAGS="$LDFLAGS --target=$CCTERMUX_HOST_PLATFORM"
+        -DCMAKE_SHARED_LINKER_FLAGS="$LDFLAGS --target=$CCTERMUX_HOST_PLATFORM"
+        -DCMAKE_FIND_ROOT_PATH=@TERMUX_PREFIX@
+        -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER
+        -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY
+        -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY
+        -DCMAKE_HAVE_LIBC_PTHREAD=True
+    )
+}
+
 function cmake_config_opt() {
     product=$1
     if [[ "${CMAKE_GENERATOR}" == "Xcode" ]] ; then
@@ -1653,6 +1682,13 @@ for host in "${ALL_HOSTS[@]}"; do
                   -DCMAKE_BUILD_TYPE:STRING="${CMARK_BUILD_TYPE}"
                   "${cmark_cmake_options[@]}"
                 )
+                if [[ $(is_cross_tools_host ${host}) ]] ; then
+                    cmake_options=(
+                        "${cmake_options[@]}"
+                        -DCMAKE_C_FLAGS="$(cmark_c_flags ${host}) --target=$CCTERMUX_HOST_PLATFORM"
+                        -DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host}) --target=$CCTERMUX_HOST_PLATFORM"
+                    )
+                fi
                 skip_build=${SKIP_BUILD_CMARK}
                 build_targets=(all)
                 ;;
@@ -1758,6 +1794,7 @@ for host in "${ALL_HOSTS[@]}"; do
                         -DCLANG_TABLEGEN=$(build_directory "${LOCAL_HOST}" llvm)/bin/clang-tblgen
                         -DLLVM_NATIVE_BUILD=$(build_directory "${LOCAL_HOST}" llvm)
                     )
+                    android_cross_cmake_options cmake_options
                 fi
 
                 ;;
@@ -1768,12 +1812,18 @@ for host in "${ALL_HOSTS[@]}"; do
 
             swift)
 
-                if [[ ! "${SKIP_BUILD_ANDROID}" ]]; then
+                if [[ "${ANDROID_API_LEVEL}" ]]; then
+                    cmake_options=(
+                        "${cmake_options[@]}"
+                        -DSWIFT_ANDROID_API_LEVEL:STRING="${ANDROID_API_LEVEL}"
+                    )
+                fi
+
+                if [[ $(is_cross_tools_host ${host}) ]] ; then
                     cmake_options=(
                         "${cmake_options[@]}"
                         -DSWIFT_ANDROID_NDK_PATH:STRING="${ANDROID_NDK}"
                         -DSWIFT_ANDROID_NDK_GCC_VERSION:STRING="${ANDROID_NDK_GCC_VERSION}"
-                        -DSWIFT_ANDROID_API_LEVEL:STRING="${ANDROID_API_LEVEL}"
                         -DSWIFT_ANDROID_${ANDROID_ARCH}_ICU_UC:STRING="${ANDROID_ICU_UC}"
                         -DSWIFT_ANDROID_${ANDROID_ARCH}_ICU_UC_INCLUDE:STRING="${ANDROID_ICU_UC_INCLUDE}"
                         -DSWIFT_ANDROID_${ANDROID_ARCH}_ICU_I18N:STRING="${ANDROID_ICU_I18N}"
@@ -2116,6 +2163,7 @@ for host in "${ALL_HOSTS[@]}"; do
                     -DCMAKE_CXX_COMPILER:PATH="${CLANG_BIN}/clang++"
                     -DCMAKE_INSTALL_PREFIX:PATH="$(get_host_install_prefix ${host})"
                     -DCMAKE_Swift_COMPILER:PATH=${SWIFTC_BIN}
+                    -DCMAKE_Swift_FLAGS="${TERMUX_SWIFT_FLAGS}"
 
                     -DLLBUILD_ENABLE_ASSERTIONS:BOOL=$(true_false "${LLBUILD_ENABLE_ASSERTIONS}")
                     -DLLBUILD_SUPPORT_BINDINGS:=Swift
@@ -2144,6 +2192,11 @@ for host in "${ALL_HOSTS[@]}"; do
                         -DSQLite3_LIBRARY:PATH="/usr/lib/libsqlite3.dylib"
                     )
                 fi
+
+                build_targets=(llbuildSwift)
+                if [[ $(is_cross_tools_host ${host}) ]] ; then
+                    android_cross_cmake_options cmake_options
+                fi
                 ;;
             xctest)
                 XCTEST_BUILD_DIR=$(build_directory ${host} xctest)
@@ -2189,6 +2242,7 @@ for host in "${ALL_HOSTS[@]}"; do
                     -DCMAKE_C_COMPILER:PATH="${CLANG_BIN}/clang"
                     -DCMAKE_CXX_COMPILER:PATH="${CLANG_BIN}/clang++"
                     -DCMAKE_Swift_COMPILER:PATH=${SWIFTC_BIN}
+                    -DCMAKE_Swift_FLAGS="${TERMUX_SWIFT_FLAGS}"
                     -DCMAKE_INSTALL_PREFIX:PATH="$(get_host_install_prefix ${host})"
                     -DCMAKE_INSTALL_LIBDIR:PATH="lib"
 
@@ -2204,6 +2258,10 @@ for host in "${ALL_HOSTS[@]}"; do
 
                     -DENABLE_TESTING=YES
                   )
+
+                  if [[ $(is_cross_tools_host ${host}) ]] ; then
+                      android_cross_cmake_options cmake_options
+                  fi
                 ;;
                 esac
 
@@ -2268,6 +2326,7 @@ for host in "${ALL_HOSTS[@]}"; do
                   -DCMAKE_C_COMPILER:PATH=${CLANG_BIN}/clang
                   -DCMAKE_CXX_COMPILER:PATH=${CLANG_BIN}/clang++
                   -DCMAKE_SWIFT_COMPILER:PATH=${SWIFTC_BIN}
+                  -DCMAKE_Swift_FLAGS="${TERMUX_SWIFT_FLAGS}"
                   -DCMAKE_Swift_COMPILER:PATH=${SWIFTC_BIN}
                   -DCMAKE_INSTALL_PREFIX:PATH=$(get_host_install_prefix ${host})
 
@@ -2281,6 +2340,9 @@ for host in "${ALL_HOSTS[@]}"; do
                   -DBUILD_SHARED_LIBS=$([[ ${product} == foundation_static ]] && echo "NO" || echo "YES")
                 )
 
+                if [[ $(is_cross_tools_host ${host}) ]] ; then
+                    android_cross_cmake_options cmake_options
+                fi
                 ;;
             libdispatch|libdispatch_static)
                 LIBDISPATCH_BUILD_DIR=$(build_directory ${host} ${product})
@@ -2307,6 +2369,7 @@ for host in "${ALL_HOSTS[@]}"; do
                     -DCMAKE_CXX_COMPILER:PATH="${CLANG_BIN}/clang++"
                     -DCMAKE_SWIFT_COMPILER:PATH="${SWIFTC_BIN}"
                     -DCMAKE_Swift_COMPILER:PATH="${SWIFTC_BIN}"
+                    -DCMAKE_Swift_FLAGS="${TERMUX_SWIFT_FLAGS}"
                     -DCMAKE_INSTALL_PREFIX:PATH="$(get_host_install_prefix ${host})"
                     -DCMAKE_INSTALL_LIBDIR:PATH="lib"
 
@@ -2315,6 +2378,11 @@ for host in "${ALL_HOSTS[@]}"; do
                     -DENABLE_TESTING=YES
                     -DBUILD_SHARED_LIBS=$([[ ${product} == libdispatch_static ]] && echo "NO" || echo "YES")
                   )
+
+                  build_targets=(swiftDispatch)
+                  if [[ $(is_cross_tools_host ${host}) ]] ; then
+                      android_cross_cmake_options cmake_options
+                  fi
                 ;;
                 esac
 
@@ -2452,6 +2520,8 @@ for host in "${ALL_HOSTS[@]}"; do
               HOST_CXX_HEADERS_DIR="$HOST_CXX_DIR/../../usr/include/c++"
             elif [[ "$(uname -s)" == "Haiku" ]] ; then
               HOST_CXX_HEADERS_DIR="/boot/system/develop/headers/c++"
+            elif [[ "${ANDROID_DATA}" ]] ; then
+              HOST_CXX_HEADERS_DIR="$PREFIX/include/c++"
             else # Linux
               HOST_CXX_HEADERS_DIR="/usr/include/c++"
             fi
@@ -2929,7 +2999,14 @@ for host in "${ALL_HOSTS[@]}"; do
                 if [[ -z "${INSTALL_LLBUILD}" ]] ; then
                     continue
                 fi
-                INSTALL_TARGETS="install-swift-build-tool install-libllbuildSwift"
+                INSTALL_TARGETS="install-libllbuildSwift"
+                # Remove most libdispatch products before building the package manager.
+                rm -rf @TERMUX_PREFIX@/lib/swift{,_static}/{Block,os}
+                rm  @TERMUX_PREFIX@/lib/swift{,_static}/dispatch/*.h
+                sed -i -e "s%dispatch\.h%@TERMUX_PREFIX@/include/dispatch/dispatch.h%" \
+                -e "s%introspection\.h%@TERMUX_PREFIX@/include/dispatch/introspection.h%" \
+                @TERMUX_PREFIX@/lib/swift/dispatch/module.modulemap
+                cp @TERMUX_PREFIX@/lib/swift/dispatch/module.modulemap @TERMUX_PREFIX@/lib/swift_static/dispatch/module.modulemap
                 ;;
             # Products from this here install themselves; they don't fall-through.
             lldb)