swift: add x86_64 package and refactor with upstreamed and submitted patches
This commit is contained in:
parent
0c37a6699c
commit
7547e0d9f8
@ -3,14 +3,14 @@ TERMUX_PKG_DESCRIPTION="Swift is a high-performance system programming language"
|
||||
TERMUX_PKG_LICENSE="Apache-2.0, NCSA"
|
||||
TERMUX_PKG_MAINTAINER="@buttaface"
|
||||
TERMUX_PKG_VERSION=5.3
|
||||
TERMUX_PKG_REVISION=2
|
||||
TERMUX_PKG_REVISION=3
|
||||
SWIFT_RELEASE="RELEASE"
|
||||
TERMUX_PKG_SRCURL=https://github.com/apple/swift/archive/swift-$TERMUX_PKG_VERSION-$SWIFT_RELEASE.tar.gz
|
||||
TERMUX_PKG_SHA256=f9e5bd81441c4ec13dd9ea290e2d7b8fe9b30ef66ad68947481022ea5179f83a
|
||||
TERMUX_PKG_HOSTBUILD=true
|
||||
TERMUX_PKG_DEPENDS="binutils-gold, clang, libc++, ndk-sysroot, libandroid-glob, libandroid-spawn, libcurl, libicu, libicu-static, libsqlite, libuuid, libxml2, libdispatch, llbuild"
|
||||
TERMUX_PKG_BUILD_DEPENDS="cmake, ninja, perl, pkg-config, python2, rsync"
|
||||
TERMUX_PKG_BLACKLISTED_ARCHES="i686, x86_64"
|
||||
TERMUX_PKG_BLACKLISTED_ARCHES="aarch64, arm, i686"
|
||||
TERMUX_PKG_NO_STATICSPLIT=true
|
||||
|
||||
SWIFT_COMPONENTS="autolink-driver;compiler;clang-resource-dir-symlink;swift-remote-mirror;parser-lib;license;sourcekit-inproc;stdlib;sdk-overlay"
|
||||
@ -121,14 +121,14 @@ termux_step_make() {
|
||||
export TERMUX_SWIFT_FLAGS="$TERMUX_SWIFTPM_FLAGS -resource-dir \
|
||||
$TERMUX_PKG_BUILDDIR/swift-android-$SWIFT_ARCH/lib/swift"
|
||||
export HOST_SWIFTC="$SWIFT_BINDIR/swiftc"
|
||||
SWIFT_BUILD_FLAGS="$SWIFT_BUILD_FLAGS --android --android-ndk $TERMUX_STANDALONE_TOOLCHAIN
|
||||
--android-arch $SWIFT_ARCH --android-api-level $TERMUX_PKG_API_LEVEL
|
||||
--android-icu-uc $TERMUX_PREFIX/lib/libicuuc.so
|
||||
SWIFT_BUILD_FLAGS="$SWIFT_BUILD_FLAGS --android
|
||||
--android-ndk $TERMUX_STANDALONE_TOOLCHAIN --android-arch $SWIFT_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 --build-toolchain-only
|
||||
--skip-local-build --skip-local-host-install --build-runtime-with-host-compiler
|
||||
--skip-local-build --skip-local-host-install
|
||||
--cross-compile-hosts=android-$SWIFT_ARCH --cross-compile-deps-path=$TERMUX_PREFIX
|
||||
--native-swift-tools-path=$SWIFT_BINDIR
|
||||
--native-clang-tools-path=$TERMUX_STANDALONE_TOOLCHAIN/bin"
|
||||
|
65
packages/swift/swift-armv7.patch
Normal file
65
packages/swift/swift-armv7.patch
Normal file
@ -0,0 +1,65 @@
|
||||
commit f7576a7bef5ca33c5598ad6b63a37f6d4c69aa98
|
||||
Date: Fri, 2 Oct 2020 14:03:49 +0530
|
||||
Subject: [android] Add support for building the toolchain for ARMv7
|
||||
|
||||
diff --git a/swift/cmake/modules/AddSwift.cmake b/swift/cmake/modules/AddSwift.cmake
|
||||
index ec61d2abb836..0b9ce10842ac 100644
|
||||
--- a/swift/cmake/modules/AddSwift.cmake
|
||||
+++ b/swift/cmake/modules/AddSwift.cmake
|
||||
@@ -291,6 +291,15 @@ function(_add_host_variant_c_compile_flags target)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
+ # The LLVM backend is built with these defines on most 32-bit platforms,
|
||||
+ # llvm/llvm-project@66395c9, which can cause incompatibilities with the Swift
|
||||
+ # frontend if not built the same way.
|
||||
+ if("${CFLAGS_ARCH}" MATCHES "armv6|armv7|i686" AND
|
||||
+ NOT (CFLAGS_SDK STREQUAL ANDROID AND SWIFT_ANDROID_API_LEVEL LESS 24))
|
||||
+ list(APPEND result
|
||||
+ "-D_LARGEFILE_SOURCE"
|
||||
+ "-D_FILE_OFFSET_BITS=64")
|
||||
+ endif()
|
||||
set("${CFLAGS_RESULT_VAR_NAME}" "${result}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
diff --git a/swift/lib/ClangImporter/ImportType.cpp b/swift/lib/ClangImporter/ImportType.cpp
|
||||
index f58dbb837e5d..70bd70dff9ac 100644
|
||||
--- a/swift/lib/ClangImporter/ImportType.cpp
|
||||
+++ b/swift/lib/ClangImporter/ImportType.cpp
|
||||
@@ -556,7 +556,7 @@ namespace {
|
||||
if (size > 4096)
|
||||
return Type();
|
||||
|
||||
- SmallVector<TupleTypeElt, 8> elts{size, elementType};
|
||||
+ SmallVector<TupleTypeElt, 8> elts{static_cast<size_t>(size), elementType};
|
||||
return TupleType::get(elts, elementType->getASTContext());
|
||||
}
|
||||
|
||||
diff --git a/swift/stdlib/public/runtime/Float16Support.cpp b/swift/stdlib/public/runtime/Float16Support.cpp
|
||||
index d7377400ba0b..9d8c4940054d 100644
|
||||
--- a/swift/stdlib/public/runtime/Float16Support.cpp
|
||||
+++ b/swift/stdlib/public/runtime/Float16Support.cpp
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
// Android NDK <r21 do not provide `__aeabi_d2h` in the compiler runtime,
|
||||
// provide shims in that case.
|
||||
-#if (defined(ANDROID) && defined(__ARM_ARCH_7A__) && defined(__ARM_EABI__)) || \
|
||||
+#if (defined(__ANDROID__) && defined(__ARM_ARCH_7A__) && defined(__ARM_EABI__)) || \
|
||||
((defined(__i686__) || defined(__x86_64__)) && !defined(__APPLE__))
|
||||
|
||||
#include "../SwiftShims/Visibility.h"
|
||||
diff --git a/swift/utils/build-script-impl b/swift/utils/build-script-impl
|
||||
index 2bb99c886a66..1977b72fd995 100755
|
||||
--- a/swift/utils/build-script-impl
|
||||
+++ b/swift/utils/build-script-impl
|
||||
@@ -454,6 +454,10 @@ function set_build_options_for_host() {
|
||||
SWIFT_HOST_TRIPLE="aarch64-unknown-linux-android"
|
||||
llvm_target_arch="AArch64"
|
||||
;;
|
||||
+ android-armv7)
|
||||
+ SWIFT_HOST_TRIPLE="armv7-unknown-linux-androideabi"
|
||||
+ llvm_target_arch="ARM"
|
||||
+ ;;
|
||||
linux-armv6)
|
||||
SWIFT_HOST_TRIPLE="armv6-unknown-linux-gnueabihf"
|
||||
llvm_target_arch="ARM"
|
@ -2,13 +2,15 @@ diff --git a/swift/utils/build-script b/swift/utils/build-script
|
||||
index b1d060328bc..218c9215260 100755
|
||||
--- a/swift/utils/build-script
|
||||
+++ b/swift/utils/build-script
|
||||
@@ -799,8 +807,7 @@
|
||||
self._execute_install_action(host_target, product_class)
|
||||
@@ -799,8 +807,9 @@
|
||||
self._execute_merged_host_lipo_core_action()
|
||||
|
||||
# Non-build-script-impl products...
|
||||
- # Note: currently only supports building for the host.
|
||||
- for host_target in [self.args.host_target]:
|
||||
+ for host_target in [tgt.name for tgt in all_hosts if StdlibDeploymentTarget.Android.contains(tgt.name)]:
|
||||
+ for host_target in all_host_names:
|
||||
+ if self.args.skip_local_build and host_target == self.args.host_target:
|
||||
+ continue
|
||||
for product_class in product_classes:
|
||||
if product_class.is_build_script_impl_product():
|
||||
continue
|
||||
@ -31,26 +33,20 @@ diff --git a/swift/utils/swift_build_support/swift_build_support/products/swiftp
|
||||
index 475483618f1..2bea230012b 100644
|
||||
--- a/swift/utils/swift_build_support/swift_build_support/products/swiftpm.py
|
||||
+++ b/swift/utils/swift_build_support/swift_build_support/products/swiftpm.py
|
||||
@@ -31,8 +31,11 @@ class SwiftPM(product.Product):
|
||||
def run_bootstrap_script(self, action, host_target, additional_params=[]):
|
||||
script_path = os.path.join(
|
||||
self.source_dir, 'Utilities', 'bootstrap')
|
||||
- toolchain_path = self.install_toolchain_path(host_target)
|
||||
- swiftc = os.path.join(toolchain_path, "bin", "swiftc")
|
||||
+ if os.getenv("HOST_SWIFTC"):
|
||||
+ swiftc = os.getenv("HOST_SWIFTC")
|
||||
+ else:
|
||||
+ toolchain_path = self.install_toolchain_path(host_target)
|
||||
+ swiftc = os.path.join(toolchain_path, "bin", "swiftc")
|
||||
@@ -56,6 +56,7 @@ class SwiftPM(product.Product):
|
||||
|
||||
# FIXME: We require llbuild build directory in order to build. Is
|
||||
# there a better way to get this?
|
||||
# Pass Cross compile host info
|
||||
if self.has_cross_compile_hosts(self.args):
|
||||
+ helper_cmd += ['--skip-cmake-bootstrap']
|
||||
helper_cmd += ['--cross-compile-hosts']
|
||||
for cross_compile_host in self.args.cross_compile_hosts:
|
||||
helper_cmd += [cross_compile_host]
|
||||
@@ -83,7 +86,7 @@ class SwiftPM(product.Product):
|
||||
@classmethod
|
||||
def get_install_destdir(self, args, host_target, build_dir):
|
||||
install_destdir = args.install_destdir
|
||||
- if self.has_cross_compile_hosts(args):
|
||||
+ if self.has_cross_compile_hosts(args) and not os.getenv("HOST_SWIFTC"):
|
||||
+ if False:
|
||||
build_root = os.path.dirname(build_dir)
|
||||
install_destdir = '%s/intermediate-install/%s' % (build_root, host_target)
|
||||
return install_destdir
|
||||
|
@ -15,27 +15,6 @@ diff --git a/swift/cmake/modules/AddSwift.cmake b/swift/cmake/modules/AddSwift.c
|
||||
index b40bd4d881e..8c51c6b6857 100644
|
||||
--- a/swift/cmake/modules/AddSwift.cmake
|
||||
+++ b/swift/cmake/modules/AddSwift.cmake
|
||||
@@ -123,6 +123,10 @@ function(_add_variant_c_compile_link_flags)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
+ if("${CFLAGS_SDK}" STREQUAL "ANDROID")
|
||||
+ set(DEPLOYMENT_VERSION "${SWIFT_SDK_${CFLAGS_SDK}_DEPLOYMENT_VERSION}")
|
||||
+ endif()
|
||||
+
|
||||
# MSVC, clang-cl, gcc don't understand -target.
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "^Clang|AppleClang$" AND
|
||||
NOT SWIFT_COMPILER_IS_MSVC_LIKE)
|
||||
@@ -351,6 +351,9 @@ function(_add_host_variant_c_compile_flags)
|
||||
list(APPEND result "SHELL:${CMAKE_INCLUDE_SYSTEM_FLAG_C}${path}")
|
||||
endforeach()
|
||||
list(APPEND result "-D__ANDROID_API__=${SWIFT_ANDROID_API_LEVEL}")
|
||||
+ if(${CFLAGS_ARCH} STREQUAL armv7)
|
||||
+ list(APPEND result "-D_FILE_OFFSET_BITS=64")
|
||||
+ endif()
|
||||
endif()
|
||||
|
||||
if("${CFLAGS_SDK}" STREQUAL "LINUX")
|
||||
@@ -480,10 +480,10 @@ function(_add_variant_link_flags)
|
||||
list(APPEND library_search_directories
|
||||
${CMAKE_BINARY_DIR}/winsdk_lib_${LFLAGS_ARCH}_symlinks)
|
||||
@ -61,62 +40,6 @@ index b40bd4d881e..8c51c6b6857 100644
|
||||
swift_android_lib_for_arch(${LFLAGS_ARCH} ${LFLAGS_ARCH}_LIB)
|
||||
foreach(path IN LISTS ${LFLAGS_ARCH}_LIB)
|
||||
list(APPEND library_search_directories ${path})
|
||||
diff --git a/swift/cmake/modules/SwiftAndroidSupport.cmake b/swift/cmake/modules/SwiftAndroidSupport.cmake
|
||||
index 9379031947d..91cecf46a37 100644
|
||||
--- a/swift/cmake/modules/SwiftAndroidSupport.cmake
|
||||
+++ b/swift/cmake/modules/SwiftAndroidSupport.cmake
|
||||
@@ -1,8 +1,7 @@
|
||||
function(swift_android_libcxx_include_paths var)
|
||||
if(NOT "${SWIFT_ANDROID_NDK_PATH}" STREQUAL "")
|
||||
set(${var}
|
||||
- "${SWIFT_ANDROID_NDK_PATH}/sources/cxx-stl/llvm-libc++/include"
|
||||
- "${SWIFT_ANDROID_NDK_PATH}/sources/cxx-stl/llvm-libc++abi/include"
|
||||
+ "${SWIFT_ANDROID_NDK_PATH}/sysroot/usr/include/c++/v1"
|
||||
PARENT_SCOPE)
|
||||
elseif(NOT "${SWIFT_ANDROID_NATIVE_SYSROOT}" STREQUAL "")
|
||||
set(${var}
|
||||
@@ -89,7 +88,7 @@ function(swift_android_cxx_libraries_for_arch arch libraries_var_name)
|
||||
message(SEND_ERROR "unknown architecture (${arch}) when cross-compiling for Android")
|
||||
endif()
|
||||
|
||||
- set(android_libcxx_path "${SWIFT_ANDROID_NDK_PATH}/sources/cxx-stl/llvm-libc++/libs/${cxx_arch}")
|
||||
+ set(android_libcxx_path "${SWIFT_ANDROID_NDK_PATH}/sysroot/usr/lib/${SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE}")
|
||||
list(APPEND link_libraries ${android_libcxx_path}/libc++abi.a
|
||||
${android_libcxx_path}/libc++_shared.so)
|
||||
elseif(NOT "${SWIFT_ANDROID_NATIVE_SYSROOT}" STREQUAL "")
|
||||
diff --git a/swift/cmake/modules/SwiftConfigureSDK.cmake b/swift/cmake/modules/SwiftConfigureSDK.cmake
|
||||
index 3a87bfcd80b..89e9827db6c 100644
|
||||
--- a/swift/cmake/modules/SwiftConfigureSDK.cmake
|
||||
+++ b/swift/cmake/modules/SwiftConfigureSDK.cmake
|
||||
@@ -285,7 +285,7 @@ macro(configure_sdk_unix name architectures)
|
||||
set(SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE "arm-linux-androideabi")
|
||||
set(SWIFT_SDK_ANDROID_ARCH_${arch}_ALT_SPELLING "arm")
|
||||
if(NOT "${SWIFT_ANDROID_NDK_PATH}" STREQUAL "")
|
||||
- set(SWIFT_SDK_ANDROID_ARCH_${arch}_PATH "${SWIFT_ANDROID_NDK_PATH}/platforms/android-${SWIFT_ANDROID_API_LEVEL}/arch-arm")
|
||||
+ set(SWIFT_SDK_ANDROID_ARCH_${arch}_PATH "${SWIFT_ANDROID_NDK_PATH}/sysroot")
|
||||
elseif(NOT "${SWIFT_ANDROID_NATIVE_SYSROOT}" STREQUAL "")
|
||||
set(SWIFT_SDK_ANDROID_ARCH_${arch}_PATH "${SWIFT_ANDROID_NATIVE_SYSROOT}")
|
||||
else()
|
||||
@@ -298,7 +298,7 @@ macro(configure_sdk_unix name architectures)
|
||||
set(SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE "aarch64-linux-android")
|
||||
set(SWIFT_SDK_ANDROID_ARCH_${arch}_ALT_SPELLING "aarch64")
|
||||
if(NOT "${SWIFT_ANDROID_NDK_PATH}" STREQUAL "")
|
||||
- set(SWIFT_SDK_ANDROID_ARCH_${arch}_PATH "${SWIFT_ANDROID_NDK_PATH}/platforms/android-${SWIFT_ANDROID_API_LEVEL}/arch-arm64")
|
||||
+ set(SWIFT_SDK_ANDROID_ARCH_${arch}_PATH "${SWIFT_ANDROID_NDK_PATH}/sysroot")
|
||||
elseif(NOT "${SWIFT_ANDROID_NATIVE_SYSROOT}" STREQUAL "")
|
||||
set(SWIFT_SDK_ANDROID_ARCH_${arch}_PATH "${SWIFT_ANDROID_NATIVE_SYSROOT}")
|
||||
else()
|
||||
@@ -339,8 +339,9 @@ macro(configure_sdk_unix name architectures)
|
||||
"${SWIFT_ANDROID_NDK_PATH}/toolchains/x86_64-${SWIFT_ANDROID_NDK_GCC_VERSION}/prebuilt/${_swift_android_prebuilt_build}")
|
||||
else()
|
||||
set(SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_PREBUILT_PATH
|
||||
- "${SWIFT_ANDROID_NDK_PATH}/toolchains/${SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE}-${SWIFT_ANDROID_NDK_GCC_VERSION}/prebuilt/${_swift_android_prebuilt_build}")
|
||||
+ "${SWIFT_ANDROID_NDK_PATH}")
|
||||
endif()
|
||||
+ set(SWIFT_SDK_ANDROID_DEPLOYMENT_VERSION ${SWIFT_ANDROID_API_LEVEL})
|
||||
else()
|
||||
set(SWIFT_SDK_${prefix}_ARCH_${arch}_PATH "/" CACHE STRING "CMAKE_SYSROOT for ${prefix} ${arch}")
|
||||
|
||||
diff --git a/swift/lib/Driver/CMakeLists.txt b/swift/lib/Driver/CMakeLists.txt
|
||||
index 448f5044b70..e665dfcfefe 100644
|
||||
--- a/swift/lib/Driver/CMakeLists.txt
|
||||
@ -216,17 +139,6 @@ diff --git a/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake b/swift/stdlib/cmak
|
||||
index a2f682ece68..95e2c6e8a99 100644
|
||||
--- a/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake
|
||||
+++ b/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake
|
||||
@@ -85,6 +85,10 @@ function(_add_target_variant_c_compile_link_flags)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
+ if("${CFLAGS_SDK}" STREQUAL "ANDROID")
|
||||
+ set(DEPLOYMENT_VERSION "${SWIFT_SDK_${CFLAGS_SDK}_DEPLOYMENT_VERSION}")
|
||||
+ endif()
|
||||
+
|
||||
# MSVC, clang-cl, gcc don't understand -target.
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "^Clang|AppleClang$" AND
|
||||
NOT SWIFT_COMPILER_IS_MSVC_LIKE)
|
||||
@@ -359,11 +359,6 @@ function(_add_target_variant_link_flags)
|
||||
swift_android_cxx_libraries_for_arch(${LFLAGS_ARCH} cxx_link_libraries)
|
||||
list(APPEND link_libraries ${cxx_link_libraries})
|
||||
|
@ -1,13 +0,0 @@
|
||||
diff --git a/swift/lib/ClangImporter/ImportType.cpp b/swift/lib/ClangImporter/ImportType.cpp
|
||||
index 08238b491c2..7bafbbac38b 100644
|
||||
--- a/swift/lib/ClangImporter/ImportType.cpp
|
||||
+++ b/swift/lib/ClangImporter/ImportType.cpp
|
||||
@@ -506,7 +506,7 @@ namespace {
|
||||
if (size > 4096)
|
||||
return Type();
|
||||
|
||||
- SmallVector<TupleTypeElt, 8> elts{size, elementType};
|
||||
+ SmallVector<TupleTypeElt, 8> elts{static_cast<size_t>(size), elementType};
|
||||
return TupleType::get(elts, elementType->getASTContext());
|
||||
}
|
||||
|
85
packages/swift/swift-native-tools.patch
Normal file
85
packages/swift/swift-native-tools.patch
Normal file
@ -0,0 +1,85 @@
|
||||
commit 9ed67668564257c27e49ff7a07fac0b23f27ba85
|
||||
Date: Mon, 26 Oct 2020 23:13:22 +0530
|
||||
Subject: [build-script] Move --native-{clang,llvm,swift}-tools-path
|
||||
flags into the Python build-script
|
||||
|
||||
Also, fix two places where the LLVM path was wrongly employed to set up clang,
|
||||
and use the Swift path in install_toolchain_path().
|
||||
|
||||
diff --git a/swift/stdlib/CMakeLists.txt b/swift/stdlib/CMakeLists.txt
|
||||
index 81cad0966a1d..a0e3b138809f 100644
|
||||
--- a/swift/stdlib/CMakeLists.txt
|
||||
+++ b/swift/stdlib/CMakeLists.txt
|
||||
@@ -102,11 +102,11 @@ else()
|
||||
# If we use Clang-cl or MSVC, CMake provides default compiler and linker flags that are incompatible
|
||||
# with the frontend of Clang or Clang++.
|
||||
if(SWIFT_COMPILER_IS_MSVC_LIKE)
|
||||
- set(CMAKE_CXX_COMPILER "${SWIFT_NATIVE_LLVM_TOOLS_PATH}/clang-cl")
|
||||
- set(CMAKE_C_COMPILER "${SWIFT_NATIVE_LLVM_TOOLS_PATH}/clang-cl")
|
||||
+ set(CMAKE_CXX_COMPILER "${SWIFT_NATIVE_CLANG_TOOLS_PATH}/clang-cl")
|
||||
+ set(CMAKE_C_COMPILER "${SWIFT_NATIVE_CLANG_TOOLS_PATH}/clang-cl")
|
||||
else()
|
||||
- set(CMAKE_CXX_COMPILER "${SWIFT_NATIVE_LLVM_TOOLS_PATH}/clang++")
|
||||
- set(CMAKE_C_COMPILER "${SWIFT_NATIVE_LLVM_TOOLS_PATH}/clang")
|
||||
+ set(CMAKE_CXX_COMPILER "${SWIFT_NATIVE_CLANG_TOOLS_PATH}/clang++")
|
||||
+ set(CMAKE_C_COMPILER "${SWIFT_NATIVE_CLANG_TOOLS_PATH}/clang")
|
||||
endif()
|
||||
|
||||
if(CMAKE_C_COMPILER_LAUNCHER MATCHES ".*distcc")
|
||||
diff --git a/swift/utils/build-script b/swift/utils/build-script
|
||||
index 639f790fe354..9ccb8ef6e2dc 100755
|
||||
--- a/swift/utils/build-script
|
||||
+++ b/swift/utils/build-script
|
||||
@@ -704,6 +704,18 @@ class BuildScriptInvocation(object):
|
||||
impl_args += [
|
||||
"--host-libtool", toolchain.libtool,
|
||||
]
|
||||
+ if args.native_clang_tools_path is not None:
|
||||
+ impl_args += [
|
||||
+ "--native-clang-tools-path=%s" % args.native_clang_tools_path
|
||||
+ ]
|
||||
+ if args.native_llvm_tools_path is not None:
|
||||
+ impl_args += [
|
||||
+ "--native-llvm-tools-path=%s" % args.native_llvm_tools_path
|
||||
+ ]
|
||||
+ if args.native_swift_tools_path is not None:
|
||||
+ impl_args += [
|
||||
+ "--native-swift-tools-path=%s" % args.native_swift_tools_path
|
||||
+ ]
|
||||
|
||||
# If we have extra_swift_args, combine all of them together and then
|
||||
# add them as one command.
|
||||
diff --git a/swift/utils/build_swift/build_swift/driver_arguments.py b/swift/utils/build_swift/build_swift/driver_arguments.py
|
||||
index cb1c5c0b0e38..73fbd7c95e18 100644
|
||||
--- a/swift/utils/build_swift/build_swift/driver_arguments.py
|
||||
+++ b/swift/utils/build_swift/build_swift/driver_arguments.py
|
||||
@@ -374,6 +374,15 @@ def create_argument_parser():
|
||||
option('--host-cxx', store_path(executable=True),
|
||||
help='the absolute path to CXX, the "clang++" compiler for the '
|
||||
'host platform. Default is auto detected.')
|
||||
+ option('--native-swift-tools-path', store_path,
|
||||
+ help='the path to a directory that contains prebuilt Swift tools '
|
||||
+ 'that are executable on the host platform')
|
||||
+ option('--native-clang-tools-path', store_path,
|
||||
+ help='the path to a directory that contains prebuilt Clang tools '
|
||||
+ 'that are executable on the host platform')
|
||||
+ option('--native-llvm-tools-path', store_path,
|
||||
+ help='the path to a directory that contains prebuilt LLVM tools '
|
||||
+ 'that are executable on the host platform')
|
||||
option('--cmake-c-launcher', store_path(executable=True),
|
||||
default=os.environ.get('C_COMPILER_LAUNCHER', None),
|
||||
help='the absolute path to set CMAKE_C_COMPILER_LAUNCHER')
|
||||
diff --git a/swift/utils/swift_build_support/swift_build_support/products/product.py b/swift/utils/swift_build_support/swift_build_support/products/product.py
|
||||
index ba6f673bb6c9..001e2bf03083 100644
|
||||
--- a/swift/utils/swift_build_support/swift_build_support/products/product.py
|
||||
+++ b/swift/utils/swift_build_support/swift_build_support/products/product.py
|
||||
@@ -169,6 +169,9 @@ def install_toolchain_path(self, host_target):
|
||||
Returns the path to the toolchain that is being created as part of this
|
||||
build.
|
||||
"""
|
||||
+ if self.args.native_swift_tools_path is not None:
|
||||
+ return os.path.split(self.args.native_swift_tools_path)[0]
|
||||
+
|
||||
install_destdir = self.args.install_destdir
|
||||
if self.args.cross_compile_hosts:
|
||||
build_root = os.path.dirname(self.build_dir)
|
378
packages/swift/swift-ndk.patch
Normal file
378
packages/swift/swift-ndk.patch
Normal file
@ -0,0 +1,378 @@
|
||||
commit d42869c1e6fbb5caf87428662825840b2e70a19d
|
||||
Date: Thu, 29 Oct 2020 20:54:59 +0530
|
||||
Subject: [android] Move to the NDK's unified sysroot
|
||||
|
||||
Since the NDK is removing the platforms/ and sysroot/ directories in the next
|
||||
release, switch to the unified sysroot in toolchains/llvm/ and take advantage
|
||||
of a bunch of simplification that's now possible.
|
||||
|
||||
diff --git a/swift/cmake/modules/AddSwift.cmake b/swift/cmake/modules/AddSwift.cmake
|
||||
index 0e019d8d30..00e0b794e7 100644
|
||||
--- a/swift/cmake/modules/AddSwift.cmake
|
||||
+++ b/swift/cmake/modules/AddSwift.cmake
|
||||
@@ -123,6 +123,10 @@ function(_add_variant_c_compile_link_flags)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
+ if("${CFLAGS_SDK}" STREQUAL "ANDROID")
|
||||
+ set(DEPLOYMENT_VERSION ${SWIFT_ANDROID_API_LEVEL})
|
||||
+ endif()
|
||||
+
|
||||
# MSVC, clang-cl, gcc don't understand -target.
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "^Clang|AppleClang$" AND
|
||||
NOT SWIFT_COMPILER_IS_MSVC_LIKE)
|
||||
@@ -343,16 +343,6 @@ function(_add_host_variant_c_compile_flags)
|
||||
list(APPEND result -funwind-tables)
|
||||
endif()
|
||||
|
||||
- if("${CFLAGS_SDK}" STREQUAL "ANDROID")
|
||||
- list(APPEND result -nostdinc++)
|
||||
- swift_android_libcxx_include_paths(CFLAGS_CXX_INCLUDES)
|
||||
- swift_android_include_for_arch("${CFLAGS_ARCH}" "${CFLAGS_ARCH}_INCLUDE")
|
||||
- foreach(path IN LISTS CFLAGS_CXX_INCLUDES ${CFLAGS_ARCH}_INCLUDE)
|
||||
- list(APPEND result "SHELL:${CMAKE_INCLUDE_SYSTEM_FLAG_C}${path}")
|
||||
- endforeach()
|
||||
- list(APPEND result "-D__ANDROID_API__=${SWIFT_ANDROID_API_LEVEL}")
|
||||
- endif()
|
||||
-
|
||||
if("${CFLAGS_SDK}" STREQUAL "LINUX")
|
||||
if(${CFLAGS_ARCH} STREQUAL x86_64)
|
||||
# this is the minimum architecture that supports 16 byte CAS, which is necessary to avoid a dependency to libatomic
|
||||
@@ -441,11 +431,6 @@ function(_add_host_variant_link_flags)
|
||||
# link against the custom C++ library
|
||||
swift_android_cxx_libraries_for_arch(${LFLAGS_ARCH} cxx_link_libraries)
|
||||
list(APPEND link_libraries ${cxx_link_libraries})
|
||||
-
|
||||
- swift_android_lib_for_arch(${LFLAGS_ARCH} ${LFLAGS_ARCH}_LIB)
|
||||
- foreach(path IN LISTS ${LFLAGS_ARCH}_LIB)
|
||||
- list(APPEND library_search_directories ${path})
|
||||
- endforeach()
|
||||
else()
|
||||
# If lto is enabled, we need to add the object path flag so that the LTO code
|
||||
# generator leaves the intermediate object file in a place where it will not
|
||||
diff --git a/swift/cmake/modules/AddSwiftUnittests.cmake b/swift/cmake/modules/AddSwiftUnittests.cmake
|
||||
index e088997741..daaba3e026 100644
|
||||
--- a/swift/cmake/modules/AddSwiftUnittests.cmake
|
||||
+++ b/swift/cmake/modules/AddSwiftUnittests.cmake
|
||||
@@ -43,9 +43,6 @@ function(add_swift_unittest test_dirname)
|
||||
set_target_properties(${test_dirname} PROPERTIES
|
||||
BUILD_RPATH ${SWIFT_LIBRARY_OUTPUT_INTDIR}/swift/macosx)
|
||||
elseif("${SWIFT_HOST_VARIANT}" STREQUAL "android")
|
||||
- swift_android_lib_for_arch(${SWIFT_HOST_VARIANT_ARCH} android_system_libs)
|
||||
- set_property(TARGET "${test_dirname}" APPEND PROPERTY LINK_DIRECTORIES
|
||||
- "${android_system_libs}")
|
||||
set_property(TARGET "${test_dirname}" APPEND PROPERTY LINK_LIBRARIES "log")
|
||||
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64")
|
||||
diff --git a/swift/cmake/modules/SwiftAndroidSupport.cmake b/swift/cmake/modules/SwiftAndroidSupport.cmake
|
||||
index 9379031947..a8b0a48c7e 100644
|
||||
--- a/swift/cmake/modules/SwiftAndroidSupport.cmake
|
||||
+++ b/swift/cmake/modules/SwiftAndroidSupport.cmake
|
||||
@@ -1,72 +1,42 @@
|
||||
-function(swift_android_libcxx_include_paths var)
|
||||
- if(NOT "${SWIFT_ANDROID_NDK_PATH}" STREQUAL "")
|
||||
- set(${var}
|
||||
- "${SWIFT_ANDROID_NDK_PATH}/sources/cxx-stl/llvm-libc++/include"
|
||||
- "${SWIFT_ANDROID_NDK_PATH}/sources/cxx-stl/llvm-libc++abi/include"
|
||||
- PARENT_SCOPE)
|
||||
- elseif(NOT "${SWIFT_ANDROID_NATIVE_SYSROOT}" STREQUAL "")
|
||||
- set(${var}
|
||||
- "${SWIFT_ANDROID_NATIVE_SYSROOT}/usr/include/c++/v1"
|
||||
- PARENT_SCOPE)
|
||||
+function(swift_android_prebuilt_host_name prebuilt_var_name)
|
||||
+ # Get the prebuilt suffix to create the correct toolchain path when using the NDK
|
||||
+ if(CMAKE_HOST_SYSTEM_NAME STREQUAL Darwin)
|
||||
+ set(${prebuilt_var_name} darwin-x86_64 PARENT_SCOPE)
|
||||
+ elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL Linux)
|
||||
+ set(${prebuilt_var_name} linux-x86_64 PARENT_SCOPE)
|
||||
+ elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
|
||||
+ set(${prebuilt_var_name} Windows-x86_64 PARENT_SCOPE)
|
||||
else()
|
||||
- message(SEND_ERROR "Couldn't set libc++ include paths for Android")
|
||||
+ message(SEND_ERROR "cannot cross-compile to android from ${CMAKE_HOST_SYSTEM_NAME}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
-function(swift_android_include_for_arch arch var)
|
||||
- set(paths)
|
||||
+function(swift_android_sysroot sysroot_var_name)
|
||||
if(NOT "${SWIFT_ANDROID_NDK_PATH}" STREQUAL "")
|
||||
- list(APPEND paths
|
||||
- "${SWIFT_ANDROID_NDK_PATH}/sources/android/support/include"
|
||||
- "${SWIFT_ANDROID_NDK_PATH}/sysroot/usr/include"
|
||||
- "${SWIFT_ANDROID_NDK_PATH}/sysroot/usr/include/${SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE}")
|
||||
+ swift_android_prebuilt_host_name(prebuilt_build)
|
||||
+ set(${sysroot_var_name} "${SWIFT_ANDROID_NDK_PATH}/toolchains/llvm/prebuilt/${prebuilt_build}/sysroot" PARENT_SCOPE)
|
||||
elseif(NOT "${SWIFT_ANDROID_NATIVE_SYSROOT}" STREQUAL "")
|
||||
- list(APPEND paths
|
||||
- "${SWIFT_ANDROID_NATIVE_SYSROOT}/usr/include"
|
||||
- "${SWIFT_ANDROID_NATIVE_SYSROOT}/usr/include/${SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE}")
|
||||
+ set(${sysroot_var_name} "${SWIFT_ANDROID_NATIVE_SYSROOT}" PARENT_SCOPE)
|
||||
else()
|
||||
- message(SEND_ERROR "Couldn't set ${arch} include paths for Android")
|
||||
+ message(SEND_ERROR "Couldn't find Android sysroot")
|
||||
endif()
|
||||
- set(${var} ${paths} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
-function(swift_android_lib_for_arch arch var)
|
||||
- set(_prebuilt "${SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_PREBUILT_PATH}")
|
||||
- set(_host "${SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE}")
|
||||
-
|
||||
- set(paths)
|
||||
+function(swift_android_tools_path arch path_var_name)
|
||||
if(NOT "${SWIFT_ANDROID_NDK_PATH}" STREQUAL "")
|
||||
- if(arch STREQUAL armv7)
|
||||
- list(APPEND paths "${_prebuilt}/${_host}/lib/armv7-a")
|
||||
- elseif(arch STREQUAL aarch64)
|
||||
- list(APPEND paths "${_prebuilt}/${_host}/lib64")
|
||||
- elseif(arch STREQUAL i686)
|
||||
- list(APPEND paths "${_prebuilt}/${_host}/lib")
|
||||
- elseif(arch STREQUAL x86_64)
|
||||
- list(APPEND paths "${_prebuilt}/${_host}/lib64")
|
||||
+ swift_android_prebuilt_host_name(prebuilt_build)
|
||||
+ if("${arch}" STREQUAL "i686")
|
||||
+ set(ndk_prebuilt_path
|
||||
+ "${SWIFT_ANDROID_NDK_PATH}/toolchains/x86-${SWIFT_ANDROID_NDK_GCC_VERSION}/prebuilt/${prebuilt_build}")
|
||||
+ elseif("${arch}" STREQUAL "x86_64")
|
||||
+ set(ndk_prebuilt_path
|
||||
+ "${SWIFT_ANDROID_NDK_PATH}/toolchains/x86_64-${SWIFT_ANDROID_NDK_GCC_VERSION}/prebuilt/${prebuilt_build}")
|
||||
else()
|
||||
- message(SEND_ERROR "unknown architecture (${arch}) for android")
|
||||
+ set(ndk_prebuilt_path
|
||||
+ "${SWIFT_ANDROID_NDK_PATH}/toolchains/${SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE}-${SWIFT_ANDROID_NDK_GCC_VERSION}/prebuilt/${prebuilt_build}")
|
||||
endif()
|
||||
- list(APPEND paths "${_prebuilt}/lib/gcc/${_host}/${SWIFT_ANDROID_NDK_GCC_VERSION}.x")
|
||||
- elseif(NOT "${SWIFT_ANDROID_NATIVE_SYSROOT}" STREQUAL "")
|
||||
- list(APPEND paths "${SWIFT_ANDROID_NATIVE_SYSROOT}/usr/lib")
|
||||
- if("${arch}" MATCHES armv7)
|
||||
- list(APPEND paths "/system/lib")
|
||||
- elseif("${arch}" MATCHES aarch64)
|
||||
- list(APPEND paths "/system/lib64")
|
||||
- else()
|
||||
- message(SEND_ERROR "unknown architecture (${arch}) when compiling for Android host")
|
||||
- endif()
|
||||
- else()
|
||||
- message(SEND_ERROR "Couldn't set ${arch} library paths for Android")
|
||||
- endif()
|
||||
-
|
||||
- set(${var} ${paths} PARENT_SCOPE)
|
||||
-endfunction()
|
||||
|
||||
-function(swift_android_tools_path arch path_var_name)
|
||||
- if(NOT "${SWIFT_ANDROID_NDK_PATH}" STREQUAL "")
|
||||
- set(${path_var_name} "${SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_PREBUILT_PATH}/${SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE}/bin" PARENT_SCOPE)
|
||||
+ set(${path_var_name} "${ndk_prebuilt_path}/${SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE}/bin" PARENT_SCOPE)
|
||||
elseif(NOT "${SWIFT_ANDROID_NATIVE_SYSROOT}" STREQUAL "")
|
||||
set(${path_var_name} "${SWIFT_ANDROID_NATIVE_SYSROOT}/usr/bin" PARENT_SCOPE)
|
||||
else()
|
||||
@@ -77,19 +49,7 @@ endfunction ()
|
||||
function(swift_android_cxx_libraries_for_arch arch libraries_var_name)
|
||||
set(link_libraries)
|
||||
if(NOT "${SWIFT_ANDROID_NDK_PATH}" STREQUAL "")
|
||||
- if("${arch}" MATCHES armv7)
|
||||
- set(cxx_arch armeabi-v7a)
|
||||
- elseif("${arch}" MATCHES aarch64)
|
||||
- set(cxx_arch arm64-v8a)
|
||||
- elseif("${arch}" MATCHES i686)
|
||||
- set(cxx_arch x86)
|
||||
- elseif("${arch}" MATCHES x86_64)
|
||||
- set(cxx_arch x86_64)
|
||||
- else()
|
||||
- message(SEND_ERROR "unknown architecture (${arch}) when cross-compiling for Android")
|
||||
- endif()
|
||||
-
|
||||
- set(android_libcxx_path "${SWIFT_ANDROID_NDK_PATH}/sources/cxx-stl/llvm-libc++/libs/${cxx_arch}")
|
||||
+ set(android_libcxx_path "${SWIFT_SDK_ANDROID_ARCH_${arch}_PATH}/usr/lib/${SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE}")
|
||||
list(APPEND link_libraries ${android_libcxx_path}/libc++abi.a
|
||||
${android_libcxx_path}/libc++_shared.so)
|
||||
elseif(NOT "${SWIFT_ANDROID_NATIVE_SYSROOT}" STREQUAL "")
|
||||
diff --git a/swift/cmake/modules/SwiftConfigureSDK.cmake b/swift/cmake/modules/SwiftConfigureSDK.cmake
|
||||
index b55e6e6b98..a654794467 100644
|
||||
--- a/swift/cmake/modules/SwiftConfigureSDK.cmake
|
||||
+++ b/swift/cmake/modules/SwiftConfigureSDK.cmake
|
||||
@@ -55,12 +55,6 @@ function(_report_sdk prefix)
|
||||
if(NOT "${SWIFT_ANDROID_NATIVE_SYSROOT}" STREQUAL "")
|
||||
message(STATUS " Sysroot: ${SWIFT_ANDROID_NATIVE_SYSROOT}")
|
||||
endif()
|
||||
- foreach(arch ${SWIFT_SDK_${prefix}_ARCHITECTURES})
|
||||
- swift_android_include_for_arch(${arch} ${arch}_INCLUDE)
|
||||
- swift_android_lib_for_arch(${arch} ${arch}_LIB)
|
||||
- message(STATUS " ${arch} INCLUDE: ${${arch}_INCLUDE}")
|
||||
- message(STATUS " ${arch} LIB: ${${arch}_LIB}")
|
||||
- endforeach()
|
||||
else()
|
||||
foreach(arch ${SWIFT_SDK_${prefix}_ARCHITECTURES})
|
||||
message(STATUS " ${arch} Path: ${SWIFT_SDK_${prefix}_ARCH_${arch}_PATH}")
|
||||
@@ -271,76 +265,32 @@ macro(configure_sdk_unix name architectures)
|
||||
|
||||
foreach(arch ${architectures})
|
||||
if("${prefix}" STREQUAL "ANDROID")
|
||||
- if(NOT "${SWIFT_ANDROID_NDK_PATH}" STREQUAL "")
|
||||
- set(SWIFT_SDK_ANDROID_ARCH_${arch}_LIBC_INCLUDE_DIRECTORY "${SWIFT_ANDROID_NDK_PATH}/sysroot/usr/include" CACHE STRING "Path to C library headers")
|
||||
- set(SWIFT_SDK_ANDROID_ARCH_${arch}_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY "${SWIFT_ANDROID_NDK_PATH}/sysroot/usr/include" CACHE STRING "Path to C library architecture headers")
|
||||
- elseif(NOT "${SWIFT_ANDROID_NATIVE_SYSROOT}" STREQUAL "")
|
||||
- set(SWIFT_SDK_ANDROID_ARCH_${arch}_LIBC_INCLUDE_DIRECTORY "${SWIFT_ANDROID_NATIVE_SYSROOT}/usr/include" CACHE STRING "Path to C library headers")
|
||||
- set(SWIFT_SDK_ANDROID_ARCH_${arch}_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY "${SWIFT_ANDROID_NATIVE_SYSROOT}/usr/include" CACHE STRING "Path to C library architecture headers")
|
||||
- else()
|
||||
- message(SEND_ERROR "Couldn't find LIBC_INCLUDE_DIRECTORY for Android")
|
||||
- endif()
|
||||
+ swift_android_sysroot(android_sysroot)
|
||||
+ set(SWIFT_SDK_ANDROID_ARCH_${arch}_PATH "${android_sysroot}")
|
||||
+ set(SWIFT_SDK_ANDROID_ARCH_${arch}_LIBC_INCLUDE_DIRECTORY "${android_sysroot}/usr/include" CACHE STRING "Path to C library headers")
|
||||
+ set(SWIFT_SDK_ANDROID_ARCH_${arch}_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY "${android_sysroot}/usr/include" CACHE STRING "Path to C library architecture headers")
|
||||
|
||||
if("${arch}" STREQUAL "armv7")
|
||||
set(SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE "arm-linux-androideabi")
|
||||
set(SWIFT_SDK_ANDROID_ARCH_${arch}_ALT_SPELLING "arm")
|
||||
- if(NOT "${SWIFT_ANDROID_NDK_PATH}" STREQUAL "")
|
||||
- set(SWIFT_SDK_ANDROID_ARCH_${arch}_PATH "${SWIFT_ANDROID_NDK_PATH}/platforms/android-${SWIFT_ANDROID_API_LEVEL}/arch-arm")
|
||||
- elseif(NOT "${SWIFT_ANDROID_NATIVE_SYSROOT}" STREQUAL "")
|
||||
- set(SWIFT_SDK_ANDROID_ARCH_${arch}_PATH "${SWIFT_ANDROID_NATIVE_SYSROOT}")
|
||||
- else()
|
||||
- message(SEND_ERROR "Couldn't find SWIFT_SDK_ANDROID_ARCH_armv7_PATH")
|
||||
- endif()
|
||||
set(SWIFT_SDK_ANDROID_ARCH_${arch}_TRIPLE "armv7-none-linux-androideabi")
|
||||
# The Android ABI isn't part of the module triple.
|
||||
set(SWIFT_SDK_ANDROID_ARCH_${arch}_MODULE "armv7-none-linux-android")
|
||||
elseif("${arch}" STREQUAL "aarch64")
|
||||
set(SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE "aarch64-linux-android")
|
||||
set(SWIFT_SDK_ANDROID_ARCH_${arch}_ALT_SPELLING "aarch64")
|
||||
- if(NOT "${SWIFT_ANDROID_NDK_PATH}" STREQUAL "")
|
||||
- set(SWIFT_SDK_ANDROID_ARCH_${arch}_PATH "${SWIFT_ANDROID_NDK_PATH}/platforms/android-${SWIFT_ANDROID_API_LEVEL}/arch-arm64")
|
||||
- elseif(NOT "${SWIFT_ANDROID_NATIVE_SYSROOT}" STREQUAL "")
|
||||
- set(SWIFT_SDK_ANDROID_ARCH_${arch}_PATH "${SWIFT_ANDROID_NATIVE_SYSROOT}")
|
||||
- else()
|
||||
- message(SEND_ERROR "Couldn't find SWIFT_SDK_ANDROID_ARCH_aarch64_PATH")
|
||||
- endif()
|
||||
set(SWIFT_SDK_ANDROID_ARCH_${arch}_TRIPLE "aarch64-unknown-linux-android")
|
||||
elseif("${arch}" STREQUAL "i686")
|
||||
set(SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE "i686-linux-android")
|
||||
set(SWIFT_SDK_ANDROID_ARCH_${arch}_ALT_SPELLING "i686")
|
||||
- set(SWIFT_SDK_ANDROID_ARCH_${arch}_PATH "${SWIFT_ANDROID_NDK_PATH}/platforms/android-${SWIFT_ANDROID_API_LEVEL}/arch-x86")
|
||||
set(SWIFT_SDK_ANDROID_ARCH_${arch}_TRIPLE "i686-unknown-linux-android")
|
||||
elseif("${arch}" STREQUAL "x86_64")
|
||||
set(SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE "x86_64-linux-android")
|
||||
set(SWIFT_SDK_ANDROID_ARCH_${arch}_ALT_SPELLING "x86_64")
|
||||
- set(SWIFT_SDK_ANDROID_ARCH_${arch}_PATH "${SWIFT_ANDROID_NDK_PATH}/platforms/android-${SWIFT_ANDROID_API_LEVEL}/arch-x86_64")
|
||||
set(SWIFT_SDK_ANDROID_ARCH_${arch}_TRIPLE "x86_64-unknown-linux-android")
|
||||
else()
|
||||
message(FATAL_ERROR "unknown arch for android SDK: ${arch}")
|
||||
endif()
|
||||
-
|
||||
- # Get the prebuilt suffix to create the correct toolchain path when using the NDK
|
||||
- if(CMAKE_HOST_SYSTEM_NAME STREQUAL Darwin)
|
||||
- set(_swift_android_prebuilt_build darwin-x86_64)
|
||||
- elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL Linux)
|
||||
- set(_swift_android_prebuilt_build linux-x86_64)
|
||||
- elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
|
||||
- set(_swift_android_prebuilt_build Windows-x86_64)
|
||||
- elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL Android)
|
||||
- # When building natively on an Android host, there's no NDK or prebuilt suffix.
|
||||
- else()
|
||||
- message(SEND_ERROR "cannot cross-compile to android from ${CMAKE_HOST_SYSTEM_NAME}")
|
||||
- endif()
|
||||
- if("${arch}" STREQUAL "i686")
|
||||
- set(SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_PREBUILT_PATH
|
||||
- "${SWIFT_ANDROID_NDK_PATH}/toolchains/x86-${SWIFT_ANDROID_NDK_GCC_VERSION}/prebuilt/${_swift_android_prebuilt_build}")
|
||||
- elseif("${arch}" STREQUAL "x86_64")
|
||||
- set(SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_PREBUILT_PATH
|
||||
- "${SWIFT_ANDROID_NDK_PATH}/toolchains/x86_64-${SWIFT_ANDROID_NDK_GCC_VERSION}/prebuilt/${_swift_android_prebuilt_build}")
|
||||
- else()
|
||||
- set(SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_PREBUILT_PATH
|
||||
- "${SWIFT_ANDROID_NDK_PATH}/toolchains/${SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE}-${SWIFT_ANDROID_NDK_GCC_VERSION}/prebuilt/${_swift_android_prebuilt_build}")
|
||||
- endif()
|
||||
else()
|
||||
set(SWIFT_SDK_${prefix}_ARCH_${arch}_PATH "/" CACHE STRING "CMAKE_SYSROOT for ${prefix} ${arch}")
|
||||
|
||||
diff --git a/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake b/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake
|
||||
index a2f682ece6..d2f6c27890 100644
|
||||
--- a/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake
|
||||
+++ b/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake
|
||||
@@ -55,6 +55,10 @@ function(_add_target_variant_c_compile_link_flags)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
+ if("${CFLAGS_SDK}" STREQUAL "ANDROID")
|
||||
+ set(DEPLOYMENT_VERSION ${SWIFT_ANDROID_API_LEVEL})
|
||||
+ endif()
|
||||
+
|
||||
# MSVC, clang-cl, gcc don't understand -target.
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "^Clang|AppleClang$" AND
|
||||
NOT SWIFT_COMPILER_IS_MSVC_LIKE)
|
||||
@@ -274,16 +278,6 @@ function(_add_target_variant_c_compile_flags)
|
||||
list(APPEND result -funwind-tables)
|
||||
endif()
|
||||
|
||||
- if("${CFLAGS_SDK}" STREQUAL "ANDROID")
|
||||
- list(APPEND result -nostdinc++)
|
||||
- swift_android_libcxx_include_paths(CFLAGS_CXX_INCLUDES)
|
||||
- swift_android_include_for_arch("${CFLAGS_ARCH}" "${CFLAGS_ARCH}_INCLUDE")
|
||||
- foreach(path IN LISTS CFLAGS_CXX_INCLUDES ${CFLAGS_ARCH}_INCLUDE)
|
||||
- list(APPEND result "SHELL:${CMAKE_INCLUDE_SYSTEM_FLAG_C}${path}")
|
||||
- endforeach()
|
||||
- list(APPEND result "-D__ANDROID_API__=${SWIFT_ANDROID_API_LEVEL}")
|
||||
- endif()
|
||||
-
|
||||
if("${CFLAGS_SDK}" STREQUAL "LINUX")
|
||||
if(${CFLAGS_ARCH} STREQUAL x86_64)
|
||||
# this is the minimum architecture that supports 16 byte CAS, which is necessary to avoid a dependency to libatomic
|
||||
@@ -363,11 +357,6 @@ function(_add_target_variant_link_flags)
|
||||
# link against the custom C++ library
|
||||
swift_android_cxx_libraries_for_arch(${LFLAGS_ARCH} cxx_link_libraries)
|
||||
list(APPEND link_libraries ${cxx_link_libraries})
|
||||
-
|
||||
- swift_android_lib_for_arch(${LFLAGS_ARCH} ${LFLAGS_ARCH}_LIB)
|
||||
- foreach(path IN LISTS ${LFLAGS_ARCH}_LIB)
|
||||
- list(APPEND library_search_directories ${path})
|
||||
- endforeach()
|
||||
else()
|
||||
# If lto is enabled, we need to add the object path flag so that the LTO code
|
||||
# generator leaves the intermediate object file in a place where it will not
|
||||
diff --git a/swift/stdlib/cmake/modules/SwiftSource.cmake b/swift/stdlib/cmake/modules/SwiftSource.cmake
|
||||
index 41850e3f54..bb504ee93a 100644
|
||||
--- a/swift/stdlib/cmake/modules/SwiftSource.cmake
|
||||
+++ b/swift/stdlib/cmake/modules/SwiftSource.cmake
|
||||
@@ -184,9 +184,7 @@ function(_add_target_variant_swift_compile_flags
|
||||
${ARGN})
|
||||
|
||||
# On Windows, we don't set SWIFT_SDK_WINDOWS_PATH_ARCH_{ARCH}_PATH, so don't include it.
|
||||
- # On Android the sdk is split to two different paths for includes and libs, so these
|
||||
- # need to be set manually.
|
||||
- if (NOT "${sdk}" STREQUAL "WINDOWS" AND NOT "${sdk}" STREQUAL "ANDROID")
|
||||
+ if (NOT "${sdk}" STREQUAL "WINDOWS")
|
||||
list(APPEND result "-sdk" "${SWIFT_SDK_${sdk}_ARCH_${arch}_PATH}")
|
||||
endif()
|
||||
|
||||
@@ -206,13 +204,6 @@ function(_add_target_variant_swift_compile_flags
|
||||
"-target" "${SWIFT_SDK_${sdk}_ARCH_${arch}_TRIPLE}")
|
||||
endif()
|
||||
|
||||
- if("${sdk}" STREQUAL "ANDROID")
|
||||
- swift_android_include_for_arch(${arch} ${arch}_swift_include)
|
||||
- foreach(path IN LISTS ${arch}_swift_include)
|
||||
- list(APPEND result "\"${CMAKE_INCLUDE_FLAG_C}${path}\"")
|
||||
- endforeach()
|
||||
- endif()
|
||||
-
|
||||
if(NOT BUILD_STANDALONE)
|
||||
list(APPEND result "-resource-dir" "${SWIFTLIB_DIR}")
|
||||
endif()
|
||||
diff --git a/swift/utils/build-script-impl b/swift/utils/build-script-impl
|
||||
index cb68af1031..51d031cd39 100755
|
||||
--- a/swift/utils/build-script-impl
|
||||
+++ b/swift/utils/build-script-impl
|
||||
@@ -470,11 +470,11 @@ function set_build_options_for_host() {
|
||||
|
||||
case ${host} in
|
||||
android-aarch64)
|
||||
- SWIFT_HOST_TRIPLE="aarch64-unknown-linux-android"
|
||||
+ SWIFT_HOST_TRIPLE="aarch64-unknown-linux-android${ANDROID_API_LEVEL}"
|
||||
llvm_target_arch="AArch64"
|
||||
;;
|
||||
android-armv7)
|
||||
- SWIFT_HOST_TRIPLE="armv7-unknown-linux-androideabi"
|
||||
+ SWIFT_HOST_TRIPLE="armv7-unknown-linux-androideabi${ANDROID_API_LEVEL}"
|
||||
llvm_target_arch="ARM"
|
||||
;;
|
||||
linux-armv6)
|
75
packages/swift/swift-runtime-flag.patch
Normal file
75
packages/swift/swift-runtime-flag.patch
Normal file
@ -0,0 +1,75 @@
|
||||
commit f84992addb0f7cd54c13762274e898f79d0b0631
|
||||
Date: Sun, 8 Nov 2020 13:25:13 +0530
|
||||
Subject: [build] Make it possible to actually build the stdlib with a
|
||||
prebuilt clang
|
||||
|
||||
diff --git a/swift/CMakeLists.txt b/swift/CMakeLists.txt
|
||||
index 99937910af2b..2cec8d38a493 100644
|
||||
--- a/swift/CMakeLists.txt
|
||||
+++ b/swift/CMakeLists.txt
|
||||
@@ -462,10 +462,12 @@ if(SWIFT_PATH_TO_CMARK_BUILD)
|
||||
endif()
|
||||
message(STATUS "")
|
||||
|
||||
-if("${SWIFT_NATIVE_LLVM_TOOLS_PATH}" STREQUAL "")
|
||||
- set(SWIFT_CROSS_COMPILING FALSE)
|
||||
+# Check if a prebuilt clang path was passed in, as this variable will be
|
||||
+# assigned if not, in SwiftSharedCMakeConfig.
|
||||
+if("${SWIFT_NATIVE_CLANG_TOOLS_PATH}" STREQUAL "")
|
||||
+ set(SWIFT_PREBUILT_CLANG FALSE)
|
||||
else()
|
||||
- set(SWIFT_CROSS_COMPILING TRUE)
|
||||
+ set(SWIFT_PREBUILT_CLANG TRUE)
|
||||
endif()
|
||||
|
||||
include(SwiftSharedCMakeConfig)
|
||||
diff --git a/swift/cmake/modules/SwiftSharedCMakeConfig.cmake b/swift/cmake/modules/SwiftSharedCMakeConfig.cmake
|
||||
index c4c15084fe9..9ee08656589 100644
|
||||
--- a/swift/cmake/modules/SwiftSharedCMakeConfig.cmake
|
||||
+++ b/swift/cmake/modules/SwiftSharedCMakeConfig.cmake
|
||||
@@ -58,7 +58,7 @@ macro(swift_common_standalone_build_config_llvm product)
|
||||
fix_imported_targets_for_xcode("${LLVM_EXPORTED_TARGETS}")
|
||||
endif()
|
||||
|
||||
- if(NOT CMAKE_CROSSCOMPILING AND NOT SWIFT_CROSS_COMPILING)
|
||||
+ if(NOT CMAKE_CROSSCOMPILING)
|
||||
set(${product}_NATIVE_LLVM_TOOLS_PATH "${LLVM_TOOLS_BINARY_DIR}")
|
||||
endif()
|
||||
|
||||
@@ -159,7 +159,7 @@ endmacro()
|
||||
macro(swift_common_standalone_build_config_clang product)
|
||||
find_package(Clang CONFIG REQUIRED NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
|
||||
|
||||
- if (NOT CMAKE_CROSSCOMPILING)
|
||||
+ if (NOT CMAKE_CROSSCOMPILING AND NOT SWIFT_PREBUILT_CLANG)
|
||||
set(${product}_NATIVE_CLANG_TOOLS_PATH "${LLVM_TOOLS_BINARY_DIR}")
|
||||
endif()
|
||||
|
||||
diff --git a/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake b/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake
|
||||
index 7a296b5807d5..ace3fb90370f 100644
|
||||
--- a/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake
|
||||
+++ b/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake
|
||||
@@ -1653,7 +1653,8 @@ function(add_swift_target_library name)
|
||||
list(APPEND SWIFTLIB_SWIFT_COMPILE_FLAGS "-warn-implicit-overrides")
|
||||
endif()
|
||||
|
||||
- if(NOT SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER AND NOT BUILD_STANDALONE)
|
||||
+ if(NOT SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER AND NOT BUILD_STANDALONE AND
|
||||
+ NOT SWIFT_PREBUILT_CLANG)
|
||||
list(APPEND SWIFTLIB_DEPENDS clang)
|
||||
endif()
|
||||
|
||||
diff --git a/swift/stdlib/public/SwiftShims/CMakeLists.txt b/swift/stdlib/public/SwiftShims/CMakeLists.txt
|
||||
index 33c49a3f8861..8553f4f00b37 100644
|
||||
--- a/swift/stdlib/public/SwiftShims/CMakeLists.txt
|
||||
+++ b/swift/stdlib/public/SwiftShims/CMakeLists.txt
|
||||
@@ -110,7 +110,8 @@ endif()
|
||||
# First extract the "version" used for Clang's resource directory.
|
||||
string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION
|
||||
"${LLVM_PACKAGE_VERSION}")
|
||||
-if(NOT SWIFT_INCLUDE_TOOLS AND SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER)
|
||||
+if(NOT SWIFT_INCLUDE_TOOLS AND
|
||||
+ (SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER OR SWIFT_PREBUILT_CLANG))
|
||||
if(SWIFT_COMPILER_IS_MSVC_LIKE)
|
||||
execute_process(COMMAND ${CMAKE_C_COMPILER} /clang:-print-resource-dir
|
||||
OUTPUT_VARIABLE clang_headers_location
|
22
packages/swift/swift-standalone-toolchain.patch
Normal file
22
packages/swift/swift-standalone-toolchain.patch
Normal file
@ -0,0 +1,22 @@
|
||||
diff --git a/swift/cmake/modules/SwiftAndroidSupport.cmake b/swift/cmake/modules/SwiftAndroidSupport.cmake
|
||||
index c8d224c958..9b0b9043af 100644
|
||||
--- a/swift/cmake/modules/SwiftAndroidSupport.cmake
|
||||
+++ b/swift/cmake/modules/SwiftAndroidSupport.cmake
|
||||
@@ -14,7 +14,7 @@ endfunction()
|
||||
function(swift_android_sysroot sysroot_var_name)
|
||||
if(NOT "${SWIFT_ANDROID_NDK_PATH}" STREQUAL "")
|
||||
swift_android_prebuilt_host_name(prebuilt_build)
|
||||
- set(${sysroot_var_name} "${SWIFT_ANDROID_NDK_PATH}/toolchains/llvm/prebuilt/${prebuilt_build}/sysroot" PARENT_SCOPE)
|
||||
+ set(${sysroot_var_name} "${SWIFT_ANDROID_NDK_PATH}/sysroot" PARENT_SCOPE)
|
||||
elseif(NOT "${SWIFT_ANDROID_NATIVE_SYSROOT}" STREQUAL "")
|
||||
set(${sysroot_var_name} "${SWIFT_ANDROID_NATIVE_SYSROOT}" PARENT_SCOPE)
|
||||
else()
|
||||
@@ -36,7 +36,7 @@ function(swift_android_tools_path arch path_var_name)
|
||||
"${SWIFT_ANDROID_NDK_PATH}/toolchains/${SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE}-${SWIFT_ANDROID_NDK_GCC_VERSION}/prebuilt/${prebuilt_build}")
|
||||
endif()
|
||||
|
||||
- set(${path_var_name} "${ndk_prebuilt_path}/${SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE}/bin" PARENT_SCOPE)
|
||||
+ set(${path_var_name} "${SWIFT_ANDROID_NDK_PATH}/${SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE}/bin" PARENT_SCOPE)
|
||||
elseif(NOT "${SWIFT_ANDROID_NATIVE_SYSROOT}" STREQUAL "")
|
||||
set(${path_var_name} "${SWIFT_ANDROID_NATIVE_SYSROOT}/usr/bin" PARENT_SCOPE)
|
||||
else()
|
@ -1,13 +0,0 @@
|
||||
diff --git a/swift/stdlib/public/runtime/Float16Support.cpp b/swift/stdlib/public/runtime/Float16Support.cpp
|
||||
index d7377400ba0..9d8c4940054 100644
|
||||
--- a/swift/stdlib/public/runtime/Float16Support.cpp
|
||||
+++ b/swift/stdlib/public/runtime/Float16Support.cpp
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
// Android NDK <r21 do not provide `__aeabi_d2h` in the compiler runtime,
|
||||
// provide shims in that case.
|
||||
-#if (defined(ANDROID) && defined(__ARM_ARCH_7A__) && defined(__ARM_EABI__)) || \
|
||||
+#if (defined(__ANDROID__) && defined(__ARM_ARCH_7A__) && defined(__ARM_EABI__)) || \
|
||||
((defined(__i686__) || defined(__x86_64__)) && !defined(__APPLE__))
|
||||
|
||||
#include "../SwiftShims/Visibility.h"
|
@ -36,7 +36,7 @@ index 7f39ff97459..af310ec8cbf 100755
|
||||
-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[@]}"
|
||||
"${llbuild_cmake_options[@]}"
|
||||
|
||||
-DCMAKE_BUILD_TYPE:STRING="${LLBUILD_BUILD_TYPE}"
|
||||
+ -DCMAKE_C_COMPILER:PATH="${CLANG_BIN}/clang"
|
||||
|
@ -2,17 +2,6 @@ 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
|
||||
@@ -472,6 +473,10 @@ function set_build_options_for_host() {
|
||||
SWIFT_HOST_TRIPLE="aarch64-unknown-linux-android"
|
||||
llvm_target_arch="AArch64"
|
||||
;;
|
||||
+ android-armv7)
|
||||
+ SWIFT_HOST_TRIPLE="armv7a-unknown-linux-androideabi"
|
||||
+ llvm_target_arch="ARM"
|
||||
+ ;;
|
||||
linux-armv6)
|
||||
SWIFT_HOST_TRIPLE="armv6-unknown-linux-gnueabihf"
|
||||
llvm_target_arch="ARM"
|
||||
@@ -703,6 +705,7 @@ function set_build_options_for_host() {
|
||||
llvm_cmake_options+=(
|
||||
-DLLVM_TOOL_COMPILER_RT_BUILD:BOOL="$(false_true ${SKIP_BUILD_COMPILER_RT})"
|
||||
@ -34,7 +23,7 @@ index b1d060328bc..218c9215260 100755
|
||||
for t in "${CROSS_COMPILE_HOSTS[@]}"; do
|
||||
case ${t} in
|
||||
- macosx-arm64* | iphone* | appletv* | watch* | linux-armv6 | linux-armv7 )
|
||||
+ macosx-arm64* | iphone* | appletv* | watch* | linux-armv6 | linux-armv7 | android-a* )
|
||||
+ macosx-arm64* | iphone* | appletv* | watch* | linux-armv6 | linux-armv7 | android-* )
|
||||
;;
|
||||
*)
|
||||
echo "Unknown host to cross-compile for: ${t}"
|
||||
@ -55,7 +44,7 @@ index b1d060328bc..218c9215260 100755
|
||||
+ local host=$1
|
||||
+ if [[ $(is_cross_tools_host ${host}) ]] ; then
|
||||
+ case $host in
|
||||
+ android-a*)
|
||||
+ android-*)
|
||||
+ echo -n "${TERMUX_SWIFT_FLAGS}"
|
||||
+ ;;
|
||||
+ *)
|
||||
@ -70,7 +59,7 @@ index b1d060328bc..218c9215260 100755
|
||||
+ local host=$1
|
||||
+ local -n options=$2
|
||||
+ case $host in
|
||||
+ android-a*)
|
||||
+ android-*)
|
||||
+ local NDK_ARCH=$ANDROID_ARCH
|
||||
+ test $NDK_ARCH == 'armv7' && NDK_ARCH='armv7-a'
|
||||
+ options+=(
|
||||
|
65
packages/swift/swift-x86_64.patch
Normal file
65
packages/swift/swift-x86_64.patch
Normal file
@ -0,0 +1,65 @@
|
||||
diff --git a/swift/utils/build-script b/swift/utils/build-script
|
||||
index e2ab40128b..f6f5ca50cd 100755
|
||||
--- a/swift/utils/build-script
|
||||
+++ b/swift/utils/build-script
|
||||
@@ -316,6 +316,9 @@ def apply_default_arguments(toolchain, args):
|
||||
elif args.android_arch == "aarch64":
|
||||
args.stdlib_deployment_targets.append(
|
||||
StdlibDeploymentTarget.Android.aarch64.name)
|
||||
+ elif args.android_arch == "x86_64":
|
||||
+ args.stdlib_deployment_targets.append(
|
||||
+ StdlibDeploymentTarget.Android.x86_64.name)
|
||||
|
||||
# Infer platform flags from manually-specified configure targets.
|
||||
# This doesn't apply to Darwin platforms, as they are
|
||||
diff --git a/swift/utils/build-script-impl b/swift/utils/build-script-impl
|
||||
index 209bc334da..64ad978a65 100755
|
||||
--- a/swift/utils/build-script-impl
|
||||
+++ b/swift/utils/build-script-impl
|
||||
@@ -433,7 +433,8 @@ function verify_host_is_supported() {
|
||||
| watchsimulator-arm64 \
|
||||
| watchos-armv7k \
|
||||
| android-armv7 \
|
||||
- | android-aarch64)
|
||||
+ | android-aarch64 \
|
||||
+ | android-x86_64)
|
||||
;;
|
||||
*)
|
||||
echo "Unknown host tools target: ${host}"
|
||||
@@ -477,6 +478,10 @@ function set_build_options_for_host() {
|
||||
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"
|
||||
+ ;;
|
||||
linux-armv6)
|
||||
SWIFT_HOST_TRIPLE="armv6-unknown-linux-gnueabihf"
|
||||
llvm_target_arch="ARM"
|
||||
diff --git a/swift/utils/build_swift/build_swift/driver_arguments.py b/swift/utils/build_swift/build_swift/driver_arguments.py
|
||||
index 1a18e83cb3..e594620dbd 100644
|
||||
--- a/swift/utils/build_swift/build_swift/driver_arguments.py
|
||||
+++ b/swift/utils/build_swift/build_swift/driver_arguments.py
|
||||
@@ -1065,7 +1065,7 @@ def create_argument_parser():
|
||||
android.adb.commands.DEVICE_TEMP_DIR))
|
||||
|
||||
option('--android-arch', store,
|
||||
- choices=['armv7', 'aarch64'],
|
||||
+ choices=['armv7', 'aarch64', 'x86_64'],
|
||||
default='armv7',
|
||||
help='The Android target architecture when building for Android. '
|
||||
'Currently only armv7 and aarch64 are supported. '
|
||||
diff --git a/swift/utils/swift_build_support/swift_build_support/targets.py b/swift/utils/swift_build_support/swift_build_support/targets.py
|
||||
index 6bc7abe319..6365bf99e6 100644
|
||||
--- a/swift/utils/swift_build_support/swift_build_support/targets.py
|
||||
+++ b/swift/utils/swift_build_support/swift_build_support/targets.py
|
||||
@@ -195,7 +195,7 @@ class StdlibDeploymentTarget(object):
|
||||
|
||||
Cygwin = Platform("cygwin", archs=["x86_64"])
|
||||
|
||||
- Android = AndroidPlatform("android", archs=["armv7", "aarch64"])
|
||||
+ Android = AndroidPlatform("android", archs=["armv7", "aarch64", "x86_64"])
|
||||
|
||||
Windows = Platform("windows", archs=["x86_64"])
|
||||
|
@ -7,7 +7,7 @@ index f7439427..5f284c48 100755
|
||||
args.cmake_path = get_cmake_path(args)
|
||||
args.ninja_path = get_ninja_path(args)
|
||||
- if args.cross_compile_hosts: # Use XCBuild target directory when building for multiple arches.
|
||||
+ if args.cross_compile_hosts and not args.cross_compiling: # Use XCBuild target directory when building for multiple arches.
|
||||
+ if args.cross_compile_hosts and "macosx-arm64" in args.cross_compile_hosts: # Use XCBuild target directory when building for multiple arches.
|
||||
args.target_dir = os.path.join(args.build_dir, "apple/Products")
|
||||
else:
|
||||
args.target_dir = os.path.join(args.build_dir, get_build_target(args))
|
||||
@ -20,29 +20,12 @@ index f7439427..5f284c48 100755
|
||||
args.target_info = json.loads(target_info_json)
|
||||
return args.target_info["target"]["unversionedTriple"]
|
||||
except Exception as e:
|
||||
@@ -255,13 +255,15 @@ def clean(args):
|
||||
|
||||
def build(args):
|
||||
"""Builds SwiftPM using a two-step process: first using CMake, then with itself."""
|
||||
+ args.cross_compiling = 'ANDROID_DATA' not in os.environ
|
||||
parse_build_args(args)
|
||||
|
||||
# Build llbuild if its build path is not passed in.
|
||||
if not args.llbuild_build_dir:
|
||||
build_llbuild(args)
|
||||
|
||||
- build_tsc(args)
|
||||
+ if not args.cross_compiling:
|
||||
+ build_tsc(args)
|
||||
build_swiftpm_with_cmake(args)
|
||||
build_swiftpm_with_swiftpm(args)
|
||||
|
||||
@@ -366,7 +368,13 @@ def build_with_cmake(args, cmake_args, source_path, build_dir):
|
||||
"""Runs CMake if needed, then builds with Ninja."""
|
||||
cache_path = os.path.join(build_dir, "CMakeCache.txt")
|
||||
if args.reconfigure or not os.path.isfile(cache_path) or not args.swiftc_path in open(cache_path).read():
|
||||
- swift_flags = ""
|
||||
+ if args.cross_compiling:
|
||||
+ if args.cross_compile_hosts:
|
||||
+ # The termux prefix flag is needed because the Swift flags pass the
|
||||
+ # standalone toolchain as the sdk, ie the sysroot.
|
||||
+ swift_flags = os.getenv("TERMUX_SWIFTPM_FLAGS") + " -resource-dir @TERMUX_PREFIX@/lib/swift -Xcc -I@TERMUX_PREFIX@/include"
|
||||
@ -52,90 +35,32 @@ index f7439427..5f284c48 100755
|
||||
if args.sysroot:
|
||||
swift_flags = "-sdk %s" % args.sysroot
|
||||
|
||||
@@ -390,6 +398,10 @@ def build_with_cmake(args, cmake_args, source_path, build_dir):
|
||||
if args.verbose:
|
||||
ninja_cmd.append("-v")
|
||||
@@ -461,6 +463,9 @@ def build_swiftpm_with_cmake(args):
|
||||
]
|
||||
else:
|
||||
cmake_flags = [ "-DFIND_PM_DEPS:BOOL=NO" ]
|
||||
+ if "android-@SWIFT_ARCH@" in args.cross_compile_hosts:
|
||||
+ cmake_flags.append("-DCMAKE_SYSTEM_NAME=Android")
|
||||
+ cmake_flags.append("-DCMAKE_SYSTEM_VERSION=1")
|
||||
|
||||
+ if args.cross_compiling:
|
||||
+ ninja_cmd.append("PD4")
|
||||
+ ninja_cmd.append("PD4_2")
|
||||
+
|
||||
call(ninja_cmd, cwd=build_dir, verbose=args.verbose)
|
||||
|
||||
def build_llbuild(args):
|
||||
@@ -432,9 +444,11 @@ def build_swiftpm_with_cmake(args):
|
||||
|
||||
cmake_flags = [
|
||||
get_llbuild_cmake_arg(args),
|
||||
- "-DTSC_DIR=" + os.path.join(args.tsc_build_dir, "cmake/modules"),
|
||||
]
|
||||
|
||||
+ if not args.cross_compiling:
|
||||
+ cmake_flags.append("-DTSC_DIR=" + os.path.join(args.tsc_build_dir, "cmake/modules"))
|
||||
+
|
||||
if platform.system() == 'Darwin':
|
||||
cmake_flags.append("-DCMAKE_C_FLAGS=-target %s%s" % (get_build_target(args), g_macos_deployment_target))
|
||||
cmake_flags.append("-DCMAKE_OSX_DEPLOYMENT_TARGET=%s" % g_macos_deployment_target)
|
||||
@@ -451,12 +465,15 @@ def build_swiftpm_with_swiftpm(args):
|
||||
"""Builds SwiftPM using the version of SwiftPM built with CMake."""
|
||||
note("Building SwiftPM (with swift-build)")
|
||||
|
||||
- swiftpm_args = [
|
||||
- "SWIFT_EXEC=" + args.swiftc_path,
|
||||
- "SWIFTPM_PD_LIBS=" + os.path.join(args.bootstrap_dir, "pm"),
|
||||
- os.path.join(args.bootstrap_dir, "bin/swift-build"),
|
||||
- "--disable-sandbox",
|
||||
- ]
|
||||
+ swiftpm_args = [ "SWIFT_EXEC=" + args.swiftc_path ]
|
||||
+
|
||||
+ if args.cross_compiling:
|
||||
+ swiftpm_args.append(os.path.join(os.path.split(args.swiftc_path)[0], "swift-build"))
|
||||
+ else:
|
||||
+ swiftpm_args.append("SWIFTPM_PD_LIBS=" + os.path.join(args.bootstrap_dir, "pm"))
|
||||
+ swiftpm_args.append(os.path.join(args.bootstrap_dir, "bin/swift-build"))
|
||||
+
|
||||
+ swiftpm_args.append("--disable-sandbox")
|
||||
|
||||
build_target = get_build_target(args)
|
||||
cross_compile_hosts = args.cross_compile_hosts
|
||||
@@ -510,15 +529,16 @@ def get_swiftpm_env_cmd(args):
|
||||
env_cmd.append("SWIFTCI_USE_LOCAL_DEPS=1")
|
||||
env_cmd.append("SWIFTPM_MACOS_DEPLOYMENT_TARGET=%s" % g_macos_deployment_target)
|
||||
|
||||
- libs_joined = ":".join([
|
||||
- os.path.join(args.bootstrap_dir, "lib"),
|
||||
- os.path.join(args.tsc_build_dir, "lib"),
|
||||
- os.path.join(args.llbuild_build_dir, "lib"),
|
||||
- ])
|
||||
+ if not args.cross_compiling:
|
||||
+ libs_joined = ":".join([
|
||||
+ os.path.join(args.bootstrap_dir, "lib"),
|
||||
+ os.path.join(args.tsc_build_dir, "lib"),
|
||||
+ os.path.join(args.llbuild_build_dir, "lib"),
|
||||
+ ])
|
||||
|
||||
if platform.system() == 'Darwin':
|
||||
env_cmd.append("DYLD_LIBRARY_PATH=%s" % libs_joined)
|
||||
- else:
|
||||
+ elif not args.cross_compiling:
|
||||
env_cmd.append("LD_LIBRARY_PATH=%s" % libs_joined)
|
||||
|
||||
return env_cmd
|
||||
@@ -600,13 +618,20 @@ def get_swiftpm_flags(args):
|
||||
@@ -622,8 +631,8 @@ def get_swiftpm_flags(args):
|
||||
)
|
||||
|
||||
# Don't use GNU strerror_r on Android.
|
||||
- if 'ANDROID_DATA' in os.environ:
|
||||
- build_flags.extend(["-Xswiftc", "-Xcc", "-Xswiftc", "-U_GNU_SOURCE"])
|
||||
+ build_flags.extend(["-Xswiftc", "-Xcc", "-Xswiftc", "-U_GNU_SOURCE"])
|
||||
+ build_flags.extend(["-Xswiftc", "-no-toolchain-stdlib-rpath"])
|
||||
+ build_flags.extend(["-Xlinker", "-landroid-spawn"])
|
||||
|
||||
build_target = get_build_target(args)
|
||||
# On ELF platforms, remove the host toolchain's stdlib absolute rpath from
|
||||
# installed executables and shared libraries.
|
||||
@@ -634,6 +643,12 @@ def get_swiftpm_flags(args):
|
||||
cross_compile_hosts = args.cross_compile_hosts
|
||||
if build_target == 'x86_64-apple-macosx' and "macosx-arm64" in cross_compile_hosts:
|
||||
build_flags += ["--arch", "x86_64", "--arch", "arm64"]
|
||||
+ elif args.cross_compiling and "android-@SWIFT_ARCH@" in cross_compile_hosts:
|
||||
+ elif "android-@SWIFT_ARCH@" in cross_compile_hosts:
|
||||
+ build_flags.extend([
|
||||
+ "--destination", "@TERMUX_PKG_BUILDDIR@/swiftpm-android-flags.json",
|
||||
+ "-Xlinker", "-rpath", "-Xlinker", "@TERMUX_PREFIX@/lib",
|
||||
|
165
packages/swift/swiftpm-no-cmake-bootstrap.patch
Normal file
165
packages/swift/swiftpm-no-cmake-bootstrap.patch
Normal file
@ -0,0 +1,165 @@
|
||||
commit c815b71f466ff1b649f73536a81c52cd1981a34b
|
||||
Date: Sat, 24 Oct 2020 13:32:23 +0530
|
||||
Subject: [bootstrap] Add a --skip-cmake-bootstrap flag to use a
|
||||
prebuilt swift-build
|
||||
|
||||
Rather than building with CMake and then using that freshly built swift-build
|
||||
to build it with itself, add this flag to check for a prebuilt swift-build next
|
||||
to swiftc and use that instead if it's there. The PackageDescription libraries
|
||||
are still built using CMake, as this repo's Package.swift only builds the latest
|
||||
4_2 version.
|
||||
|
||||
diff --git a/swiftpm/CMakeLists.txt b/swiftpm/CMakeLists.txt
|
||||
index 405b3c56..f1fcf16d 100644
|
||||
--- a/swiftpm/CMakeLists.txt
|
||||
+++ b/swiftpm/CMakeLists.txt
|
||||
@@ -31,13 +31,16 @@ endif()
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
|
||||
option(BUILD_SHARED_LIBS "Build shared libraryes by default" YES)
|
||||
+option(FIND_PM_DEPS "Search for all external Package Manager dependencies" YES)
|
||||
|
||||
+if(FIND_PM_DEPS)
|
||||
find_package(TSC CONFIG REQUIRED)
|
||||
|
||||
find_package(LLBuild CONFIG)
|
||||
if(NOT LLBuild_FOUND)
|
||||
find_package(LLBuild REQUIRED)
|
||||
endif()
|
||||
+endif()
|
||||
|
||||
find_package(dispatch QUIET)
|
||||
find_package(Foundation QUIET)
|
||||
diff --git a/swiftpm/Utilities/bootstrap b/swiftpm/Utilities/bootstrap
|
||||
index 4cc7dd01..cd13cda4 100755
|
||||
--- a/swiftpm/Utilities/bootstrap
|
||||
+++ b/swiftpm/Utilities/bootstrap
|
||||
@@ -113,6 +113,10 @@ def add_build_args(parser):
|
||||
"--release",
|
||||
action="store_true",
|
||||
help="enables building SwiftPM in release mode")
|
||||
+ parser.add_argument(
|
||||
+ "--skip-cmake-bootstrap",
|
||||
+ action="store_true",
|
||||
+ help="build with prebuilt package manager in toolchain if it exists")
|
||||
parser.add_argument(
|
||||
"--libswiftpm-install-dir",
|
||||
metavar='PATH',
|
||||
@@ -174,6 +178,8 @@ def parse_build_args(args):
|
||||
args.bootstrap_dir = os.path.join(args.target_dir, "bootstrap")
|
||||
args.conf = 'release' if args.release else 'debug'
|
||||
args.bin_dir = os.path.join(args.target_dir, args.conf)
|
||||
+ args.bootstrap = not args.skip_cmake_bootstrap or \
|
||||
+ not os.path.exists(os.path.join(os.path.split(args.swiftc_path)[0], "swift-build"))
|
||||
|
||||
def parse_test_args(args):
|
||||
"""Parses and cleans arguments necessary for the test action."""
|
||||
@@ -270,7 +276,8 @@ def build(args):
|
||||
if not args.llbuild_build_dir:
|
||||
build_llbuild(args)
|
||||
|
||||
- build_tsc(args)
|
||||
+ if args.bootstrap:
|
||||
+ build_tsc(args)
|
||||
build_swiftpm_with_cmake(args)
|
||||
build_swiftpm_with_swiftpm(args)
|
||||
|
||||
@@ -376,7 +383,7 @@ def install_binary(args, binary, dest_dir):
|
||||
# Build functions
|
||||
# -----------------------------------------------------------
|
||||
|
||||
-def build_with_cmake(args, cmake_args, source_path, build_dir):
|
||||
+def build_with_cmake(args, cmake_args, source_path, build_dir, targets=[]):
|
||||
"""Runs CMake if needed, then builds with Ninja."""
|
||||
cache_path = os.path.join(build_dir, "CMakeCache.txt")
|
||||
if args.reconfigure or not os.path.isfile(cache_path) or not args.swiftc_path in open(cache_path).read():
|
||||
@@ -404,6 +411,8 @@ def build_with_cmake(args, cmake_args, source_path, build_dir):
|
||||
if args.verbose:
|
||||
ninja_cmd.append("-v")
|
||||
|
||||
+ ninja_cmd += targets
|
||||
+
|
||||
call(ninja_cmd, cwd=build_dir, verbose=args.verbose)
|
||||
|
||||
def build_llbuild(args):
|
||||
@@ -444,16 +453,22 @@ def build_swiftpm_with_cmake(args):
|
||||
"""Builds SwiftPM using CMake."""
|
||||
note("Building SwiftPM (with CMake)")
|
||||
|
||||
- cmake_flags = [
|
||||
- get_llbuild_cmake_arg(args),
|
||||
- "-DTSC_DIR=" + os.path.join(args.tsc_build_dir, "cmake/modules"),
|
||||
- ]
|
||||
+ if args.bootstrap:
|
||||
+ cmake_flags = [
|
||||
+ get_llbuild_cmake_arg(args),
|
||||
+ "-DTSC_DIR=" + os.path.join(args.tsc_build_dir, "cmake/modules"),
|
||||
+ "-DFIND_PM_DEPS:BOOL=YES",
|
||||
+ ]
|
||||
+ else:
|
||||
+ cmake_flags = [ "-DFIND_PM_DEPS:BOOL=NO" ]
|
||||
|
||||
if platform.system() == 'Darwin':
|
||||
cmake_flags.append("-DCMAKE_C_FLAGS=-target %s%s" % (get_build_target(args), g_macos_deployment_target))
|
||||
cmake_flags.append("-DCMAKE_OSX_DEPLOYMENT_TARGET=%s" % g_macos_deployment_target)
|
||||
|
||||
- build_with_cmake(args, cmake_flags, args.project_root, args.bootstrap_dir)
|
||||
+ targets = [] if args.bootstrap else ["PD4", "PD4_2"]
|
||||
+
|
||||
+ build_with_cmake(args, cmake_flags, args.project_root, args.bootstrap_dir, targets)
|
||||
|
||||
if args.llbuild_link_framework:
|
||||
swift_build = os.path.join(args.bootstrap_dir, "bin/swift-build")
|
||||
@@ -463,15 +478,21 @@ def build_swiftpm_with_cmake(args):
|
||||
|
||||
def build_swiftpm_with_swiftpm(args):
|
||||
"""Builds SwiftPM using the version of SwiftPM built with CMake."""
|
||||
- note("Building SwiftPM (with swift-build)")
|
||||
|
||||
swiftpm_args = [
|
||||
"SWIFT_EXEC=" + args.swiftc_path,
|
||||
- "SWIFTPM_PD_LIBS=" + os.path.join(args.bootstrap_dir, "pm"),
|
||||
- os.path.join(args.bootstrap_dir, "bin/swift-build"),
|
||||
- "--disable-sandbox",
|
||||
]
|
||||
|
||||
+ if args.bootstrap:
|
||||
+ note("Building SwiftPM (with a freshly built swift-build)")
|
||||
+ swiftpm_args.append("SWIFTPM_PD_LIBS=" + os.path.join(args.bootstrap_dir, "pm"))
|
||||
+ swiftpm_args.append(os.path.join(args.bootstrap_dir, "bin/swift-build"))
|
||||
+ else:
|
||||
+ note("Building SwiftPM (with a prebuilt swift-build)")
|
||||
+ swiftpm_args.append(os.path.join(os.path.split(args.swiftc_path)[0], "swift-build"))
|
||||
+
|
||||
+ swiftpm_args.append("--disable-sandbox")
|
||||
+
|
||||
call_swiftpm(args, swiftpm_args)
|
||||
|
||||
# Setup symlinks that'll allow using swiftpm from the build directory.
|
||||
@@ -527,16 +548,17 @@ def get_swiftpm_env_cmd(args):
|
||||
env_cmd.append("SWIFTCI_USE_LOCAL_DEPS=1")
|
||||
env_cmd.append("SWIFTPM_MACOS_DEPLOYMENT_TARGET=%s" % g_macos_deployment_target)
|
||||
|
||||
- libs_joined = ":".join([
|
||||
- os.path.join(args.bootstrap_dir, "lib"),
|
||||
- os.path.join(args.tsc_build_dir, "lib"),
|
||||
- os.path.join(args.llbuild_build_dir, "lib"),
|
||||
- ])
|
||||
+ if args.bootstrap:
|
||||
+ libs_joined = ":".join([
|
||||
+ os.path.join(args.bootstrap_dir, "lib"),
|
||||
+ os.path.join(args.tsc_build_dir, "lib"),
|
||||
+ os.path.join(args.llbuild_build_dir, "lib"),
|
||||
+ ])
|
||||
|
||||
- if platform.system() == 'Darwin':
|
||||
- env_cmd.append("DYLD_LIBRARY_PATH=%s" % libs_joined)
|
||||
- else:
|
||||
- env_cmd.append("LD_LIBRARY_PATH=%s" % libs_joined)
|
||||
+ if platform.system() == 'Darwin':
|
||||
+ env_cmd.append("DYLD_LIBRARY_PATH=%s" % libs_joined)
|
||||
+ else:
|
||||
+ env_cmd.append("LD_LIBRARY_PATH=%s" % libs_joined)
|
||||
|
||||
return env_cmd
|
||||
|
@ -1,75 +1,19 @@
|
||||
diff --git a/swiftpm/CMakeLists.txt b/swiftpm/CMakeLists.txt
|
||||
index 4cd8621f..86a23e0a 100644
|
||||
--- a/swiftpm/CMakeLists.txt
|
||||
+++ b/swiftpm/CMakeLists.txt
|
||||
@@ -26,7 +26,9 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
|
||||
option(BUILD_SHARED_LIBS "Build shared libraryes by default" YES)
|
||||
|
||||
-find_package(TSC CONFIG REQUIRED)
|
||||
+if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL Android)
|
||||
+ find_package(TSC CONFIG REQUIRED)
|
||||
+endif()
|
||||
|
||||
find_package(LLBuild CONFIG)
|
||||
if(NOT LLBuild_FOUND)
|
||||
commit 75be121002348a7f0c3995f6a6ff63fcbe21aaed
|
||||
Date: Tue Mar 31 01:14:18 2020 +0530
|
||||
|
||||
[PackageDescription] Add missing relative SDK rpath to libPackageDescription.so shared libraries (#2661)
|
||||
|
||||
diff --git a/swiftpm/Sources/PackageDescription/CMakeLists.txt b/swiftpm/Sources/PackageDescription/CMakeLists.txt
|
||||
index b6d925e1..3e546554 100644
|
||||
index ee9eda32..ea704129 100644
|
||||
--- a/swiftpm/Sources/PackageDescription/CMakeLists.txt
|
||||
+++ b/swiftpm/Sources/PackageDescription/CMakeLists.txt
|
||||
@@ -32,11 +32,13 @@ foreach(PACKAGE_DESCRIPTION_VERSION 4 4_2)
|
||||
target_link_options(PD${PACKAGE_DESCRIPTION_VERSION} PRIVATE
|
||||
"SHELL:-Xlinker -install_name -Xlinker @rpath/libPackageDescription.dylib")
|
||||
@@ -47,6 +47,9 @@ foreach(PACKAGE_DESCRIPTION_VERSION 4 4_2)
|
||||
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
|
||||
target_link_libraries(PD${PACKAGE_DESCRIPTION_VERSION} PRIVATE
|
||||
Foundation)
|
||||
+ set_target_properties(PD${PACKAGE_DESCRIPTION_VERSION} PROPERTIES
|
||||
+ BUILD_WITH_INSTALL_RPATH TRUE
|
||||
+ INSTALL_RPATH "$ORIGIN/../../$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>")
|
||||
endif()
|
||||
-
|
||||
+ target_link_options(PD${PACKAGE_DESCRIPTION_VERSION} PRIVATE "SHELL:-no-toolchain-stdlib-rpath")
|
||||
set_target_properties(PD${PACKAGE_DESCRIPTION_VERSION} PROPERTIES
|
||||
Swift_MODULE_NAME PackageDescription
|
||||
Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/pm/${PACKAGE_DESCRIPTION_VERSION}
|
||||
+ BUILD_WITH_INSTALL_RPATH TRUE
|
||||
INSTALL_NAME_DIR \\@rpath
|
||||
+ INSTALL_RPATH "$ORIGIN/../../android"
|
||||
OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/pm/${PACKAGE_DESCRIPTION_VERSION}
|
||||
OUTPUT_NAME PackageDescription
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/pm/${PACKAGE_DESCRIPTION_VERSION}
|
||||
diff --git a/swiftpm/Sources/SPMBuildCore/Triple.swift b/swiftpm/Sources/SPMBuildCore/Triple.swift
|
||||
index 361dc283..e9091607 100644
|
||||
--- a/swiftpm/Sources/SPMBuildCore/Triple.swift
|
||||
+++ b/swiftpm/Sources/SPMBuildCore/Triple.swift
|
||||
@@ -40,6 +40,7 @@ public struct Triple: Encodable, Equatable {
|
||||
case s390x
|
||||
case aarch64
|
||||
case armv7
|
||||
+ case armv7a
|
||||
case arm
|
||||
case arm64
|
||||
case arm64e
|
||||
diff --git a/swiftpm/swift-tools-support-core/Sources/TSCBasic/CMakeLists.txt b/swiftpm/swift-tools-support-core/Sources/TSCBasic/CMakeLists.txt
|
||||
index bbc43d98..bc5ee576 100644
|
||||
--- a/swiftpm/swift-tools-support-core/Sources/TSCBasic/CMakeLists.txt
|
||||
+++ b/swiftpm/swift-tools-support-core/Sources/TSCBasic/CMakeLists.txt
|
||||
@@ -53,7 +53,7 @@ target_link_libraries(TSCBasic PUBLIC
|
||||
TSCLibc)
|
||||
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
|
||||
target_link_libraries(TSCBasic PUBLIC
|
||||
- Foundation)
|
||||
+ Foundation android-spawn)
|
||||
endif()
|
||||
# NOTE(compnerd) workaround for CMake not setting up include flags yet
|
||||
set_target_properties(TSCBasic PROPERTIES
|
||||
diff --git a/swiftpm/swift-tools-support-core/Sources/TSCUtility/FSWatch.swift b/swiftpm/swift-tools-support-core/Sources/TSCUtility/FSWatch.swift
|
||||
index 0658e55b..9221950b 100644
|
||||
--- a/swiftpm/swift-tools-support-core/Sources/TSCUtility/FSWatch.swift
|
||||
+++ b/swiftpm/swift-tools-support-core/Sources/TSCUtility/FSWatch.swift
|
||||
@@ -429,7 +429,11 @@ public final class Inotify {
|
||||
|
||||
private func FD_ZERO(_ set: inout fd_set) {
|
||||
#if os(Android)
|
||||
+ #if arch(arm)
|
||||
+ set.fds_bits = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||
+ #else
|
||||
set.fds_bits = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||
+ #endif
|
||||
#else
|
||||
set.__fds_bits = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||
#endif
|
||||
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Darwin)
|
||||
|
29
packages/swift/swiftpm-swift-tools-support-core.patch
Normal file
29
packages/swift/swiftpm-swift-tools-support-core.patch
Normal file
@ -0,0 +1,29 @@
|
||||
diff --git a/swiftpm/swift-tools-support-core/Sources/TSCBasic/CMakeLists.txt b/swiftpm/swift-tools-support-core/Sources/TSCBasic/CMakeLists.txt
|
||||
index bbc43d98..bc5ee576 100644
|
||||
--- a/swiftpm/swift-tools-support-core/Sources/TSCBasic/CMakeLists.txt
|
||||
+++ b/swiftpm/swift-tools-support-core/Sources/TSCBasic/CMakeLists.txt
|
||||
@@ -53,7 +53,7 @@ target_link_libraries(TSCBasic PUBLIC
|
||||
TSCLibc)
|
||||
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
|
||||
target_link_libraries(TSCBasic PUBLIC
|
||||
- Foundation)
|
||||
+ Foundation android-spawn)
|
||||
endif()
|
||||
# NOTE(compnerd) workaround for CMake not setting up include flags yet
|
||||
set_target_properties(TSCBasic PROPERTIES
|
||||
diff --git a/swiftpm/swift-tools-support-core/Sources/TSCUtility/FSWatch.swift b/swiftpm/swift-tools-support-core/Sources/TSCUtility/FSWatch.swift
|
||||
index 0658e55b..9221950b 100644
|
||||
--- a/swiftpm/swift-tools-support-core/Sources/TSCUtility/FSWatch.swift
|
||||
+++ b/swiftpm/swift-tools-support-core/Sources/TSCUtility/FSWatch.swift
|
||||
@@ -429,7 +429,11 @@ public final class Inotify {
|
||||
|
||||
private func FD_ZERO(_ set: inout fd_set) {
|
||||
#if os(Android)
|
||||
+ #if arch(arm)
|
||||
+ set.fds_bits = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||
+ #else
|
||||
set.fds_bits = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||
+ #endif
|
||||
#else
|
||||
set.__fds_bits = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||
#endif
|
35
packages/swift/swiftpm-toolchain-stdlib.patch
Normal file
35
packages/swift/swiftpm-toolchain-stdlib.patch
Normal file
@ -0,0 +1,35 @@
|
||||
commit 8189d735d33f91e334725f1824eb9f61de78f138
|
||||
Date: Tue Apr 21 05:29:36 2020 +0530
|
||||
|
||||
On ELF platforms, remove host toolchain rpath from executables and shared libraries
|
||||
before installing.
|
||||
|
||||
diff --git a/swiftpm/Sources/PackageDescription/CMakeLists.txt b/swiftpm/Sources/PackageDescription/CMakeLists.txt
|
||||
index ea704129..0119cad7 100644
|
||||
--- a/swiftpm/Sources/PackageDescription/CMakeLists.txt
|
||||
+++ b/swiftpm/Sources/PackageDescription/CMakeLists.txt
|
||||
@@ -47,6 +47,8 @@ foreach(PACKAGE_DESCRIPTION_VERSION 4 4_2)
|
||||
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
|
||||
target_link_libraries(PD${PACKAGE_DESCRIPTION_VERSION} PRIVATE
|
||||
Foundation)
|
||||
+ target_link_options(PD${PACKAGE_DESCRIPTION_VERSION} PRIVATE
|
||||
+ "SHELL:-no-toolchain-stdlib-rpath")
|
||||
set_target_properties(PD${PACKAGE_DESCRIPTION_VERSION} PROPERTIES
|
||||
BUILD_WITH_INSTALL_RPATH TRUE
|
||||
INSTALL_RPATH "$ORIGIN/../../$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>")
|
||||
diff --git a/swiftpm/Utilities/bootstrap b/swiftpm/Utilities/bootstrap
|
||||
index ef703dc1..4ee5fff9 100755
|
||||
--- a/swiftpm/Utilities/bootstrap
|
||||
+++ b/swiftpm/Utilities/bootstrap
|
||||
@@ -678,6 +678,11 @@ def get_swiftpm_flags(args):
|
||||
if 'ANDROID_DATA' in os.environ:
|
||||
build_flags.extend(["-Xswiftc", "-Xcc", "-Xswiftc", "-U_GNU_SOURCE"])
|
||||
|
||||
+ # On ELF platforms, remove the host toolchain's stdlib absolute rpath from
|
||||
+ # installed executables and shared libraries.
|
||||
+ if platform.system() != "Darwin" and args.command == 'install':
|
||||
+ build_flags.extend(["-Xswiftc", "-no-toolchain-stdlib-rpath"])
|
||||
+
|
||||
build_target = get_build_target(args)
|
||||
cross_compile_hosts = args.cross_compile_hosts
|
||||
if build_target == 'x86_64-apple-macosx' and "macosx-arm64" in cross_compile_hosts:
|
Loading…
Reference in New Issue
Block a user