swift: bump clang headers symlink version to 10.0.1 and refactor some flags and patches

This commit is contained in:
Butta 2020-07-28 13:18:36 +05:30 committed by buttaface
parent 3b8b4a61a8
commit 8c65964325
4 changed files with 333 additions and 374 deletions

View File

@ -2,7 +2,7 @@ TERMUX_PKG_HOMEPAGE=https://swift.org/
TERMUX_PKG_DESCRIPTION="Swift is a high-performance system programming language"
TERMUX_PKG_LICENSE="Apache-2.0, NCSA"
TERMUX_PKG_VERSION=5.2.4
TERMUX_PKG_REVISION=3
TERMUX_PKG_REVISION=4
SWIFT_RELEASE="RELEASE"
TERMUX_PKG_SRCURL=https://github.com/apple/swift/archive/swift-$TERMUX_PKG_VERSION-$SWIFT_RELEASE.tar.gz
TERMUX_PKG_SHA256=94c44101c3dd6774887029110269bbaf9aff68cce5ea0783588157cc08d82ed8
@ -19,13 +19,17 @@ SWIFT_PATH_FLAGS="--build-subdir=. --install-destdir=/ --install-prefix=$TERMUX_
if [ "$TERMUX_ON_DEVICE_BUILD" = "true" ]; then
SWIFT_BUILD_FLAGS="--build-swift-static-stdlib --swift-install-components='$SWIFT_COMPONENTS;stdlib;sdk-overlay'"
else
SWIFT_BIN="swift-$TERMUX_PKG_VERSION-$SWIFT_RELEASE-ubuntu20.04"
SWIFT_BINDIR="$TERMUX_PKG_HOSTBUILD_DIR/$SWIFT_BIN/usr/bin"
SWIFT_ANDROID_NDK_FLAGS="--android --android-ndk $TERMUX_STANDALONE_TOOLCHAIN --android-arch $TERMUX_ARCH
--android-api-level $TERMUX_PKG_API_LEVEL --android-icu-uc $TERMUX_PREFIX/lib/libicuuc.so
--android-icu-uc-include $TERMUX_PREFIX/include/ --android-icu-i18n $TERMUX_PREFIX/lib/libicui18n.so
--android-icu-i18n-include $TERMUX_PREFIX/include/ --android-icu-data $TERMUX_PREFIX/lib/libicudata.so"
SWIFT_BUILD_FLAGS="$SWIFT_ANDROID_NDK_FLAGS --build-toolchain-only
SWIFT_BUILD_FLAGS="$SWIFT_ANDROID_NDK_FLAGS --build-toolchain-only --skip-build-android
--cross-compile-hosts=android-$TERMUX_ARCH --swift-install-components='$SWIFT_COMPONENTS'
--build-swift-dynamic-stdlib=0 --build-swift-dynamic-sdk-overlay=0"
--native-swift-tools-path=$SWIFT_BINDIR --native-clang-tools-path=$TERMUX_STANDALONE_TOOLCHAIN/bin
--build-swift-dynamic-stdlib=0 --build-swift-dynamic-sdk-overlay=0 --skip-local-build
--skip-local-host-install"
fi
termux_step_post_get_source() {
@ -60,8 +64,8 @@ termux_step_post_get_source() {
if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then
termux_download \
https://swift.org/builds/swift-$TERMUX_PKG_VERSION-release/ubuntu2004/swift-$TERMUX_PKG_VERSION-$SWIFT_RELEASE/swift-$TERMUX_PKG_VERSION-$SWIFT_RELEASE-ubuntu20.04.tar.gz \
$TERMUX_PKG_CACHEDIR/swift-$TERMUX_PKG_VERSION-$SWIFT_RELEASE-ubuntu20.04.tar.gz \
https://swift.org/builds/swift-$TERMUX_PKG_VERSION-release/ubuntu2004/swift-$TERMUX_PKG_VERSION-$SWIFT_RELEASE/$SWIFT_BIN.tar.gz \
$TERMUX_PKG_CACHEDIR/$SWIFT_BIN.tar.gz \
00629cde8f10b0a97646cb89f7ee66ad1e65f259d25d7e03132e348dcf4d792b
fi
@ -84,9 +88,8 @@ termux_step_post_get_source() {
termux_step_host_build() {
if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then
if [ "$TERMUX_PKG_QUICK_REBUILD" = "false" ]; then
tar xf $TERMUX_PKG_CACHEDIR/swift-$TERMUX_PKG_VERSION-$SWIFT_RELEASE-ubuntu20.04.tar.gz
tar xf $TERMUX_PKG_CACHEDIR/$SWIFT_BIN.tar.gz
fi
local SWIFT_BINDIR="$TERMUX_PKG_HOSTBUILD_DIR/swift-$TERMUX_PKG_VERSION-$SWIFT_RELEASE-ubuntu20.04/usr/bin"
termux_setup_cmake
termux_setup_ninja
@ -135,14 +138,11 @@ termux_step_pre_configure() {
patch -p1 < $TERMUX_PKG_BUILDER_DIR/../libllvm/include-llvm-ADT-Triple.h.patch
cd ../..
if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then
# Build patch needed only when cross-compiling the compiler.
sed "s%\@TERMUX_STANDALONE_TOOLCHAIN\@%${TERMUX_STANDALONE_TOOLCHAIN}%g" \
$TERMUX_PKG_BUILDER_DIR/swift-utils-build-script-impl | \
sed "s%\@TERMUX_PKG_API_LEVEL\@%${TERMUX_PKG_API_LEVEL}%g" | \
sed "s%\@TERMUX_PREFIX\@%${TERMUX_PREFIX}%g" | \
sed "s%\@TERMUX_ARCH\@%${TERMUX_ARCH}%g" | patch -p1
fi
sed "s%\@TERMUX_STANDALONE_TOOLCHAIN\@%${TERMUX_STANDALONE_TOOLCHAIN}%g" \
$TERMUX_PKG_BUILDER_DIR/swift-utils-build-script-impl | \
sed "s%\@TERMUX_PKG_API_LEVEL\@%${TERMUX_PKG_API_LEVEL}%g" | \
sed "s%\@TERMUX_PREFIX\@%${TERMUX_PREFIX}%g" | \
sed "s%\@TERMUX_ARCH\@%${TERMUX_ARCH}%g" | patch -p1
sed "s%\@TERMUX_STANDALONE_TOOLCHAIN\@%${TERMUX_STANDALONE_TOOLCHAIN}%g" \
$TERMUX_PKG_BUILDER_DIR/swiftpm-Utilities-bootstrap | \
@ -159,7 +159,7 @@ termux_step_make() {
-L$TERMUX_STANDALONE_TOOLCHAIN/lib/gcc/$TERMUX_HOST_PLATFORM/4.9.x \
-tools-directory $TERMUX_STANDALONE_TOOLCHAIN/$TERMUX_HOST_PLATFORM/bin \
-Xlinker -rpath -Xlinker $TERMUX_PREFIX/lib"
export HOST_SWIFTC="$TERMUX_PKG_HOSTBUILD_DIR/swift-$TERMUX_PKG_VERSION-$SWIFT_RELEASE-ubuntu20.04/usr/bin/swiftc"
export HOST_SWIFTC="$SWIFT_BINDIR/swiftc"
# Use the modulemap that points to the sysroot headers in the standalone NDK
# when cross-compiling, rather than the one meant for running natively on Termux,
@ -176,6 +176,7 @@ termux_step_make() {
termux_step_make_install() {
rm $TERMUX_PREFIX/lib/swift/pm/llbuild/libllbuild.so
rm $TERMUX_PREFIX/lib/swift/android/lib{dispatch,BlocksRuntime}.so
if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then
cp $TERMUX_PKG_BUILDDIR/glibc-native.modulemap \

View File

@ -36,362 +36,6 @@ index b1d060328bc..218c9215260 100755
for product_class in product_classes:
if product_class.is_build_script_impl_product():
continue
diff --git a/swift/utils/build-script-impl b/swift/utils/build-script-impl
index 7f39ff97459..9e5a646b668 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,10 @@ function swift_c_flags() {
fi
}
+function android_cross_swift_flags() {
+ echo -n "${TERMUX_SWIFT_FLAGS}"
+}
+
function cmake_config_opt() {
product=$1
if [[ "${CMAKE_GENERATOR}" == "Xcode" ]] ; then
@@ -1634,6 +1642,13 @@ for host in "${ALL_HOSTS[@]}"; do
product_cmake_options=(${!product_cmake_options_name}) # convert to array
cmake_options+=("${product_cmake_options[@]}")
+ function skip_configure_and_build() {
+ dir=$1
+ call mkdir -p "${dir}"
+ call touch "${dir}/CMakeCache.txt" "${dir}/build.ninja"
+ skip_build=true
+ }
+
case ${product} in
cmark)
cmake_options=(
@@ -1641,6 +1665,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)
;;
@@ -1665,6 +1696,10 @@ for host in "${ALL_HOSTS[@]}"; do
fi
fi
+ if [[ "${CROSS_COMPILE_HOSTS}" && "${host}" == "${LOCAL_HOST}" ]] ; then
+ skip_build=true
+ fi
+
if [ "${HOST_LIBTOOL}" ] ; then
cmake_options=(
"${cmake_options[@]}"
@@ -1746,6 +1765,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 +1803,18 @@ for host in "${ALL_HOSTS[@]}"; do
swift)
+ if [[ "${ANDROID_API_LEVEL}" ]]; then
+ cmake_options=(
+ "${cmake_options[@]}"
+ -DSWIFT_ANDROID_API_LEVEL:STRING="${ANDROID_API_LEVEL}"
+ )
+ fi
+
if [[ ! "${SKIP_BUILD_ANDROID}" ]]; 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}"
@@ -1973,7 +2014,11 @@ for host in "${ALL_HOSTS[@]}"; do
)
fi
+ if [[ $(is_cross_tools_host ${host}) ]] ; then
+ build_targets=(all)
+ else
build_targets=(all "${SWIFT_STDLIB_TARGETS[@]}")
+ fi
if [[ $(true_false "${build_perf_testsuite_this_time}") == "TRUE" ]]; then
native_swift_tools_path="$(build_directory_bin ${LOCAL_HOST} swift)"
cmake_options=(
@@ -1984,6 +2029,9 @@ for host in "${ALL_HOSTS[@]}"; do
"${SWIFT_BENCHMARK_TARGETS[@]}")
fi
skip_build=${SKIP_BUILD_SWIFT}
+ if [[ "${CROSS_COMPILE_HOSTS}" && "${host}" == "${LOCAL_HOST}" ]] ; then
+ skip_build=true
+ fi
;;
lldb)
if [ ! -d "${LLDB_SOURCE_DIR}" ]; then
@@ -2101,7 +2149,6 @@ for host in "${ALL_HOSTS[@]}"; do
-DCMAKE_BUILD_TYPE:STRING="${LLBUILD_BUILD_TYPE}"
-DCMAKE_INSTALL_PREFIX:PATH="$(get_host_install_prefix ${host})"
- -DCMAKE_Swift_COMPILER:PATH="$(build_directory_bin ${LOCAL_HOST} swift)/swiftc"
-DLLBUILD_ENABLE_ASSERTIONS:BOOL=$(true_false "${LLBUILD_ENABLE_ASSERTIONS}")
-DLLBUILD_SUPPORT_BINDINGS:=Swift
@@ -2130,6 +2177,23 @@ for host in "${ALL_HOSTS[@]}"; do
-DSQLite3_LIBRARY:PATH="/usr/lib/libsqlite3.dylib"
)
fi
+
+ if [[ $(is_cross_tools_host ${host}) ]] ; then
+ cmake_options+=(
+ -DCMAKE_Swift_COMPILER:PATH="${HOST_SWIFTC}"
+ -DCMAKE_Swift_FLAGS="$(android_cross_swift_flags)"
+ )
+ android_cross_cmake_options cmake_options
+ build_targets=(llbuildSwift)
+ else
+ cmake_options+=(
+ -DCMAKE_Swift_COMPILER:PATH="$(build_directory_bin ${LOCAL_HOST} swift)/swiftc"
+ )
+ fi
+
+ if [[ "${CROSS_COMPILE_HOSTS}" && "${host}" == "${LOCAL_HOST}" ]] ; then
+ skip_configure_and_build ${build_dir}
+ fi
;;
xctest)
SWIFTC_BIN="$(build_directory_bin ${LOCAL_HOST} swift)/swiftc"
@@ -2175,9 +2235,6 @@ for host in "${ALL_HOSTS[@]}"; do
cmake_options=(
${cmake_options[@]}
-DCMAKE_BUILD_TYPE:STRING="${XCTEST_BUILD_TYPE}"
- -DCMAKE_C_COMPILER:PATH="${LLVM_BIN}/clang"
- -DCMAKE_CXX_COMPILER:PATH="${LLVM_BIN}/clang++"
- -DCMAKE_Swift_COMPILER:PATH="$(build_directory_bin ${LOCAL_HOST} swift)/swiftc"
-DCMAKE_INSTALL_PREFIX:PATH="$(get_host_install_prefix ${host})"
-DCMAKE_INSTALL_LIBDIR:PATH="lib"
@@ -2193,6 +2250,24 @@ for host in "${ALL_HOSTS[@]}"; do
-DENABLE_TESTING=YES
)
+
+ if [[ $(is_cross_tools_host ${host}) ]] ; then
+ cmake_options+=(
+ -DCMAKE_Swift_COMPILER:PATH="${HOST_SWIFTC}"
+ -DCMAKE_Swift_FLAGS="$(android_cross_swift_flags)"
+ )
+ android_cross_cmake_options cmake_options
+ else
+ cmake_options+=(
+ -DCMAKE_C_COMPILER:PATH="${LLVM_BIN}/clang"
+ -DCMAKE_CXX_COMPILER:PATH="${LLVM_BIN}/clang++"
+ -DCMAKE_Swift_COMPILER:PATH="$(build_directory_bin ${LOCAL_HOST} swift)/swiftc"
+ )
+ fi
+
+ if [[ "${CROSS_COMPILE_HOSTS}" && "${host}" == "${LOCAL_HOST}" ]] ; then
+ skip_configure_and_build ${build_dir}
+ fi
;;
esac
@@ -2257,10 +2328,7 @@ for host in "${ALL_HOSTS[@]}"; do
cmake_options=(
${cmake_options[@]}
-DCMAKE_BUILD_TYPE:STRING=${FOUNDATION_BUILD_TYPE}
- -DCMAKE_C_COMPILER:PATH=${LLVM_BIN}/clang
- -DCMAKE_CXX_COMPILER:PATH=${LLVM_BIN}/clang++
-DCMAKE_SWIFT_COMPILER:PATH=${SWIFTC_BIN}
- -DCMAKE_Swift_COMPILER:PATH=${SWIFTC_BIN}
-DCMAKE_INSTALL_PREFIX:PATH=$(get_host_install_prefix ${host})
${LIBICU_BUILD_ARGS[@]}
@@ -2273,6 +2341,23 @@ for host in "${ALL_HOSTS[@]}"; do
-DBUILD_SHARED_LIBS=$([[ ${product} == foundation_static ]] && echo "NO" || echo "YES")
)
+ if [[ $(is_cross_tools_host ${host}) ]] ; then
+ cmake_options+=(
+ -DCMAKE_Swift_COMPILER:PATH="${HOST_SWIFTC}"
+ -DCMAKE_Swift_FLAGS="$(android_cross_swift_flags)"
+ )
+ android_cross_cmake_options cmake_options
+ else
+ cmake_options+=(
+ -DCMAKE_C_COMPILER:PATH=${LLVM_BIN}/clang
+ -DCMAKE_CXX_COMPILER:PATH=${LLVM_BIN}/clang++
+ -DCMAKE_Swift_COMPILER:PATH=${SWIFTC_BIN}
+ )
+ fi
+
+ if [[ "${CROSS_COMPILE_HOSTS}" && "${host}" == "${LOCAL_HOST}" ]] ; then
+ skip_configure_and_build ${build_dir}
+ fi
;;
libdispatch|libdispatch_static)
LIBDISPATCH_BUILD_DIR=$(build_directory ${host} ${product})
@@ -2297,10 +2378,7 @@ for host in "${ALL_HOSTS[@]}"; do
-DENABLE_SWIFT=YES
${cmake_options[@]}
-DCMAKE_BUILD_TYPE:STRING="${LIBDISPATCH_BUILD_TYPE}"
- -DCMAKE_C_COMPILER:PATH="${LLVM_BIN}/clang"
- -DCMAKE_CXX_COMPILER:PATH="${LLVM_BIN}/clang++"
-DCMAKE_SWIFT_COMPILER:PATH="${SWIFTC_BIN}"
- -DCMAKE_Swift_COMPILER:PATH="${SWIFTC_BIN}"
-DCMAKE_INSTALL_PREFIX:PATH="$(get_host_install_prefix ${host})"
-DCMAKE_INSTALL_LIBDIR:PATH="lib"
@@ -2309,6 +2387,25 @@ for host in "${ALL_HOSTS[@]}"; do
-DENABLE_TESTING=YES
-DBUILD_SHARED_LIBS=$([[ ${product} == libdispatch_static ]] && echo "NO" || echo "YES")
)
+
+ if [[ $(is_cross_tools_host ${host}) ]] ; then
+ cmake_options+=(
+ -DCMAKE_Swift_COMPILER:PATH="${HOST_SWIFTC}"
+ -DCMAKE_Swift_FLAGS="$(android_cross_swift_flags)"
+ )
+ android_cross_cmake_options cmake_options
+ build_targets=(swiftDispatch)
+ else
+ cmake_options+=(
+ -DCMAKE_C_COMPILER:PATH="${LLVM_BIN}/clang"
+ -DCMAKE_CXX_COMPILER:PATH="${LLVM_BIN}/clang++"
+ -DCMAKE_Swift_COMPILER:PATH="${SWIFTC_BIN}"
+ )
+ fi
+
+ if [[ "${CROSS_COMPILE_HOSTS}" && "${host}" == "${LOCAL_HOST}" ]] ; then
+ skip_configure_and_build ${build_dir}
+ fi
;;
esac
@@ -2446,6 +2539,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
@@ -2903,9 +2998,13 @@ for host in "${ALL_HOSTS[@]}"; do
fi
if [[ "${LLVM_INSTALL_COMPONENTS}" == "all" ]]; then
INSTALL_TARGETS=install
+ else
+ if [[ ("${CROSS_COMPILE_HOSTS}" && "${host}" == "${LOCAL_HOST}") ]] ; then
+ continue
else
INSTALL_TARGETS=install-$(echo ${LLVM_INSTALL_COMPONENTS} | sed -E 's/;/ install-/g')
fi
+ fi
;;
libcxx)
if [[ -z "${INSTALL_LIBCXX}" ]] ; then
@@ -2917,13 +3052,24 @@ for host in "${ALL_HOSTS[@]}"; do
if [[ -z "${INSTALL_SWIFT}" ]] ; then
continue
fi
+ if [[ ("${CROSS_COMPILE_HOSTS}" && "${host}" == "${LOCAL_HOST}") ]] ; then
+ continue
+ else
INSTALL_TARGETS=install-swift-components
+ fi
;;
llbuild)
- if [[ -z "${INSTALL_LLBUILD}" ]] ; then
+ if [[ -z "${INSTALL_LLBUILD}" || ("${CROSS_COMPILE_HOSTS}" && "${host}" == "${LOCAL_HOST}") ]] ; then
continue
fi
- INSTALL_TARGETS="install-swift-build-tool install-libllbuildSwift"
+ INSTALL_TARGETS="install-libllbuildSwift"
+ rm @TERMUX_PREFIX@/lib/swift/android/lib{dispatch,BlocksRuntime}.so
+ 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)
@@ -2937,7 +3040,7 @@ for host in "${ALL_HOSTS[@]}"; do
INSTALL_TARGETS="install-distribution"
;;
xctest)
- if [[ -z "${INSTALL_XCTEST}" ]] ; then
+ if [[ -z "${INSTALL_XCTEST}" || ("${CROSS_COMPILE_HOSTS}" && "${host}" == "${LOCAL_HOST}") ]] ; then
continue
fi
if [[ -z "${INSTALL_DESTDIR}" ]] ; then
@@ -2961,7 +3064,7 @@ for host in "${ALL_HOSTS[@]}"; do
continue
fi
- if [[ -z "${INSTALL_FOUNDATION}" ]] ; then
+ if [[ -z "${INSTALL_FOUNDATION}" || ("${CROSS_COMPILE_HOSTS}" && "${host}" == "${LOCAL_HOST}") ]] ; then
continue
fi
@@ -2972,7 +3075,7 @@ for host in "${ALL_HOSTS[@]}"; do
;;
libdispatch|libdispatch_static)
- if [[ -z "${INSTALL_LIBDISPATCH}" ]] ; then
+ if [[ -z "${INSTALL_LIBDISPATCH}" || ("${CROSS_COMPILE_HOSTS}" && "${host}" == "${LOCAL_HOST}") ]] ; then
continue
fi
diff --git a/swift/utils/swift_build_support/swift_build_support/products/swiftpm.py b/swift/utils/swift_build_support/swift_build_support/products/swiftpm.py
index 475483618f1..2bea230012b 100644
--- a/swift/utils/swift_build_support/swift_build_support/products/swiftpm.py

View File

@ -2,8 +2,44 @@ 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
@@ -1430,6 +1430,26 @@ function android_cross_swift_flags() {
echo -n "${TERMUX_SWIFT_FLAGS}"
@@ -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() {
@ -29,3 +65,148 @@ index b1d060328bc..218c9215260 100755
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)

View File

@ -0,0 +1,133 @@
commit 32d341e244d4a56185ed04c60542250b5b5047e9
Date: Thu Jul 16 17:23:18 2020 +0530
[build] extend support for building with a prebuilt toolchain to the corelibs and llbuild
diff --git a/swift/utils/build-script-impl b/swift/utils/build-script-impl
index 7f39ff97459..af310ec8cbf 100755
--- a/swift/utils/build-script-impl
+++ b/swift/utils/build-script-impl
@@ -1604,6 +1604,18 @@ for host in "${ALL_HOSTS[@]}"; do
)
fi
+ if [[ "${NATIVE_CLANG_TOOLS_PATH}" ]] ; then
+ CLANG_BIN="${NATIVE_CLANG_TOOLS_PATH}"
+ else
+ CLANG_BIN="$(build_directory_bin ${LOCAL_HOST} llvm)"
+ fi
+
+ if [[ "${NATIVE_SWIFT_TOOLS_PATH}" ]] ; then
+ SWIFTC_BIN="${NATIVE_SWIFT_TOOLS_PATH}/swiftc"
+ else
+ SWIFTC_BIN="$(build_directory_bin ${LOCAL_HOST} swift)/swiftc"
+ fi
+
for product in "${PRODUCTS[@]}"; do
# Check if we should perform this action.
tmp_product=${product}
@@ -2066,7 +2078,7 @@ for host in "${ALL_HOSTS[@]}"; do
-DCMAKE_C_FLAGS="$(llvm_c_flags ${host})"
-DCMAKE_CXX_FLAGS="$(llvm_c_flags ${host})"
-DCMAKE_BUILD_TYPE:STRING="${LLDB_BUILD_TYPE}"
- -DLLDB_SWIFTC:PATH="$(build_directory ${LOCAL_HOST} swift)/bin/swiftc"
+ -DLLDB_SWIFTC:PATH=${SWIFTC_BIN}
-DLLDB_SWIFT_LIBS:PATH="$(build_directory ${LOCAL_HOST} swift)/lib/swift"
-DCMAKE_INSTALL_PREFIX:PATH="$(get_host_install_prefix ${host})"
-DLLDB_FRAMEWORK_INSTALL_DIR="$(get_host_install_prefix ${host})../System/Library/PrivateFrameworks"
@@ -2100,15 +2112,17 @@ for host in "${ALL_HOSTS[@]}"; do
"${cmake_options[@]}"
-DCMAKE_BUILD_TYPE:STRING="${LLBUILD_BUILD_TYPE}"
+ -DCMAKE_C_COMPILER:PATH="${CLANG_BIN}/clang"
+ -DCMAKE_CXX_COMPILER:PATH="${CLANG_BIN}/clang++"
-DCMAKE_INSTALL_PREFIX:PATH="$(get_host_install_prefix ${host})"
- -DCMAKE_Swift_COMPILER:PATH="$(build_directory_bin ${LOCAL_HOST} swift)/swiftc"
+ -DCMAKE_Swift_COMPILER:PATH=${SWIFTC_BIN}
-DLLBUILD_ENABLE_ASSERTIONS:BOOL=$(true_false "${LLBUILD_ENABLE_ASSERTIONS}")
-DLLBUILD_SUPPORT_BINDINGS:=Swift
-DLIT_EXECUTABLE:PATH="${LLVM_SOURCE_DIR}/utils/lit/lit.py"
-DFILECHECK_EXECUTABLE:PATH="$(build_directory_bin ${LOCAL_HOST} llvm)/FileCheck"
- -DSWIFTC_EXECUTABLE:PATH="$(build_directory_bin ${LOCAL_HOST} swift)/swiftc"
+ -DSWIFTC_EXECUTABLE:PATH=${SWIFTC_BIN}
-DFOUNDATION_BUILD_DIR:PATH="$(build_directory ${host} foundation)"
-DLIBDISPATCH_BUILD_DIR:PATH="$(build_directory ${host} libdispatch)"
-DLIBDISPATCH_SOURCE_DIR:PATH="${LIBDISPATCH_SOURCE_DIR}"
@@ -2132,7 +2146,6 @@ for host in "${ALL_HOSTS[@]}"; do
fi
;;
xctest)
- SWIFTC_BIN="$(build_directory_bin ${LOCAL_HOST} swift)/swiftc"
XCTEST_BUILD_DIR=$(build_directory ${host} xctest)
FOUNDATION_BUILD_DIR=$(build_directory ${host} foundation)
SWIFT_BUILD_DIR=$(build_directory ${host} swift)
@@ -2170,14 +2183,12 @@ for host in "${ALL_HOSTS[@]}"; do
echo "Cleaning the XCTest build directory"
call rm -rf "${XCTEST_BUILD_DIR}"
- LLVM_BIN="$(build_directory_bin ${LOCAL_HOST} llvm)"
-
cmake_options=(
${cmake_options[@]}
-DCMAKE_BUILD_TYPE:STRING="${XCTEST_BUILD_TYPE}"
- -DCMAKE_C_COMPILER:PATH="${LLVM_BIN}/clang"
- -DCMAKE_CXX_COMPILER:PATH="${LLVM_BIN}/clang++"
- -DCMAKE_Swift_COMPILER:PATH="$(build_directory_bin ${LOCAL_HOST} swift)/swiftc"
+ -DCMAKE_C_COMPILER:PATH="${CLANG_BIN}/clang"
+ -DCMAKE_CXX_COMPILER:PATH="${CLANG_BIN}/clang++"
+ -DCMAKE_Swift_COMPILER:PATH=${SWIFTC_BIN}
-DCMAKE_INSTALL_PREFIX:PATH="$(get_host_install_prefix ${host})"
-DCMAKE_INSTALL_LIBDIR:PATH="lib"
@@ -2188,7 +2199,7 @@ for host in "${ALL_HOSTS[@]}"; do
-DXCTEST_PATH_TO_LIBDISPATCH_SOURCE:PATH=${LIBDISPATCH_SOURCE_DIR}
-DXCTEST_PATH_TO_LIBDISPATCH_BUILD:PATH=$(build_directory ${host} libdispatch)
-DXCTEST_PATH_TO_FOUNDATION_BUILD:PATH=${FOUNDATION_BUILD_DIR}
- -DCMAKE_SWIFT_COMPILER:PATH="$(build_directory_bin ${LOCAL_HOST} swift)/swiftc"
+ -DCMAKE_SWIFT_COMPILER:PATH=${SWIFTC_BIN}
-DCMAKE_PREFIX_PATH:PATH=$(build_directory ${host} llvm)
-DENABLE_TESTING=YES
@@ -2203,9 +2214,6 @@ for host in "${ALL_HOSTS[@]}"; do
# is not yet built at this point.
XCTEST_BUILD_DIR=$(build_directory ${host} xctest)
- SWIFTC_BIN="$(build_directory_bin ${LOCAL_HOST} swift)/swiftc"
- LLVM_BIN="$(build_directory_bin ${LOCAL_HOST} llvm)"
-
if [[ ${host} == "macosx"* ]]; then
echo "Skipping Foundation on OS X -- use the Xcode project instead"
continue
@@ -2257,8 +2265,8 @@ for host in "${ALL_HOSTS[@]}"; do
cmake_options=(
${cmake_options[@]}
-DCMAKE_BUILD_TYPE:STRING=${FOUNDATION_BUILD_TYPE}
- -DCMAKE_C_COMPILER:PATH=${LLVM_BIN}/clang
- -DCMAKE_CXX_COMPILER:PATH=${LLVM_BIN}/clang++
+ -DCMAKE_C_COMPILER:PATH=${CLANG_BIN}/clang
+ -DCMAKE_CXX_COMPILER:PATH=${CLANG_BIN}/clang++
-DCMAKE_SWIFT_COMPILER:PATH=${SWIFTC_BIN}
-DCMAKE_Swift_COMPILER:PATH=${SWIFTC_BIN}
-DCMAKE_INSTALL_PREFIX:PATH=$(get_host_install_prefix ${host})
@@ -2277,8 +2285,6 @@ for host in "${ALL_HOSTS[@]}"; do
libdispatch|libdispatch_static)
LIBDISPATCH_BUILD_DIR=$(build_directory ${host} ${product})
SWIFT_BUILD_PATH="$(build_directory ${host} swift)"
- SWIFTC_BIN="$(build_directory_bin ${LOCAL_HOST} swift)/swiftc"
- LLVM_BIN="$(build_directory_bin ${LOCAL_HOST} llvm)"
case "${host}" in
macosx-*)
@@ -2297,8 +2303,8 @@ for host in "${ALL_HOSTS[@]}"; do
-DENABLE_SWIFT=YES
${cmake_options[@]}
-DCMAKE_BUILD_TYPE:STRING="${LIBDISPATCH_BUILD_TYPE}"
- -DCMAKE_C_COMPILER:PATH="${LLVM_BIN}/clang"
- -DCMAKE_CXX_COMPILER:PATH="${LLVM_BIN}/clang++"
+ -DCMAKE_C_COMPILER:PATH="${CLANG_BIN}/clang"
+ -DCMAKE_CXX_COMPILER:PATH="${CLANG_BIN}/clang++"
-DCMAKE_SWIFT_COMPILER:PATH="${SWIFTC_BIN}"
-DCMAKE_Swift_COMPILER:PATH="${SWIFTC_BIN}"
-DCMAKE_INSTALL_PREFIX:PATH="$(get_host_install_prefix ${host})"