swift: update from 5.4.3 to 5.5

This commit is contained in:
Butta 2021-07-04 22:45:47 +05:30 committed by buttaface
parent 29b1221835
commit 0354a09676
24 changed files with 849 additions and 992 deletions

View File

@ -2,8 +2,8 @@ TERMUX_PKG_HOMEPAGE=https://github.com/apple/swift-corelibs-libdispatch
TERMUX_PKG_DESCRIPTION="The libdispatch project, for concurrency on multicore hardware" TERMUX_PKG_DESCRIPTION="The libdispatch project, for concurrency on multicore hardware"
TERMUX_PKG_LICENSE="Apache-2.0" TERMUX_PKG_LICENSE="Apache-2.0"
TERMUX_PKG_MAINTAINER="@buttaface" TERMUX_PKG_MAINTAINER="@buttaface"
_VERSION=5.4 _VERSION=5.5
TERMUX_PKG_VERSION=1:${_VERSION} TERMUX_PKG_VERSION=1:${_VERSION}
TERMUX_PKG_SRCURL=https://github.com/apple/swift-corelibs-libdispatch/archive/swift-${_VERSION}-RELEASE.tar.gz TERMUX_PKG_SRCURL=https://github.com/apple/swift-corelibs-libdispatch/archive/swift-${_VERSION}-RELEASE.tar.gz
TERMUX_PKG_SHA256=bafbcc1feaf8ac3a82edffde27b85820936cbfd0d194c9c1a320a13c356083c0 TERMUX_PKG_SHA256=5efdfa1d2897c598acea42fc00776477bb3713645686774f5ff0818b26649e62
TERMUX_PKG_DEPENDS="libc++, libblocksruntime" TERMUX_PKG_DEPENDS="libc++, libblocksruntime"

View File

@ -2,7 +2,7 @@ TERMUX_PKG_HOMEPAGE=https://github.com/apple/swift-llbuild
TERMUX_PKG_DESCRIPTION="A low-level build system, used by the Swift Package Manager" TERMUX_PKG_DESCRIPTION="A low-level build system, used by the Swift Package Manager"
TERMUX_PKG_LICENSE="Apache-2.0, NCSA" TERMUX_PKG_LICENSE="Apache-2.0, NCSA"
TERMUX_PKG_MAINTAINER="@buttaface" TERMUX_PKG_MAINTAINER="@buttaface"
TERMUX_PKG_VERSION=5.4 TERMUX_PKG_VERSION=5.5
TERMUX_PKG_SRCURL=https://github.com/apple/swift-llbuild/archive/swift-${TERMUX_PKG_VERSION}-RELEASE.tar.gz TERMUX_PKG_SRCURL=https://github.com/apple/swift-llbuild/archive/swift-${TERMUX_PKG_VERSION}-RELEASE.tar.gz
TERMUX_PKG_SHA256=91d3e454fff11b14bf89e6ab2b61bacb39395f92d5aab336923670aaa0a7e2fc TERMUX_PKG_SHA256=09e774c4a97bbb7473ab2b69ef2a547036660ce7d5d2c67802974de3e23381f8
TERMUX_PKG_DEPENDS="libc++, libandroid-spawn, libsqlite" TERMUX_PKG_DEPENDS="libc++, libandroid-spawn, libsqlite"

View File

@ -2,10 +2,10 @@ TERMUX_PKG_HOMEPAGE=https://swift.org/
TERMUX_PKG_DESCRIPTION="Swift is a high-performance system programming language" TERMUX_PKG_DESCRIPTION="Swift is a high-performance system programming language"
TERMUX_PKG_LICENSE="Apache-2.0, NCSA" TERMUX_PKG_LICENSE="Apache-2.0, NCSA"
TERMUX_PKG_MAINTAINER="@buttaface" TERMUX_PKG_MAINTAINER="@buttaface"
TERMUX_PKG_VERSION=5.4.3 TERMUX_PKG_VERSION=5.5
SWIFT_RELEASE="RELEASE" SWIFT_RELEASE="RELEASE"
TERMUX_PKG_SRCURL=https://github.com/apple/swift/archive/swift-$TERMUX_PKG_VERSION-$SWIFT_RELEASE.tar.gz TERMUX_PKG_SRCURL=https://github.com/apple/swift/archive/swift-$TERMUX_PKG_VERSION-$SWIFT_RELEASE.tar.gz
TERMUX_PKG_SHA256=b5eed91bff7667e469b13803a57d60f87c7ec136f4ebb01ae433b3ebc2b6c28b TERMUX_PKG_SHA256=0f76c429e65f24d48a2a18b18e7b380a5c97be0d4370271ac3623e436332fd35
TERMUX_PKG_HOSTBUILD=true 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_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, rsync" TERMUX_PKG_BUILD_DEPENDS="cmake, ninja, perl, pkg-config, rsync"
@ -38,22 +38,29 @@ termux_step_post_get_source() {
mv .temp swift mv .temp swift
declare -A library_checksums declare -A library_checksums
library_checksums[swift-cmark]=5cac6b095878105fc871fb268f22d6f3b4a3d3d5ed44c018c817c77d3d1ea724 library_checksums[swift-cmark]=689865cafeb0bd7eb1297cdd8ba06c43d072af921d36bdbdf6dbe3817b3bb27f
library_checksums[llvm-project]=efa12cb20f894ef34aaab9eb3cdc7fa6b94633ebb65db0fcf2a1f26f3bccab0d library_checksums[llvm-project]=87955764fb6cd83cb24e0421f249ce3fc817400edd3c0015eb840fe7fd7cf5e3
library_checksums[swift-corelibs-libdispatch]=4e78210507236a523038f489d660ca66e168bfd6d005d4df0a79f466a19206aa library_checksums[swift-corelibs-libdispatch]=5efdfa1d2897c598acea42fc00776477bb3713645686774f5ff0818b26649e62
library_checksums[swift-corelibs-foundation]=75b4a9098867cb85c54430cd9645f42ef4cb6946de8cd84ebdde6e70a451d8bb library_checksums[swift-corelibs-foundation]=4d58bd3ed05f8b2bf836e4868034f01272dddbd3c0385ddc6f2afc93da033464
library_checksums[swift-corelibs-xctest]=94154379381274e483caeb32f7b33b88906be7f78ac0413929dbeb4464bef02c library_checksums[swift-corelibs-xctest]=4dd3a3096c51b52817b0876ce18ea921cb0f71adf1992019e984d0d45e49b840
library_checksums[swift-llbuild]=69ab1466d79b0f95a04adf7c9c299aeedffde1d517b64a4c64e6c76b1f530556 library_checksums[swift-llbuild]=09e774c4a97bbb7473ab2b69ef2a547036660ce7d5d2c67802974de3e23381f8
library_checksums[swift-argument-parser]=6743338612be50a5a32127df0a3dd1c34e695f5071b1213f128e6e2b27c4364a library_checksums[swift-argument-parser]=9dfcb236f599e309e49af145610957648f8a59d9527b4202bc5bdda0068556d7
library_checksums[Yams]=8bbb28ef994f60afe54668093d652e4d40831c79885fa92b1c2cd0e17e26735a library_checksums[Yams]=8bbb28ef994f60afe54668093d652e4d40831c79885fa92b1c2cd0e17e26735a
library_checksums[swift-driver]=16a1161ca78c184f40937d07a997b2045abdd7cc8cf62102e3cda6249e329fd6 library_checksums[swift-crypto]=86d6c22c9f89394fd579e967b0d5d0b6ce33cdbf52ba70f82fa313baf70c759f
library_checksums[swift-tools-support-core]=7f8271fd9f9af2e1f889d918d7cd53bf7fad34ca04e0ab2a9a7a6cc1d3ad2cbe library_checksums[swift-driver]=e6c8ec5fc41f05ffd4c04b409278d0b4ec098402304b20d2997f06ea2ed2e4ed
library_checksums[swift-package-manager]=298ec9390941d50b2a71833ce1224bd8c4c1b5c68cc19fd83da4331f07f0e5c6 library_checksums[swift-tools-support-core]=4ae77edeb30a311d6d4bd5a4ed5ce7286d8fb3305d962a702a985297c82053d0
library_checksums[swift-package-manager]=89b240810b1c2adb86ba83a70ec384b75608a737f9af09f469c8ca968a85a30e
library_checksums[indexstore-db]=191711ad5d7638091b8c813335a7831c7e549a82b3fd480e368ed8ad7801d62d
library_checksums[sourcekit-lsp]=21bca4b8a84a4b687dc9ab1090fd3433915d7555445687ad82f1eaf3ec23c738
for library in "${!library_checksums[@]}"; do \ for library in "${!library_checksums[@]}"; do \
if [ "$library" = "swift-argument-parser" ]; then if [ "$library" = "swift-argument-parser" ]; then
GH_ORG="apple" GH_ORG="apple"
SRC_VERSION="0.4.1" SRC_VERSION="0.4.3"
TAR_NAME=$SRC_VERSION
elif [ "$library" = "swift-crypto" ]; then
GH_ORG="apple"
SRC_VERSION="1.1.5"
TAR_NAME=$SRC_VERSION TAR_NAME=$SRC_VERSION
elif [ "$library" = "Yams" ]; then elif [ "$library" = "Yams" ]; then
GH_ORG="jpsim" GH_ORG="jpsim"
@ -82,7 +89,7 @@ termux_step_post_get_source() {
termux_download \ termux_download \
https://swift.org/builds/swift-$TERMUX_PKG_VERSION-release/ubuntu2004/swift-$TERMUX_PKG_VERSION-$SWIFT_RELEASE/$SWIFT_BIN.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 \ $TERMUX_PKG_CACHEDIR/$SWIFT_BIN.tar.gz \
e5bf05aeb639999ae2134a86837dcaa7b80e2d9308849c79892e0144f906d56b aaf7eaefdc3f90f77b21b8829546fc2648e02928af476437d6a58556cb858ec6
fi fi
} }
@ -114,17 +121,8 @@ termux_step_pre_configure() {
cd .. cd ..
sed "s%\@TERMUX_PREFIX\@%${TERMUX_PREFIX}%g" \ sed "s%\@TERMUX_PREFIX\@%${TERMUX_PREFIX}%g" \
$TERMUX_PKG_BUILDER_DIR/swiftpm-Utilities-bootstrap | \ $TERMUX_PKG_BUILDER_DIR/swiftpm-driver-lsp-termux-flags | \
sed "s%\@TERMUX_PKG_BUILDDIR\@%${TERMUX_PKG_BUILDDIR}%g" | patch -p1 sed "s%\@CCTERMUX_HOST_PLATFORM\@%${CCTERMUX_HOST_PLATFORM}%g" | patch -p1
if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then
sed "s%\@TERMUX_STANDALONE_TOOLCHAIN\@%${TERMUX_STANDALONE_TOOLCHAIN}%g" \
$TERMUX_PKG_BUILDER_DIR/swiftpm-android-flags.json | \
sed "s%\@CCTERMUX_HOST_PLATFORM\@%${CCTERMUX_HOST_PLATFORM}%g" | \
sed "s%\@TERMUX_HOST_PLATFORM\@%${TERMUX_HOST_PLATFORM}%g" | \
sed "s%\@TERMUX_PREFIX\@%${TERMUX_PREFIX}%g" | \
sed "s%\@SWIFT_ARCH\@%${SWIFT_ARCH}%g" > $TERMUX_PKG_BUILDDIR/swiftpm-android-flags.json
fi
} }
termux_step_make() { termux_step_make() {
@ -141,17 +139,19 @@ termux_step_make() {
--android-icu-i18n-include $TERMUX_PREFIX/include/ --android-icu-i18n-include $TERMUX_PREFIX/include/
--android-icu-data $TERMUX_PREFIX/lib/libicudata.so --build-toolchain-only --android-icu-data $TERMUX_PREFIX/lib/libicudata.so --build-toolchain-only
--skip-local-build --skip-local-host-install --skip-local-build --skip-local-host-install
--cross-compile-hosts=android-$SWIFT_ARCH --cross-compile-deps-path=$TERMUX_PREFIX --cross-compile-hosts=android-$SWIFT_ARCH
--cross-compile-deps-path=$(dirname $TERMUX_PREFIX)
--native-swift-tools-path=$SWIFT_BINDIR --native-swift-tools-path=$SWIFT_BINDIR
--native-clang-tools-path=$TERMUX_STANDALONE_TOOLCHAIN/bin" --native-clang-tools-path=$TERMUX_STANDALONE_TOOLCHAIN/bin"
fi fi
SWIFT_BUILD_ROOT=$TERMUX_PKG_BUILDDIR $TERMUX_PKG_SRCDIR/swift/utils/build-script \ SWIFT_BUILD_ROOT=$TERMUX_PKG_BUILDDIR $TERMUX_PKG_SRCDIR/swift/utils/build-script \
$SWIFT_BUILD_FLAGS --xctest -b -p --android-api-level $TERMUX_PKG_API_LEVEL \ $SWIFT_BUILD_FLAGS --xctest -b -p --swift-driver --sourcekit-lsp \
--android-api-level $TERMUX_PKG_API_LEVEL \
--build-swift-static-stdlib --swift-install-components=$SWIFT_COMPONENTS \ --build-swift-static-stdlib --swift-install-components=$SWIFT_COMPONENTS \
--llvm-install-components=IndexStore --install-llvm --install-swift \ --llvm-install-components=IndexStore --install-llvm --install-swift \
--install-libdispatch --install-foundation --install-xctest --install-llbuild \ --install-libdispatch --install-foundation --install-xctest --install-llbuild \
--install-swiftpm --install-swiftpm --install-swift-driver --install-sourcekit-lsp
} }
termux_step_make_install() { termux_step_make_install() {
@ -159,6 +159,7 @@ termux_step_make_install() {
rm $TERMUX_PREFIX/lib/swift/android/lib{dispatch,BlocksRuntime}.so rm $TERMUX_PREFIX/lib/swift/android/lib{dispatch,BlocksRuntime}.so
if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then
rm $TERMUX_PREFIX/swiftpm-android-$SWIFT_ARCH.json
mv $TERMUX_PREFIX/glibc-native.modulemap \ mv $TERMUX_PREFIX/glibc-native.modulemap \
$TERMUX_PREFIX/lib/swift/android/$SWIFT_ARCH/glibc.modulemap $TERMUX_PREFIX/lib/swift/android/$SWIFT_ARCH/glibc.modulemap
fi fi

View File

@ -10,7 +10,7 @@ diff --git a/swift-corelibs-foundation/Sources/Tools/plutil/CMakeLists.txt b/swi
index 7f2913b3..3c9163c1 100644 index 7f2913b3..3c9163c1 100644
--- a/swift-corelibs-foundation/Sources/Tools/plutil/CMakeLists.txt --- a/swift-corelibs-foundation/Sources/Tools/plutil/CMakeLists.txt
+++ b/swift-corelibs-foundation/Sources/Tools/plutil/CMakeLists.txt +++ b/swift-corelibs-foundation/Sources/Tools/plutil/CMakeLists.txt
@@ -2,6 +2,30 @@ add_executable(plutil @@ -2,10 +2,37 @@ add_executable(plutil
main.swift) main.swift)
target_link_libraries(plutil PRIVATE target_link_libraries(plutil PRIVATE
Foundation) Foundation)
@ -41,3 +41,10 @@ index 7f2913b3..3c9163c1 100644
set_target_properties(plutil PROPERTIES set_target_properties(plutil PROPERTIES
INSTALL_RPATH "$ORIGIN/../lib/swift/$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>") INSTALL_RPATH "$ORIGIN/../lib/swift/$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>")
set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS plutil)
+if(NOT BUILD_SHARED_LIBS AND ${CMAKE_SYSTEM_PROCESSOR} STREQUAL armv7-a)
+ target_link_libraries(plutil PRIVATE gcc_real)
+endif()
install(TARGETS plutil
DESTINATION ${CMAKE_INSTALL_BINDIR})

View File

@ -0,0 +1,104 @@
diff --git a/sourcekit-lsp/Utilities/build-script-helper.py b/sourcekit-lsp/Utilities/build-script-helper.py
index 58f8676..7fa6a46 100755
--- a/sourcekit-lsp/Utilities/build-script-helper.py
+++ b/sourcekit-lsp/Utilities/build-script-helper.py
@@ -5,6 +5,7 @@ from __future__ import print_function
import argparse
import os
import platform
+import re
import shutil
import subprocess
import sys
@@ -50,25 +51,28 @@ def get_swiftpm_options(args):
os.path.join(args.toolchain, 'lib', 'swift', 'Block'),
]
- if 'ANDROID_DATA' in os.environ:
- swiftpm_args += [
- '-Xlinker', '-rpath', '-Xlinker', '$ORIGIN/../lib/swift/android',
- # SwiftPM will otherwise try to compile against GNU strerror_r on
- # Android and fail.
- '-Xswiftc', '-Xcc', '-Xswiftc', '-U_GNU_SOURCE',
- ]
- else:
- # Library rpath for swift, dispatch, Foundation, etc. when installing
- swiftpm_args += [
- '-Xlinker', '-rpath', '-Xlinker', '$ORIGIN/../lib/swift/linux',
- ]
+ if 'ANDROID_DATA' in os.environ or (args.cross_compile_host and re.match(
+ 'android-', args.cross_compile_host)):
+ swiftpm_args += [
+ '-Xlinker', '-rpath', '-Xlinker', '$ORIGIN/../lib/swift/android',
+ # SwiftPM will otherwise try to compile against GNU strerror_r on
+ # Android and fail.
+ '-Xswiftc', '-Xcc', '-Xswiftc', '-U_GNU_SOURCE',
+ ]
+ elif platform.system() == 'Linux':
+ # Library rpath for swift, dispatch, Foundation, etc. when installing
+ swiftpm_args += [
+ '-Xlinker', '-rpath', '-Xlinker', '$ORIGIN/../lib/swift/linux',
+ ]
+
+ if args.cross_compile_host:
+ swiftpm_args += ['--destination', args.cross_compile_config]
return swiftpm_args
-def install(swiftpm_bin_path, toolchain):
- toolchain_bin = os.path.join(toolchain, 'bin')
- for exe in ['sourcekit-lsp']:
- install_binary(exe, swiftpm_bin_path, toolchain_bin, toolchain)
+def install(swiftpm_bin_path, prefixes, toolchain):
+ for prefix in prefixes:
+ install_binary('sourcekit-lsp', swiftpm_bin_path, os.path.join(prefix, 'bin'), toolchain)
def install_binary(exe, source_dir, install_dir, toolchain):
cmd = ['rsync', '-a', os.path.join(source_dir, exe), install_dir]
@@ -112,6 +116,8 @@ def handle_invocation(swift_exec, args):
print('Cleaning ' + args.build_path)
shutil.rmtree(args.build_path, ignore_errors=True)
+ env['SWIFT_EXEC'] = '%sc' % (swift_exec)
+
if args.action == 'build':
swiftpm('build', swift_exec, swiftpm_args, env)
elif args.action == 'test':
@@ -131,7 +137,7 @@ def handle_invocation(swift_exec, args):
bin_path = swiftpm_bin_path(swift_exec, swiftpm_args, env)
swiftpm_args += ['-Xswiftc', '-no-toolchain-stdlib-rpath']
swiftpm('build', swift_exec, swiftpm_args, env)
- install(bin_path, args.toolchain)
+ install(bin_path, args.install_prefixes if not None else [args.toolchain], args.toolchain)
else:
assert False, 'unknown action \'{}\''.format(args.action)
@@ -148,6 +154,8 @@ def main():
parser.add_argument('--sanitize', action='append', help='build using the given sanitizer(s) (address|thread|undefined)')
parser.add_argument('--sanitize-all', action='store_true', help='build using every available sanitizer in sub-directories of build path')
parser.add_argument('--verbose', '-v', action='store_true', help='enable verbose output')
+ parser.add_argument('--cross-compile-host', help='cross-compile for another host instead')
+ parser.add_argument('--cross-compile-config', help='an SPM JSON destination file containing Swift cross-compilation flags')
subparsers = parser.add_subparsers(title='subcommands', dest='action', metavar='action')
build_parser = subparsers.add_parser('build', help='build the package')
@@ -159,6 +167,7 @@ def main():
install_parser = subparsers.add_parser('install', help='build the package')
add_common_args(install_parser)
+ install_parser.add_argument('--prefix', dest='install_prefixes', nargs='*', metavar='PATHS', help="paths to install sourcekit-lsp, default: 'toolchain/bin'")
args = parser.parse_args(sys.argv[1:])
@@ -175,6 +184,11 @@ def main():
else:
swift_exec = 'swift'
+ if args.cross_compile_host and re.match('android-', args.cross_compile_host):
+ print('Cross-compiling for %s' % args.cross_compile_host)
+ elif args.cross_compile_host:
+ error("cannot cross-compile for %s" % args.cross_compile_host)
+
handle_invocation(swift_exec, args)
if args.sanitize_all:
base = args.build_path

View File

@ -0,0 +1,2 @@
TERMUX_SUBPKG_DESCRIPTION="Language Server Protocol implementation for Swift and C-based languages"
TERMUX_SUBPKG_INCLUDE="bin/sourcekit-lsp"

View File

@ -6,11 +6,30 @@ index b7503ecdd6..c643c2c9a5 100644
set(SWIFT_USE_LINKER_default "lld") set(SWIFT_USE_LINKER_default "lld")
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin) elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
set(SWIFT_USE_LINKER_default "") set(SWIFT_USE_LINKER_default "")
+elseif("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "ANDROID") +elseif("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "ANDROID" AND NOT "${SWIFT_HOST_VARIANT_ARCH}" STREQUAL "armv7")
+ set(SWIFT_USE_LINKER_default "lld") + set(SWIFT_USE_LINKER_default "lld")
else() else()
set(SWIFT_USE_LINKER_default "gold") set(SWIFT_USE_LINKER_default "gold")
endif() endif()
@@ -463,7 +463,7 @@ set(SWIFT_BUILD_HOST_DISPATCH FALSE)
if(SWIFT_ENABLE_DISPATCH AND NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
# Only build libdispatch for the host if the host tools are being built and
# specifically if these two libraries that depend on it are built.
- if(SWIFT_INCLUDE_TOOLS AND (SWIFT_BUILD_SYNTAXPARSERLIB OR SWIFT_BUILD_SOURCEKIT))
+ if(NOT ${SWIFT_HOST_VARIANT_SDK} STREQUAL ANDROID AND SWIFT_INCLUDE_TOOLS AND (SWIFT_BUILD_SYNTAXPARSERLIB OR SWIFT_BUILD_SOURCEKIT))
set(SWIFT_BUILD_HOST_DISPATCH TRUE)
endif()
@@ -976,7 +976,8 @@ if (LLVM_ENABLE_DOXYGEN)
endif()
if(SWIFT_ENABLE_DISPATCH)
- include(Libdispatch)
+# Use the Termux libdispatch instead.
+# include(Libdispatch)
endif()
# Add all of the subdirectories, where we actually do work.
diff --git a/swift/localization/CMakeLists.txt b/swift/localization/CMakeLists.txt diff --git a/swift/localization/CMakeLists.txt b/swift/localization/CMakeLists.txt
index 07a3585a66c..461a98b6856 100644 index 07a3585a66c..461a98b6856 100644
--- a/swift/localization/CMakeLists.txt --- a/swift/localization/CMakeLists.txt
@ -25,6 +44,29 @@ index 07a3585a66c..461a98b6856 100644
PATTERN "*.yaml" PATTERN "*.yaml"
) )
+endif() +endif()
diff --git a/swift/stdlib/public/Concurrency/CMakeLists.txt b/swift/stdlib/public/Concurrency/CMakeLists.txt
index 3313f56c8a6..59804ff6228 100644
--- a/swift/stdlib/public/Concurrency/CMakeLists.txt
+++ b/swift/stdlib/public/Concurrency/CMakeLists.txt
@@ -27,8 +27,8 @@ if(SWIFT_CONCURRENCY_USES_DISPATCH)
# FIXME: we can't rely on libdispatch having been built for the
# target at this point in the process. Currently, we're relying
# on soft-linking.
- list(APPEND swift_concurrency_link_libraries
- dispatch)
+ #list(APPEND swift_concurrency_link_libraries
+ # dispatch)
endif()
endif()
@@ -87,6 +87,6 @@ add_swift_target_library(swift_Concurrency ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} I
-Xfrontend -enable-experimental-concurrency
-Xfrontend -define-availability
-Xfrontend \"SwiftStdlib 5.5:macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0\"
- LINK_FLAGS "${SWIFT_RUNTIME_CONCURRENCY_SWIFT_LINK_FLAGS}"
+ LINK_FLAGS "${SWIFT_RUNTIME_CONCURRENCY_SWIFT_LINK_FLAGS};-ldispatch"
INSTALL_IN_COMPONENT stdlib
)
diff --git a/swift/stdlib/public/Platform/CMakeLists.txt b/swift/stdlib/public/Platform/CMakeLists.txt diff --git a/swift/stdlib/public/Platform/CMakeLists.txt b/swift/stdlib/public/Platform/CMakeLists.txt
index 8ded40c5791..c811000b1d1 100644 index 8ded40c5791..c811000b1d1 100644
--- a/swift/stdlib/public/Platform/CMakeLists.txt --- a/swift/stdlib/public/Platform/CMakeLists.txt
@ -33,7 +75,7 @@ index 8ded40c5791..c811000b1d1 100644
OUTPUT "${glibc_modulemap_out}" OUTPUT "${glibc_modulemap_out}"
FLAGS FLAGS
"-DCMAKE_SDK=${sdk}" "-DCMAKE_SDK=${sdk}"
+ "-DTERMUX_INCLUDE_PATH=@TERMUX_PREFIX@/include" + "-DTERMUX_INCLUDE_PATH=${SWIFT_ANDROID_NATIVE_SYSROOT}/usr/include"
"-DGLIBC_INCLUDE_PATH=${SWIFT_SDK_${sdk}_ARCH_${arch}_LIBC_INCLUDE_DIRECTORY}" "-DGLIBC_INCLUDE_PATH=${SWIFT_SDK_${sdk}_ARCH_${arch}_LIBC_INCLUDE_DIRECTORY}"
"-DGLIBC_ARCH_INCLUDE_PATH=${SWIFT_SDK_${sdk}_ARCH_${arch}_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY}") "-DGLIBC_ARCH_INCLUDE_PATH=${SWIFT_SDK_${sdk}_ARCH_${arch}_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY}")
@ -50,15 +92,15 @@ index 8ded40c5791..c811000b1d1 100644
- string(REPLACE "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${arch}_PATH}" - string(REPLACE "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${arch}_PATH}"
- "" absolute_libc_arch_include_path ${SWIFT_SDK_${sdk}_ARCH_${arch}_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY}) - "" absolute_libc_arch_include_path ${SWIFT_SDK_${sdk}_ARCH_${arch}_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY})
+ string(REPLACE "${SWIFT_SDK_${sdk}_ARCH_${arch}_PATH}/usr" + string(REPLACE "${SWIFT_SDK_${sdk}_ARCH_${arch}_PATH}/usr"
+ "@TERMUX_PREFIX@" absolute_libc_include_path "${SWIFT_SDK_${sdk}_ARCH_${arch}_LIBC_INCLUDE_DIRECTORY}") + "${SWIFT_ANDROID_NATIVE_SYSROOT}/usr" absolute_libc_include_path "${SWIFT_SDK_${sdk}_ARCH_${arch}_LIBC_INCLUDE_DIRECTORY}")
+ string(REPLACE "${SWIFT_SDK_${sdk}_ARCH_${arch}_PATH}/usr" + string(REPLACE "${SWIFT_SDK_${sdk}_ARCH_${arch}_PATH}/usr"
+ "@TERMUX_PREFIX@" absolute_libc_arch_include_path ${SWIFT_SDK_${sdk}_ARCH_${arch}_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY}) + "${SWIFT_ANDROID_NATIVE_SYSROOT}/usr" absolute_libc_arch_include_path ${SWIFT_SDK_${sdk}_ARCH_${arch}_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY})
handle_gyb_source_single(glibc_modulemap_native_target handle_gyb_source_single(glibc_modulemap_native_target
SOURCE "${glibc_modulemap_source}" SOURCE "${glibc_modulemap_source}"
OUTPUT "${glibc_sysroot_relative_modulemap_out}" OUTPUT "${glibc_sysroot_relative_modulemap_out}"
FLAGS "-DCMAKE_SDK=${sdk}" FLAGS "-DCMAKE_SDK=${sdk}"
+ "-DTERMUX_INCLUDE_PATH=@TERMUX_PREFIX@/include" + "-DTERMUX_INCLUDE_PATH=${SWIFT_ANDROID_NATIVE_SYSROOT}/usr/include"
"-DGLIBC_INCLUDE_PATH=${absolute_libc_include_path}" "-DGLIBC_INCLUDE_PATH=${absolute_libc_include_path}"
"-DGLIBC_ARCH_INCLUDE_PATH=${absolute_libc_arch_include_path}") "-DGLIBC_ARCH_INCLUDE_PATH=${absolute_libc_arch_include_path}")
@ -96,6 +138,19 @@ index 23ac72bcda5..23aecfc9bc5 100644
DESTINATION "lib/swift_static") DESTINATION "lib/swift_static")
endif() endif()
diff --git a/swift/stdlib/public/runtime/CMakeLists.txt b/swift/stdlib/public/runtime/CMakeLists.txt
index 86bb4b9666b..cf293f9f36f 100644
--- a/swift/stdlib/public/runtime/CMakeLists.txt
+++ b/swift/stdlib/public/runtime/CMakeLists.txt
@@ -227,7 +227,7 @@ foreach(sdk ${SWIFT_SDKS})
endif()
set(libpthread -lpthread)
set(android_libraries)
- if(sdk STREQUAL ANDROID)
+ if(${sdk} STREQUAL ANDROID)
set(android_libraries -llog)
set(libpthread)
endif()
diff --git a/swift/tools/SourceKit/cmake/modules/AddSwiftSourceKit.cmake b/swift/tools/SourceKit/cmake/modules/AddSwiftSourceKit.cmake diff --git a/swift/tools/SourceKit/cmake/modules/AddSwiftSourceKit.cmake b/swift/tools/SourceKit/cmake/modules/AddSwiftSourceKit.cmake
index 7a77e125f95..7eddfea2054 100644 index 7a77e125f95..7eddfea2054 100644
--- a/swift/tools/SourceKit/cmake/modules/AddSwiftSourceKit.cmake --- a/swift/tools/SourceKit/cmake/modules/AddSwiftSourceKit.cmake

View File

@ -1,13 +1,22 @@
--- a/swift-corelibs-foundation/Sources/Foundation/CMakeLists.txt 2020-12-13 15:31:11.444709471 +0000 diff --git a/swift-corelibs-foundation/Sources/Foundation/CMakeLists.txt b/swift-corelibs-foundation/Sources/Foundation/CMakeLists.txt
+++ b/swift-corelibs-foundation/Sources/Foundation/CMakeLists.txt 2020-12-13 15:31:45.594845323 +0000 index 016bf294..cd534f16 100644
@@ -145,8 +145,10 @@ --- a/swift-corelibs-foundation/Sources/Foundation/CMakeLists.txt
$<$<PLATFORM_ID:Windows>:pathcch> +++ b/swift-corelibs-foundation/Sources/Foundation/CMakeLists.txt
CoreFoundation @@ -166,7 +166,17 @@ if(CMAKE_SYSTEM_NAME STREQUAL Windows)
uuid target_link_options(Foundation PRIVATE
+ android-spawn $<TARGET_OBJECTS:CoreFoundationResources>)
PUBLIC elseif(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
swiftDispatch) + if(NOT BUILD_SHARED_LIBS)
+ target_compile_options(Foundation PRIVATE "SHELL:-disallow-use-new-driver")
+ endif()
target_link_options(Foundation PRIVATE "SHELL:-no-toolchain-stdlib-rpath")
+ if(${CMAKE_SYSTEM_NAME} STREQUAL Android)
+ target_link_libraries(Foundation PRIVATE android-spawn)
+ target_link_directories(Foundation PUBLIC ${CMAKE_FIND_ROOT_PATH}/usr/lib) + target_link_directories(Foundation PUBLIC ${CMAKE_FIND_ROOT_PATH}/usr/lib)
set_target_properties(Foundation PROPERTIES + if(BUILD_SHARED_LIBS AND ${CMAKE_SYSTEM_PROCESSOR} STREQUAL armv7-a)
INSTALL_RPATH "$ORIGIN" + target_link_libraries(Foundation PRIVATE gcc_real)
BUILD_RPATH "$<TARGET_FILE_DIR:swiftDispatch>" + endif()
+ endif()
endif()

View File

@ -1,43 +0,0 @@
From 0f8ab3e42a4a052dec0e4b66c252fd83e8e5ba7c Mon Sep 17 00:00:00 2001
Date: Wed, 2 Dec 2020 18:33:48 +0530
Subject: [PATCH] [android] Put in fixes for librt and armv7-a
Android doesn't have a separate librt, it's just part of libc. Also, the static
build wasn't working for armv7-a, because the test executables wouldn't link
with the multiple definition errors listed in android/ndk#176, so use the
workaround given there.
diff --git a/swift-corelibs-libdispatch/CMakeLists.txt b/swift-corelibs-libdispatch/CMakeLists.txt
index 75c419c13..36da01122 100644
--- a/swift-corelibs-libdispatch/CMakeLists.txt
+++ b/swift-corelibs-libdispatch/CMakeLists.txt
@@ -113,7 +113,9 @@ if(__BUILTIN_TRAP)
set(HAVE_NORETURN_BUILTIN_TRAP 1)
endif()
-find_package(LibRT)
+if(NOT CMAKE_SYSTEM_NAME STREQUAL Android)
+ find_package(LibRT)
+endif()
check_function_exists(_pthread_workqueue_init HAVE__PTHREAD_WORKQUEUE_INIT)
check_function_exists(getprogname HAVE_GETPROGNAME)
diff --git a/swift-corelibs-libdispatch/tests/CMakeLists.txt b/swift-corelibs-libdispatch/tests/CMakeLists.txt
index a27603559..0176a062b 100644
--- a/swift-corelibs-libdispatch/tests/CMakeLists.txt
+++ b/swift-corelibs-libdispatch/tests/CMakeLists.txt
@@ -88,6 +88,14 @@ function(add_unit_test name)
target_compile_options(${name} PRIVATE -fblocks)
target_compile_options(${name} PRIVATE -Wall -Wno-deprecated-declarations)
endif()
+ # Without this flag, cross-compiling static test executables for Android armv7
+ # fails with the multiple definition errors seen in android/ndk#176, so I
+ # pulled in this workaround noted there. The tests build and run with this
+ # flag applied.
+ if(NOT BUILD_SHARED_LIBS AND CMAKE_SYSTEM_NAME STREQUAL Android AND
+ CMAKE_SYSTEM_PROCESSOR STREQUAL armv7-a)
+ target_link_options(${name} PRIVATE "LINKER:--allow-multiple-definition")
+ endif()
target_link_libraries(${name}
PRIVATE
dispatch

View File

@ -0,0 +1,26 @@
From 8dda3589e3e9fc940e8704a083a54a647ffde795
From: Saleem Abdulrasool <compnerd@compnerd.org>
Date: Fri, 23 Jul 2021 09:26:48 -0700
Subject: [PATCH] Jobs: do not inject the swiftautolink file into archives
It has been observed that a static library may sometimes contain the
autolink extracted rules. This causes autolink-extract to not be able
to process the archive as a dependency, causing a build failure.
---
.../SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/swift-driver/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift b/swift-driver/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift
index a08e3fa1..93eceb72 100644
--- a/swift-driver/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift
+++ b/swift-driver/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift
@@ -290,7 +290,8 @@ extension GenericUnixToolchain {
commandLine.appendFlag("crs")
commandLine.appendPath(outputFile)
- commandLine.append(contentsOf: inputs.map { .path($0.file) })
+ commandLine.append(contentsOf: inputs.filter { $0.type == .object }
+ .map { .path($0.file) })
return try getToolPath(.staticLinker(lto))
}

View File

@ -0,0 +1,106 @@
diff --git a/swift-driver/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift b/swift-driver/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift
index 06a29d8..5cbfddd 100644
--- a/swift-driver/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift
+++ b/swift-driver/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift
@@ -133,8 +137,7 @@ extension GenericUnixToolchain {
isShared: hasRuntimeArgs
)
- if hasRuntimeArgs && targetTriple.environment != .android &&
- toolchainStdlibRpath {
+ if hasRuntimeArgs && toolchainStdlibRpath {
// FIXME: We probably shouldn't be adding an rpath here unless we know
// ahead of time the standard library won't be copied.
for path in runtimePaths {
diff --git a/swift-driver/Utilities/build-script-helper.py b/swift-driver/Utilities/build-script-helper.py
index e986475..83916c3 100755
--- a/swift-driver/Utilities/build-script-helper.py
+++ b/swift-driver/Utilities/build-script-helper.py
@@ -11,6 +11,7 @@ import shutil
import subprocess
import sys
import errno
+import re
if platform.system() == 'Darwin':
shared_lib_ext = '.dylib'
@@ -96,7 +97,11 @@ def get_swiftpm_options(args):
os.path.join(args.toolchain, 'lib', 'swift', 'Block'),
]
- if 'ANDROID_DATA' in os.environ:
+ if args.cross_compile_hosts:
+ swiftpm_args += [ '--destination', args.cross_compile_config ]
+
+ if 'ANDROID_DATA' in os.environ or (args.cross_compile_hosts and re.match(
+ 'android-', args.cross_compile_hosts[0])):
swiftpm_args += [
'-Xlinker', '-rpath', '-Xlinker', '$ORIGIN/../lib/swift/android',
# SwiftPM will otherwise try to compile against GNU strerror_r on
@@ -177,8 +185,13 @@ def handle_invocation(args):
if args.sysroot:
env['SDKROOT'] = args.sysroot
+ env['SWIFT_EXEC'] = '%sc' % (swift_exec)
+
if args.action == 'build':
- build_using_cmake(args, toolchain_bin, args.build_path, targets)
+ if args.cross_compile_hosts and not re.match('-macosx', args.cross_compile_hosts[0]):
+ swiftpm('build', swift_exec, swiftpm_args, env)
+ else:
+ build_using_cmake(args, toolchain_bin, args.build_path, targets)
elif args.action == 'clean':
print('Cleaning ' + args.build_path)
@@ -188,7 +201,6 @@ def handle_invocation(args):
tool_path = os.path.join(toolchain_bin, tool)
if os.path.exists(tool_path):
env['SWIFT_DRIVER_' + tool.upper().replace('-','_') + '_EXEC'] = '%s' % (tool_path)
- env['SWIFT_EXEC'] = '%sc' % (swift_exec)
test_args = swiftpm_args
test_args += ['-Xswiftc', '-enable-testing']
if should_test_parallel():
@@ -205,16 +217,17 @@ def handle_invocation(args):
else:
bin_path = swiftpm_bin_path(swift_exec, swiftpm_args, env)
swiftpm('build', swift_exec, swiftpm_args, env)
- non_darwin_install(bin_path, args.toolchain, args.verbose)
+ non_darwin_install(args, bin_path)
else:
assert False, 'unknown action \'{}\''.format(args.action)
# Installation flow for non-darwin platforms, only copies over swift-driver and swift-help
# TODO: Unify CMake-based installation flow used on Darwin with this
-def non_darwin_install(swiftpm_bin_path, toolchain, verbose):
- toolchain_bin = os.path.join(toolchain, 'bin')
- for exe in executables_to_install:
- install_binary(exe, swiftpm_bin_path, toolchain_bin, verbose)
+def non_darwin_install(args, swiftpm_bin_path):
+ for prefix in args.install_prefixes:
+ prefix_bin = os.path.join(prefix, 'bin')
+ for exe in executables_to_install:
+ install_binary(exe, swiftpm_bin_path, prefix_bin, args.verbose)
def install(args, build_dir, targets):
# Construct and install universal swift-driver, swift-help executables
@@ -581,6 +594,10 @@ def main():
nargs='*',
help='List of cross compile hosts targets.',
default=[])
+ parser.add_argument(
+ '--cross-compile-config',
+ metavar='PATH',
+ help="A JSON SPM config file with Swift flags for cross-compilation")
parser.add_argument('--ninja-bin', metavar='PATH', help='ninja binary to use for testing')
parser.add_argument('--cmake-bin', metavar='PATH', help='cmake binary to use for building')
parser.add_argument('--build-path', metavar='PATH', default='.build', help='build in the given path')
@@ -617,9 +634,6 @@ def main():
else:
args.sysroot = None
- if args.cross_compile_hosts and not all('apple-macos' in target for target in args.cross_compile_hosts):
- error('Cross-compilation is currently only supported for the Darwin platform.')
-
if args.cross_compile_hosts and args.local_compiler_build:
error('Cross-compilation is currently not supported for the local compiler installation')

View File

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

View File

@ -1,229 +0,0 @@
diff --git a/swift/CMakeLists.txt b/swift/CMakeLists.txt
index 8be6f4a7abd7..77e81153a232 100644
--- a/swift/CMakeLists.txt
+++ b/swift/CMakeLists.txt
@@ -481,10 +481,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 c4c15084fe90..9ee086565891 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/CMakeLists.txt b/swift/stdlib/CMakeLists.txt
index edf7c19f4b7a..91d9f4c28a51 100644
--- a/swift/stdlib/CMakeLists.txt
+++ b/swift/stdlib/CMakeLists.txt
@@ -112,11 +112,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/stdlib/cmake/modules/AddSwiftStdlib.cmake b/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake
index 2a6e1d1df071..d5df9c57dd33 100644
--- a/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake
+++ b/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake
@@ -1669,7 +1669,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 926020372fb2..5ee8a9c92069 100644
--- a/swift/stdlib/public/SwiftShims/CMakeLists.txt
+++ b/swift/stdlib/public/SwiftShims/CMakeLists.txt
@@ -111,7 +111,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
diff --git a/swift/unittests/runtime/CMakeLists.txt b/swift/unittests/runtime/CMakeLists.txt
index 60f9944e1e64..2ca86bf2b407 100644
--- a/swift/unittests/runtime/CMakeLists.txt
+++ b/swift/unittests/runtime/CMakeLists.txt
@@ -13,11 +13,11 @@ if(("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "${SWIFT_PRIMARY_VARIANT_SDK}") AND
# 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-presets.ini b/swift/utils/build-presets.ini
index 5330b5acba18..dcba1e6d7b74 100644
--- a/swift/utils/build-presets.ini
+++ b/swift/utils/build-presets.ini
@@ -2283,10 +2283,9 @@ skip-build-cmark
skip-build-benchmarks
skip-test-cmark
-# This triggers the stdlib standalone build: Don't build tools (the compiler),
-# assume we are working with the host compiler.
+# This triggers the stdlib standalone build: don't build the native tools from
+# scratch, ie the compiler.
build-swift-tools=0
-build-runtime-with-host-compiler=1
# Then set the paths to our native tools. If compiling against a toolchain,
# these should all be the ./usr/bin directory.
diff --git a/swift/utils/build-script b/swift/utils/build-script
index ab9809b1351c..f544478b2a57 100755
--- a/swift/utils/build-script
+++ b/swift/utils/build-script
@@ -707,6 +707,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-script-impl b/swift/utils/build-script-impl
index 268d23de155a..7ac53c1e5a91 100755
--- a/swift/utils/build-script-impl
+++ b/swift/utils/build-script-impl
@@ -1485,13 +1485,6 @@ for host in "${ALL_HOSTS[@]}"; do
fi
fi
- if [[ "${NATIVE_CLANG_TOOLS_PATH}" ]] ; then
- common_cmake_options_host+=(
- -DCMAKE_C_COMPILER="${NATIVE_CLANG_TOOLS_PATH}/clang"
- -DCMAKE_CXX_COMPILER="${NATIVE_CLANG_TOOLS_PATH}/clang++"
- )
- fi
-
llvm_cmake_options=(
"${llvm_cmake_options[@]}"
-DCMAKE_INSTALL_PREFIX:PATH="$(get_host_install_prefix ${host})"
diff --git a/swift/utils/build_swift/build_swift/driver_arguments.py b/swift/utils/build_swift/build_swift/driver_arguments.py
index 28a3ec0e6ab2..aab24712b801 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/build_swift/tests/expected_options.py b/swift/utils/build_swift/tests/expected_options.py
index 8f13cca65b9c..9ecfc4714312 100644
--- a/swift/utils/build_swift/tests/expected_options.py
+++ b/swift/utils/build_swift/tests/expected_options.py
@@ -189,6 +189,9 @@ EXPECTED_DEFAULTS = {
'lto_type': None,
'maccatalyst': False,
'maccatalyst_ios_tests': False,
+ 'native_clang_tools_path': None,
+ 'native_llvm_tools_path': None,
+ 'native_swift_tools_path': None,
'dump_config': False,
'relocate_xdg_cache_home_under_build_subdir': False,
'show_sdks': False,
@@ -658,6 +661,9 @@ EXPECTED_OPTIONS = [
PathOption('--install-symroot'),
PathOption('--install-destdir'),
EnableOption('--install-all'),
+ PathOption('--native-clang-tools-path'),
+ PathOption('--native-llvm-tools-path'),
+ PathOption('--native-swift-tools-path'),
PathOption('--symbols-package'),
PathOption('--cmake-c-launcher'),
PathOption('--cmake-cxx-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..075b934d10ac 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
@@ -167,8 +167,11 @@ def install_toolchain_path(self, host_target):
"""toolchain_path() -> string
Returns the path to the toolchain that is being created as part of this
- build.
+ build, or to a native prebuilt toolchain that was passed in.
"""
+ 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)

View File

@ -1,62 +0,0 @@
commit 86c40574f594f4f7b4b25bb02cc2389e1328c200
Date: Fri Nov 13 17:22:09 2020 +0530
[build] Don't build test targets in tools/ if SWIFT_INCLUDE_TESTS is turned off
diff --git a/swift/tools/CMakeLists.txt b/swift/tools/CMakeLists.txt
index 2bd8352bf273..ea610709e2f5 100644
--- a/swift/tools/CMakeLists.txt
+++ b/swift/tools/CMakeLists.txt
@@ -16,13 +16,10 @@ endif()
add_swift_tool_subdirectory(driver)
add_swift_tool_subdirectory(sil-opt)
add_swift_tool_subdirectory(swift-dependency-tool)
-add_swift_tool_subdirectory(swift-ide-test)
-add_swift_tool_subdirectory(swift-remoteast-test)
add_swift_tool_subdirectory(swift-demangle)
add_swift_tool_subdirectory(swift-demangle-yamldump)
add_swift_tool_subdirectory(swift-def-to-yaml-converter)
add_swift_tool_subdirectory(swift-serialize-diagnostics)
-add_swift_tool_subdirectory(lldb-moduleimport-test)
add_swift_tool_subdirectory(sil-func-extractor)
add_swift_tool_subdirectory(sil-llvm-gen)
add_swift_tool_subdirectory(sil-nm)
@@ -30,11 +27,19 @@ add_swift_tool_subdirectory(sil-passpipeline-dumper)
add_swift_tool_subdirectory(swift-llvm-opt)
add_swift_tool_subdirectory(swift-api-digester)
add_swift_tool_subdirectory(swift-ast-script)
-add_swift_tool_subdirectory(swift-syntax-test)
add_swift_tool_subdirectory(swift-refactor)
if(SWIFT_BUILD_SYNTAXPARSERLIB)
add_swift_tool_subdirectory(libSwiftSyntaxParser)
- add_swift_tool_subdirectory(swift-syntax-parser-test)
+ if(SWIFT_INCLUDE_TESTS)
+ add_swift_tool_subdirectory(swift-syntax-parser-test)
+ endif()
+endif()
+
+if(SWIFT_INCLUDE_TESTS)
+ add_swift_tool_subdirectory(swift-ide-test)
+ add_swift_tool_subdirectory(swift-remoteast-test)
+ add_swift_tool_subdirectory(lldb-moduleimport-test)
+ add_swift_tool_subdirectory(swift-syntax-test)
endif()
if(LLVM_USE_SANITIZE_COVERAGE)
diff --git a/swift/tools/SourceKit/tools/CMakeLists.txt b/swift/tools/SourceKit/tools/CMakeLists.txt
index 739078c36e52..75cf0861b11e 100644
--- a/swift/tools/SourceKit/tools/CMakeLists.txt
+++ b/swift/tools/SourceKit/tools/CMakeLists.txt
@@ -5,8 +5,10 @@ include_directories(
)
add_swift_lib_subdirectory(sourcekitd)
-add_swift_tool_subdirectory(sourcekitd-test)
if(LibEdit_FOUND AND LibEdit_HAS_UNICODE)
add_swift_tool_subdirectory(sourcekitd-repl)
endif()
-add_swift_tool_subdirectory(complete-test)
+if(SWIFT_INCLUDE_TESTS)
+ add_swift_tool_subdirectory(sourcekitd-test)
+ add_swift_tool_subdirectory(complete-test)
+endif()

View File

@ -11,19 +11,3 @@ index bbc43d98..bc5ee576 100644
endif() endif()
endif() endif()
target_link_libraries(TSCBasic PRIVATE target_link_libraries(TSCBasic PRIVATE
diff --git a/swift-tools-support-core/Sources/TSCUtility/FSWatch.swift b/swift-tools-support-core/Sources/TSCUtility/FSWatch.swift
index 0658e55b..9221950b 100644
--- a/swift-tools-support-core/Sources/TSCUtility/FSWatch.swift
+++ b/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

View File

@ -1,256 +0,0 @@
diff --git a/swift/CMakeLists.txt b/swift/CMakeLists.txt
index 4b202c99502..aa7b9e8f715 100644
--- a/swift/CMakeLists.txt
+++ b/swift/CMakeLists.txt
@@ -443,7 +445,7 @@
endif()
set(SWIFT_BUILD_HOST_DISPATCH FALSE)
-if(SWIFT_BUILD_SYNTAXPARSERLIB OR SWIFT_BUILD_SOURCEKIT)
+if(NOT SWIFT_HOST_VARIANT_SDK STREQUAL ANDROID AND SWIFT_INCLUDE_TOOLS AND (SWIFT_BUILD_SYNTAXPARSERLIB OR SWIFT_BUILD_SOURCEKIT))
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
set(SWIFT_BUILD_HOST_DISPATCH TRUE)
endif()
diff --git a/swift/utils/build-script b/swift/utils/build-script
index b4c3f6f6b28..27045d12eac 100755
--- a/swift/utils/build-script
+++ b/swift/utils/build-script
@@ -817,6 +817,7 @@ class BuildScriptInvocation(object):
"""
args = self.args
+ args.build_root = self.workspace.build_root
options = {}
for host_target in [args.host_target] + args.cross_compile_hosts:
@@ -838,6 +839,8 @@ class BuildScriptInvocation(object):
config.swift_benchmark_run_targets),
"SWIFT_TEST_TARGETS": " ".join(
config.swift_test_run_targets),
+ "SWIFT_FLAGS": config.swift_flags,
+ "SWIFT_TARGET_CMAKE_OPTIONS": config.cmake_options,
}
return options
diff --git a/swift/utils/build-script-impl b/swift/utils/build-script-impl
index 66a4408d066..2f6e9981252 100755
--- a/swift/utils/build-script-impl
+++ b/swift/utils/build-script-impl
@@ -137,7 +137,6 @@ KNOWN_SETTINGS=(
common-cmake-options "" "CMake options used for all targets, including LLVM/Clang"
extra-cmake-options "" "Extra options to pass to CMake for all targets"
ninja-cmake-options "" "CMake options used for all ninja targets"
- ninja-cmake-options "" "CMake options used for all ninja targets"
## Build ...
build-llvm "1" "set to 1 to build LLVM and Clang"
@@ -199,6 +198,7 @@
swift-stdlib-single-threaded-runtime "0" "whether to build stdlib as a single-threaded runtime only"
swift-stdlib-os-versioning "1" "whether to build stdlib with availability based on OS versions (Darwin only)"
swift-stdlib-stable-abi "" "should stdlib be built with stable ABI, if not set defaults to true on Darwin, false otherwise"
+ common-swift-flags "" "Flags used for Swift targets other than the stdlib, like the corelibs"
## FREESTANDING Stdlib Options
swift-freestanding-sdk "" "which SDK to use when building the FREESTANDING stdlib"
@@ -224,6 +223,7 @@ KNOWN_SETTINGS=(
cross-compile-hosts "" "space-separated list of targets to cross-compile host Swift tools for"
cross-compile-with-host-tools "" "set to use the clang we build for the host to then build the cross-compile hosts"
cross-compile-install-prefixes "" "semicolon-separated list of install prefixes to use for the cross-compiled hosts. The list expands, so if there are more cross-compile hosts than prefixes, unmatched hosts use the last prefix in the list"
+ cross-compile-deps-path "" "path for CMake to look for cross-compiled library dependencies, such as libXML2"
skip-merge-lipo-cross-compile-tools "" "set to skip running merge-lipo after installing cross-compiled host Swift tools"
coverage-db "" "If set, coverage database to use when prioritizing testing"
skip-local-host-install "" "If we are cross-compiling multiple targets, skip an install pass locally if the hosts match"
@@ -1206,6 +1206,8 @@ function calculate_targets_for_host() {
SWIFT_BENCHMARK_TARGETS=($(get_host_specific_variable ${host} SWIFT_BENCHMARK_TARGETS))
SWIFT_RUN_BENCHMARK_TARGETS=($(get_host_specific_variable ${host} SWIFT_RUN_BENCHMARK_TARGETS))
SWIFT_TEST_TARGETS=($(get_host_specific_variable ${host} SWIFT_TEST_TARGETS))
+ SWIFT_FLAGS=($(get_host_specific_variable ${host} SWIFT_FLAGS))
+ SWIFT_TARGET_CMAKE_OPTIONS=($(get_host_specific_variable ${host} SWIFT_TARGET_CMAKE_OPTIONS))
}
@@ -1347,6 +1349,10 @@ function swift_c_flags() {
fi
}
+function common_swift_flags() {
+ echo -n "${SWIFT_FLAGS[@]} ${COMMON_SWIFT_FLAGS} -module-cache-path \"${module_cache}\" "
+}
+
function cmake_config_opt() {
product=$1
if [[ "${CMAKE_GENERATOR}" == "Xcode" ]] ; then
@@ -1631,6 +1637,9 @@ 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+=("${SWIFT_TARGET_CMAKE_OPTIONS[@]}")
+ fi
build_targets=(all)
;;
@@ -1751,6 +1760,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)
)
+ cmake_options+=("${SWIFT_TARGET_CMAKE_OPTIONS[@]}")
fi
;;
@@ -2161,7 +2171,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:STRING="-module-cache-path \"${module_cache}\""
+ -DCMAKE_Swift_FLAGS:STRING="$(common_swift_flags)"
-DLLBUILD_ENABLE_ASSERTIONS:BOOL=$(true_false "${LLBUILD_ENABLE_ASSERTIONS}")
-DLLBUILD_SUPPORT_BINDINGS:=Swift
@@ -2177,6 +2187,16 @@ for host in "${ALL_HOSTS[@]}"; do
-DFoundation_DIR:PATH=$(build_directory ${host} foundation)/cmake/modules
)
+ if [[ $(is_cross_tools_host ${host}) ]] ; then
+ cmake_options+=("${SWIFT_TARGET_CMAKE_OPTIONS[@]}")
+
+ # CROSS_COMPILE_DEPS_PATH is searched for the SQLite3 dependency.
+ cmake_options+=(
+ -DCMAKE_FIND_ROOT_PATH:PATH="${CROSS_COMPILE_DEPS_PATH}"
+ -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER
+ )
+ fi
+
# Ensure on Darwin platforms that we consider only the SQLite headers
# from the SDK instead of picking ones found elsewhere
# (e.g. in /usr/include )
@@ -2234,7 +2254,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:STRING="-module-cache-path \"${module_cache}\""
+ -DCMAKE_Swift_FLAGS:STRING="$(common_swift_flags)"
-DCMAKE_INSTALL_PREFIX:PATH="$(get_host_install_prefix ${host})"
-DCMAKE_INSTALL_LIBDIR:PATH="lib"
@@ -2250,6 +2270,9 @@ for host in "${ALL_HOSTS[@]}"; do
-DENABLE_TESTING=YES
)
+ if [[ $(is_cross_tools_host ${host}) ]] ; then
+ cmake_options+=("${SWIFT_TARGET_CMAKE_OPTIONS[@]}")
+ fi
;;
esac
@@ -2303,7 +2326,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:STRING="-module-cache-path \"${module_cache}\""
+ -DCMAKE_Swift_FLAGS:STRING="$(common_swift_flags)"
-DCMAKE_INSTALL_PREFIX:PATH=$(get_host_install_prefix ${host})
${LIBICU_BUILD_ARGS[@]}
@@ -2319,6 +2342,21 @@ 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+=("${SWIFT_TARGET_CMAKE_OPTIONS[@]}")
+
+ # CROSS_COMPILE_DEPS_PATH is searched for the ICU, libXML2
+ # and libcurl dependencies.
+ cmake_options+=(
+ -DCMAKE_FIND_ROOT_PATH:PATH="${CROSS_COMPILE_DEPS_PATH}"
+ -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER
+ )
+ fi
+ if [[ "${host}" == "android-"* ]]; then
+ cmake_options+=(
+ -DCMAKE_HAVE_LIBC_PTHREAD=True
+ )
+ fi
;;
libdispatch|libdispatch_static)
LIBDISPATCH_BUILD_DIR=$(build_directory ${host} ${product})
@@ -2345,7 +2383,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:STRING="-module-cache-path \"${module_cache}\""
+ -DCMAKE_Swift_FLAGS:STRING="$(common_swift_flags)"
-DCMAKE_INSTALL_PREFIX:PATH="$(get_host_install_prefix ${host})"
-DCMAKE_INSTALL_LIBDIR:PATH="lib"
@@ -2354,6 +2392,9 @@ 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+=("${SWIFT_TARGET_CMAKE_OPTIONS[@]}")
+ fi
;;
esac
diff --git a/swift/utils/swift_build_support/swift_build_support/host_specific_configuration.py b/swift/utils/swift_build_support/swift_build_support/host_specific_configuration.py
index 9bd750657b8..1e24aee8468 100644
--- a/swift/utils/swift_build_support/swift_build_support/host_specific_configuration.py
+++ b/swift/utils/swift_build_support/swift_build_support/host_specific_configuration.py
@@ -72,6 +72,8 @@ class HostSpecificConfiguration(object):
self.swift_test_run_targets = []
self.swift_benchmark_build_targets = []
self.swift_benchmark_run_targets = []
+ self.swift_flags = ''
+ self.cmake_options = ''
for deployment_target_name in stdlib_targets_to_configure:
# Get the target object.
deployment_target = StdlibDeploymentTarget.get_target_for_name(
@@ -194,6 +196,13 @@ class HostSpecificConfiguration(object):
"check-swift{}-optimize_none_with_implicit_dynamic-{}"
.format(subset_suffix, name))
+ # Only pull in these flags when cross-compiling with
+ # --cross-compile-hosts.
+ if deployment_target_name != args.host_target and \
+ host_target != args.host_target:
+ self.swift_flags = deployment_target.swift_flags(args)
+ self.cmake_options = deployment_target.cmake_options(args)
+
def __platforms_to_skip_build(self, args):
platforms_to_skip_build = set()
if not args.build_linux:
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 cb42f52c633..61778ad9837 100644
--- a/swift/utils/swift_build_support/swift_build_support/targets.py
+++ b/swift/utils/swift_build_support/swift_build_support/targets.py
@@ -152,6 +152,29 @@ class Target(object):
def name(self):
return "{}-{}".format(self.platform.name, self.arch)
+ def swift_flags(self, args):
+ flags = ''
+ if self.platform.name == 'android':
+ flags = '-target %s-unknown-linux-android%s ' % (self.arch,
+ args.android_api_level)
+ flags += '-resource-dir %s/swift-%s/lib/swift ' % (
+ args.build_root, self.name)
+ flags += '-sdk %s/sysroot ' % (args.android_ndk)
+ flags += '-tools-directory %s/bin' % (args.android_ndk)
+ flags += ' -Xlinker -rpath -Xlinker @TERMUX_PREFIX@/lib'
+
+ return flags
+
+ def cmake_options(self, args):
+ options = ''
+ if self.platform.name == 'android':
+ options = '-DCMAKE_SYSTEM_NAME=Android '
+ options += '-DCMAKE_SYSTEM_VERSION=%s ' % (args.android_api_level)
+ options += '-DCMAKE_SYSTEM_PROCESSOR=%s ' % (args.android_arch if not
+ args.android_arch == 'armv7' else 'armv7-a')
+ options += '-DCMAKE_ANDROID_STANDALONE_TOOLCHAIN:PATH=%s' % (args.android_ndk)
+
+ return options
class StdlibDeploymentTarget(object):
OSX = DarwinPlatform("macosx", archs=["x86_64", "arm64", "arm64e"],

View File

@ -22,17 +22,30 @@ index b1d060328bc..218c9215260 100755
fi fi
build_targets=(all) build_targets=(all)
;; ;;
@@ -1652,6 +1688,10 @@ for host in "${ALL_HOSTS[@]}"; do @@ -1652,6 +1688,13 @@ for host in "${ALL_HOSTS[@]}"; do
-DLLVM_NATIVE_BUILD=$(build_directory "${LOCAL_HOST}" llvm) -DLLVM_NATIVE_BUILD=$(build_directory "${LOCAL_HOST}" llvm)
) )
cmake_options+=("${SWIFT_TARGET_CMAKE_OPTIONS[@]}") cmake_options+=("${SWIFT_TARGET_CMAKE_OPTIONS[@]}")
+ cmake_options+=( + cmake_options+=(
+ -DCMAKE_CXX_FLAGS="$CXXFLAGS --target=$CCTERMUX_HOST_PLATFORM $CPPFLAGS" + -DCMAKE_CXX_FLAGS="$CXXFLAGS --target=$CCTERMUX_HOST_PLATFORM $CPPFLAGS"
+ -DCMAKE_EXE_LINKER_FLAGS="$LDFLAGS --target=$CCTERMUX_HOST_PLATFORM" + -DCMAKE_EXE_LINKER_FLAGS="$LDFLAGS --target=$CCTERMUX_HOST_PLATFORM"
+ -DCMAKE_FIND_ROOT_PATH:PATH="${CROSS_COMPILE_DEPS_PATH}"
+ -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER
+ -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY
+ ) + )
fi fi
;; ;;
@@ -1854,6 +1854,9 @@ for host in "${ALL_HOSTS[@]}"; do
cmake_options=(
"${cmake_options[@]}"
-DLLVM_TABLEGEN=$(build_directory "${LOCAL_HOST}" llvm)/bin/llvm-tblgen
+ -DCMAKE_FIND_ROOT_PATH:PATH="${CROSS_COMPILE_DEPS_PATH}"
+ -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER
+ -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY
)
fi
@@ -2045,6 +2045,8 @@ for host in "${ALL_HOSTS[@]}"; do @@ -2045,6 +2045,8 @@ for host in "${ALL_HOSTS[@]}"; do
cmake_options+=( cmake_options+=(
-DCMAKE_FIND_ROOT_PATH:PATH="${CROSS_COMPILE_DEPS_PATH}" -DCMAKE_FIND_ROOT_PATH:PATH="${CROSS_COMPILE_DEPS_PATH}"
@ -42,10 +55,11 @@ index b1d060328bc..218c9215260 100755
) )
fi fi
@@ -2199,6 +2201,8 @@ for host in "${ALL_HOSTS[@]}"; do @@ -2199,6 +2201,9 @@ for host in "${ALL_HOSTS[@]}"; do
# https://cmake.org/cmake/help/latest/command/find_package.html
cmake_options+=( cmake_options+=(
-DCMAKE_FIND_ROOT_PATH:PATH="${CROSS_COMPILE_DEPS_PATH}" -DCMAKE_FIND_ROOT_PATH:PATH="${CROSS_COMPILE_DEPS_PATH}"
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER + -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER
+ -DCMAKE_C_FLAGS="$CFLAGS --target=$CCTERMUX_HOST_PLATFORM $CPPFLAGS" + -DCMAKE_C_FLAGS="$CFLAGS --target=$CCTERMUX_HOST_PLATFORM $CPPFLAGS"
+ -DCMAKE_EXE_LINKER_FLAGS="$LDFLAGS --target=$CCTERMUX_HOST_PLATFORM" + -DCMAKE_EXE_LINKER_FLAGS="$LDFLAGS --target=$CCTERMUX_HOST_PLATFORM"
) )

View File

@ -0,0 +1,37 @@
--- a/swift/utils/swift_build_support/swift_build_support/products/indexstoredb.py 2021-08-07 01:42:42.000000000 +0000
+++ b/swift/utils/swift_build_support/swift_build_support/products/indexstoredb.py 2021-08-20 21:38:31.566330389 +0000
@@ -81,8 +81,10 @@
install_destdir = swiftpm.SwiftPM.get_install_destdir(args,
host_target,
product.build_dir)
- toolchain_path = targets.toolchain_path(install_destdir,
- args.install_prefix)
+ if args.native_swift_tools_path is not None:
+ toolchain_path = os.path.split(args.native_swift_tools_path)[0]
+ else:
+ toolchain_path = product.install_toolchain_path(host_target)
is_release = product.is_release()
configuration = 'release' if is_release else 'debug'
helper_cmd = [
@@ -106,4 +108,21 @@
elif args.enable_tsan:
helper_cmd.extend(['--sanitize', 'thread'])
+ if swiftpm.SwiftPM.has_cross_compile_hosts(args) and host_target != args.host_target:
+ helper_cmd.extend(['--cross-compile-host', host_target])
+ build_toolchain_path = install_destdir + args.install_prefix
+ resource_dir = '%s/lib/swift' % build_toolchain_path
+ helper_cmd += [
+ '--cross-compile-config',
+ targets.StdlibDeploymentTarget.get_target_for_name(host_target).platform
+ .swiftpm_config(args, output_dir=build_toolchain_path,
+ swift_toolchain=toolchain_path,
+ resource_path=resource_dir)
+ ]
+
+ if action == 'install':
+ helper_cmd.extend([
+ '--prefix', install_destdir + args.install_prefix
+ ])
+
shell.call(helper_cmd)

View File

@ -1,46 +1,165 @@
From 652c51f7c8fb1a90bcec89b060ae923b974c8332
Date: Thu, 15 Apr 2021 02:27:15 +0530
Subject: [PATCH] [build] Allow cross-compiling build-script products for
non-Darwin hosts too
To that end, move the --cross-compile-deps-path flag from build-script-impl to a
publicly documented build-script flag and use it for build-script products'
library dependencies too. Generate a SPM destination JSON file that can be used
both for cross-compiling these build-script products and by users for their own
Swift packages.
Also, make using a prebuilt toolchain explicit and pass an install prefix in to
swift-driver.
diff --git a/swift/utils/build-script b/swift/utils/build-script diff --git a/swift/utils/build-script b/swift/utils/build-script
index e34ac8ba03..bc4ddb47d9 100755 index e19967df1fa40..afd6d76933987 100755
--- a/swift/utils/build-script --- a/swift/utils/build-script
+++ b/swift/utils/build-script +++ b/swift/utils/build-script
@@ -1005,9 +1005,14 @@ class BuildScriptInvocation(object): @@ -558,6 +558,10 @@ class BuildScriptInvocation(object):
if args.cross_compile_hosts:
impl_args += [
"--cross-compile-hosts", " ".join(args.cross_compile_hosts)]
+ if args.cross_compile_deps_path is not None:
+ impl_args += [
+ "--cross-compile-deps-path=%s" % args.cross_compile_deps_path
+ ]
if args.test_paths:
impl_args += ["--test-paths", " ".join(args.test_paths)]
@@ -1075,9 +1079,14 @@ class BuildScriptInvocation(object):
# Core Lipo... # Core Lipo...
self._execute_merged_host_lipo_core_action() self._execute_merged_host_lipo_core_action()
+ non_darwin_cross_compile_host_names = [target for target in + non_darwin_cross_compile_hostnames = [
+ self.args.cross_compile_hosts if not + target for target in self.args.cross_compile_hosts if not
+ StdlibDeploymentTarget.get_target_for_name(target).platform.is_darwin] + StdlibDeploymentTarget.get_target_for_name(target).platform.is_darwin]
# Non-build-script-impl products... # Non-build-script-impl products...
- # Note: currently only supports building for the host. - # Note: currently only supports building for the host.
- for host_target in [self.args.host_target]: - for host_target in [self.args.host_target]:
+ # Note: currently only supports cross-compiling for non-Darwin hosts. + # Note: currently only supports cross-compiling for non-Darwin hosts.
+ for host_target in [self.args.host_target] + non_darwin_cross_compile_host_names: + for host_target in [self.args.host_target] + non_darwin_cross_compile_hostnames:
+ if self.args.skip_local_build and host_target == self.args.host_target: + if self.args.skip_local_build and host_target == self.args.host_target:
+ continue + continue
for product_class in product_classes: for product_class in product_classes:
if product_class.is_build_script_impl_product(): if product_class.is_build_script_impl_product():
continue continue
diff --git a/swift/utils/build_swift/build_swift/driver_arguments.py b/swift/utils/build_swift/build_swift/driver_arguments.py
index 850c30dce3d86..fcd2f52f349be 100644
--- a/swift/utils/build_swift/build_swift/driver_arguments.py
+++ b/swift/utils/build_swift/build_swift/driver_arguments.py
@@ -558,6 +558,11 @@ def create_argument_parser():
help='A space separated list of targets to cross-compile host '
'Swift tools for. Can be used multiple times.')
+ option('--cross-compile-deps-path', store_path,
+ help='The path to a directory that contains prebuilt cross-compiled '
+ 'library dependencies of the corelibs and other Swift repos, '
+ 'such as the libcurl dependency of FoundationNetworking')
+
option('--stdlib-deployment-targets', store,
type=argparse.ShellSplitType(),
default=None,
diff --git a/swift/utils/build_swift/tests/expected_options.py b/swift/utils/build_swift/tests/expected_options.py
index bc0041beea192..fa15ca93bb897 100644
--- a/swift/utils/build_swift/tests/expected_options.py
+++ b/swift/utils/build_swift/tests/expected_options.py
@@ -128,6 +128,7 @@
'cmark_build_variant': 'Debug',
'compiler_vendor': defaults.COMPILER_VENDOR,
'coverage_db': None,
+ 'cross_compile_deps_path': None,
'cross_compile_hosts': [],
'darwin_deployment_version_ios':
defaults.DARWIN_DEPLOYMENT_VERSION_IOS,
@@ -673,6 +674,7 @@ class BuildScriptImplOption(_BaseOption):
PathOption('--clang-profile-instr-use'),
PathOption('--cmake'),
PathOption('--coverage-db'),
+ PathOption('--cross-compile-deps-path'),
PathOption('--host-cc'),
PathOption('--host-cxx'),
PathOption('--host-libtool'),
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 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 075b934d10..7cd51690db 100644 index fd202b8cf1738..741353f15ce45 100644
--- a/swift/utils/swift_build_support/swift_build_support/products/product.py --- a/swift/utils/swift_build_support/swift_build_support/products/product.py
+++ b/swift/utils/swift_build_support/swift_build_support/products/product.py +++ b/swift/utils/swift_build_support/swift_build_support/products/product.py
@@ -174,8 +174,10 @@ class Product(object): @@ -195,15 +195,17 @@ def install_toolchain_path(self, host_target):
"""toolchain_path() -> string
Returns the path to the toolchain that is being created as part of this
- build, or to a native prebuilt toolchain that was passed in.
+ 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 install_destdir = self.args.install_destdir
if self.args.cross_compile_hosts: if self.args.cross_compile_hosts:
- build_root = os.path.dirname(self.build_dir) - build_root = os.path.dirname(self.build_dir)
- install_destdir = '%s/intermediate-install/%s' % (build_root, host_target) - install_destdir = '%s/intermediate-install/%s' % (build_root, host_target)
+ if host_target == self.args.host_target: + if targets.StdlibDeploymentTarget.get_target_for_name(
+ host_target).platform.is_darwin:
+ build_root = os.path.dirname(self.build_dir) + build_root = os.path.dirname(self.build_dir)
+ install_destdir = '%s/intermediate-install/%s' % (build_root, + install_destdir = '%s/intermediate-install/%s' % (build_root,
+ host_target) + host_target)
+ else:
+ install_destdir = os.path.join(install_destdir, self.args.host_target)
return targets.toolchain_path(install_destdir, return targets.toolchain_path(install_destdir,
self.args.install_prefix) self.args.install_prefix)
diff --git a/swift/utils/swift_build_support/swift_build_support/products/swiftdriver.py b/swift/utils/swift_build_support/swift_build_support/products/swiftdriver.py
index 3bd5755de35be..c30b032886d0a 100644
--- a/swift/utils/swift_build_support/swift_build_support/products/swiftdriver.py
+++ b/swift/utils/swift_build_support/swift_build_support/products/swiftdriver.py
@@ -91,8 +91,10 @@ def run_build_script_helper(action, host_target, product, args):
install_destdir = swiftpm.SwiftPM.get_install_destdir(args,
host_target,
product.build_dir)
- toolchain_path = targets.toolchain_path(install_destdir,
- args.install_prefix)
+ if args.native_swift_tools_path is not None:
+ toolchain_path = os.path.split(args.native_swift_tools_path)[0]
+ else:
+ toolchain_path = product.install_toolchain_path(host_target)
# Pass Dispatch directory down if we built it
dispatch_build_dir = os.path.join(
@@ -134,7 +136,29 @@ def run_build_script_helper(action, host_target, product, args):
helper_cmd += [
'--lit-test-dir', lit_test_dir
]
+ # Pass Cross compile host info
+ if swiftpm.SwiftPM.has_cross_compile_hosts(args):
+ if targets.StdlibDeploymentTarget.get_target_for_name(
+ host_target).platform.is_darwin:
+ helper_cmd += ['--cross-compile-hosts']
+ for cross_compile_host in args.cross_compile_hosts:
+ helper_cmd += [cross_compile_host]
+ elif host_target != args.host_target:
+ helper_cmd += ['--cross-compile-hosts', host_target]
+ build_toolchain_path = install_destdir + args.install_prefix
+ resource_dir = '%s/lib/swift' % build_toolchain_path
+ helper_cmd += [
+ '--cross-compile-config',
+ targets.StdlibDeploymentTarget.get_target_for_name(
+ host_target).platform.swiftpm_config(
+ args, output_dir=build_toolchain_path,
+ swift_toolchain=toolchain_path, resource_path=resource_dir)]
if args.verbose_build:
helper_cmd.append('--verbose')
+ if action == 'install':
+ helper_cmd += [
+ '--prefix', install_destdir + args.install_prefix
+ ]
+
shell.call(helper_cmd)
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 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 25e982e23f..3127069e19 100644 index 4a97f377ef408..47a893a98ca16 100644
--- a/swift/utils/swift_build_support/swift_build_support/products/swiftpm.py --- a/swift/utils/swift_build_support/swift_build_support/products/swiftpm.py
+++ b/swift/utils/swift_build_support/swift_build_support/products/swiftpm.py +++ b/swift/utils/swift_build_support/swift_build_support/products/swiftpm.py
@@ -23,6 +23,7 @@ from . import product @@ -23,6 +23,7 @@
from . import swift from . import swift
from . import xctest from . import xctest
from .. import shell from .. import shell
@ -48,60 +167,134 @@ index 25e982e23f..3127069e19 100644
class SwiftPM(product.Product): class SwiftPM(product.Product):
@@ -88,9 +89,18 @@ class SwiftPM(product.Product): @@ -44,7 +45,11 @@ def should_build(self, host_target):
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)
+
+ if self.args.native_swift_tools_path is not None:
+ toolchain_path = os.path.split(self.args.native_swift_tools_path)[0]
+ else:
+ toolchain_path = self.install_toolchain_path(host_target)
swiftc = os.path.join(toolchain_path, "bin", "swiftc")
# FIXME: We require llbuild build directory in order to build. Is
@@ -92,9 +97,23 @@ def run_bootstrap_script(self, action, host_target, additional_params=[]):
# Pass Cross compile host info # Pass Cross compile host info
if self.has_cross_compile_hosts(self.args): if self.has_cross_compile_hosts(self.args):
+ helper_cmd += ['--skip-cmake-bootstrap'] - helper_cmd += ['--cross-compile-hosts']
helper_cmd += ['--cross-compile-hosts']
- for cross_compile_host in self.args.cross_compile_hosts: - for cross_compile_host in self.args.cross_compile_hosts:
- helper_cmd += [cross_compile_host] - helper_cmd += [cross_compile_host]
+ if host_target == self.args.host_target: + if StdlibDeploymentTarget.get_target_for_name(
+ host_target).platform.is_darwin:
+ helper_cmd += ['--cross-compile-hosts']
+ for cross_compile_host in self.args.cross_compile_hosts: + for cross_compile_host in self.args.cross_compile_hosts:
+ helper_cmd += [cross_compile_host] + helper_cmd += [cross_compile_host]
+ else: + elif host_target != self.args.host_target:
+ helper_cmd += [host_target] + helper_cmd += ['--cross-compile-hosts', host_target,
+ install_dir = self.args.install_prefix + '--skip-cmake-bootstrap']
+ helper_cmd += ['--cross-compile-flags', + build_toolchain_path = self.get_install_destdir(
+ StdlibDeploymentTarget.get_target_for_name(host_target) + self.args, host_target, self.build_dir) + self.args.install_prefix
+ .swift_flags(self.args, resource_dir_root=install_dir)] + resource_dir = '%s/lib/swift' % build_toolchain_path
+ + helper_cmd += [
+ '--cross-compile-config',
+ StdlibDeploymentTarget.get_target_for_name(host_target).platform
+ .swiftpm_config(self.args, output_dir=build_toolchain_path,
+ swift_toolchain=toolchain_path,
+ resource_path=resource_dir)]
helper_cmd.extend(additional_params) helper_cmd.extend(additional_params)
@@ -122,8 +133,9 @@ class SwiftPM(product.Product): @@ -126,8 +145,13 @@ def has_cross_compile_hosts(self, args):
def get_install_destdir(self, args, host_target, build_dir): def get_install_destdir(self, args, host_target, build_dir):
install_destdir = args.install_destdir install_destdir = args.install_destdir
if self.has_cross_compile_hosts(args): if self.has_cross_compile_hosts(args):
- build_root = os.path.dirname(build_dir) - build_root = os.path.dirname(build_dir)
- install_destdir = '%s/intermediate-install/%s' % (build_root, host_target) - install_destdir = '%s/intermediate-install/%s' % (build_root, host_target)
+ if host_target == args.host_target: + if StdlibDeploymentTarget.get_target_for_name(
+ host_target).platform.is_darwin:
+ build_root = os.path.dirname(build_dir) + build_root = os.path.dirname(build_dir)
+ install_destdir = '%s/intermediate-install/%s' % (build_root, host_target) + install_destdir = '%s/intermediate-install/%s' % (
+ build_root, host_target)
+ else:
+ install_destdir = os.path.join(install_destdir, host_target)
return install_destdir return install_destdir
def install(self, host_target): def install(self, host_target):
diff --git a/swift/utils/swift_build_support/swift_build_support/targets.py b/swift/utils/swift_build_support/swift_build_support/targets.py 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 61778ad983..57df12a555 100644 index 34364458ec736..b6cedb3908f48 100644
--- a/swift/utils/swift_build_support/swift_build_support/targets.py --- a/swift/utils/swift_build_support/swift_build_support/targets.py
+++ b/swift/utils/swift_build_support/swift_build_support/targets.py +++ b/swift/utils/swift_build_support/swift_build_support/targets.py
@@ -152,13 +152,16 @@ class Target(object): @@ -80,6 +80,13 @@ def cmake_options(self, args):
def name(self): """
return "{}-{}".format(self.platform.name, self.arch) return ''
- def swift_flags(self, args): + def swiftpm_config(self, args, output_dir, swift_toolchain, resource_path):
+ def swift_flags(self, args, resource_dir_root=""): + """
flags = '' + Generate a JSON file that SPM can use to cross-compile
if self.platform.name == 'android': + """
flags = '-target %s-unknown-linux-android%s ' % (self.arch, + raise NotImplementedError('Generating a SwiftPM cross-compilation JSON file '
args.android_api_level) + 'for %s is not supported yet' % self.name)
- flags += '-resource-dir %s/swift-%s/lib/swift ' % ( +
- args.build_root, self.name)
+ if resource_dir_root: class DarwinPlatform(Platform):
+ flags += '-resource-dir %s/lib/swift ' % (resource_dir_root) def __init__(self, name, archs, sdk_name=None, is_simulator=False):
+ else: @@ -155,8 +162,7 @@ def swift_flags(self, args):
+ flags += '-resource-dir %s/swift-%s/lib/swift ' % ( flags += '-resource-dir %s/swift-%s-%s/lib/swift ' % (
+ args.build_root, self.name) args.build_root, self.name, args.android_arch)
flags += '-sdk %s/sysroot ' % (args.android_ndk)
flags += '-tools-directory %s/bin' % (args.android_ndk) - android_toolchain_path = '%s/toolchains/llvm/prebuilt/%s' % (
flags += ' -Xlinker -rpath -Xlinker @TERMUX_PREFIX@/lib' - args.android_ndk, StdlibDeploymentTarget.host_target().name)
+ android_toolchain_path = self.ndk_toolchain_path(args)
flags += '-sdk %s/sysroot ' % (android_toolchain_path)
flags += '-tools-directory %s/bin' % (android_toolchain_path)
@@ -171,6 +177,46 @@ def cmake_options(self, args):
options += '-DCMAKE_ANDROID_NDK:PATH=%s' % (args.android_ndk)
return options
+ def ndk_toolchain_path(self, args):
+ return '%s/toolchains/llvm/prebuilt/%s' % (
+ args.android_ndk, StdlibDeploymentTarget.host_target().name)
+
+ def swiftpm_config(self, args, output_dir, swift_toolchain, resource_path):
+ config_file = '%s/swiftpm-android-%s.json' % (output_dir, args.android_arch)
+
+ if os.path.exists(config_file):
+ return config_file
+
+ spm_json = '{\n'
+ spm_json += ' "version": 1,\n'
+ spm_json += ' "target": "%s-unknown-linux-android",\n' % args.android_arch
+ spm_json += ' "toolchain-bin-dir": "%s/bin",\n' % swift_toolchain
+ spm_json += ' "sdk": "%s/sysroot",\n' % self.ndk_toolchain_path(args)
+
+ spm_json += ' "extra-cc-flags": [ "-fPIC", "-I%s/usr/include" ],\n' % (
+ args.cross_compile_deps_path)
+
+ spm_json += ' "extra-swiftc-flags": [\n'
+ spm_json += ' "-resource-dir", "%s",\n' % resource_path
+ spm_json += ' "-tools-directory", "%s/bin",\n' % (
+ self.ndk_toolchain_path(args))
+ spm_json += ' "-Xcc", "-I%s/usr/include",\n' % args.cross_compile_deps_path
+ spm_json += ' "-L%s/usr/lib",\n' % args.cross_compile_deps_path
+ spm_json += ' "-L%s/lib/gcc/%s-linux-android%s/%s.x/%s"\n' % (
+ self.ndk_toolchain_path(args),
+ args.android_arch if not args.android_arch == 'armv7' else 'arm',
+ '' if not args.android_arch == 'armv7' else 'eabi',
+ args.android_ndk_gcc_version,
+ '' if not args.android_arch == 'armv7' else 'armv7-a')
+ spm_json += ' ],\n'
+
+ spm_json += ' "extra-cpp-flags": [ "-lstdc++" ]\n'
+ spm_json += '}'
+
+ with open(config_file, 'w') as f:
+ f.write(spm_json)
+ return config_file
+
class Target(object):
"""

View File

@ -0,0 +1,73 @@
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 741353f15ce..e54e211b705 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
@@ -204,8 +204,6 @@ class Product(object):
build_root = os.path.dirname(self.build_dir)
install_destdir = '%s/intermediate-install/%s' % (build_root,
host_target)
- else:
- install_destdir = os.path.join(install_destdir, self.args.host_target)
return targets.toolchain_path(install_destdir,
self.args.install_prefix)
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 81460b3ba6d..46a43b4acdd 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
@@ -146,8 +146,6 @@ class SwiftPM(product.Product):
build_root = os.path.dirname(build_dir)
install_destdir = '%s/intermediate-install/%s' % (
build_root, host_target)
- else:
- install_destdir = os.path.join(install_destdir, host_target)
return install_destdir
def install(self, host_target):
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 7ebcdc070c1..5a6ed88182e 100644
--- a/swift/utils/swift_build_support/swift_build_support/targets.py
+++ b/swift/utils/swift_build_support/swift_build_support/targets.py
@@ -166,6 +166,7 @@ class AndroidPlatform(Platform):
flags += '-sdk %s/sysroot ' % (android_toolchain_path)
flags += '-tools-directory %s/bin' % (android_toolchain_path)
+ flags += ' -Xlinker -rpath -Xlinker @TERMUX_PREFIX@/lib'
return flags
def cmake_options(self, args):
@@ -174,12 +175,11 @@ class AndroidPlatform(Platform):
options += '-DCMAKE_SYSTEM_PROCESSOR=%s ' % (args.android_arch if not
args.android_arch == 'armv7'
else 'armv7-a')
- options += '-DCMAKE_ANDROID_NDK:PATH=%s' % (args.android_ndk)
+ options += '-DCMAKE_ANDROID_STANDALONE_TOOLCHAIN:PATH=%s' % (args.android_ndk)
return options
def ndk_toolchain_path(self, args):
- return '%s/toolchains/llvm/prebuilt/%s' % (
- args.android_ndk, StdlibDeploymentTarget.host_target().name)
+ return args.android_ndk
def swiftpm_config(self, args, output_dir, swift_toolchain, resource_path):
config_file = '%s/swiftpm-android-%s.json' % (output_dir, args.android_arch)
@@ -190,17 +190,15 @@ class AndroidPlatform(Platform):
spm_json = '{\n'
spm_json += ' "version": 1,\n'
spm_json += ' "target": "%s-unknown-linux-android",\n' % args.android_arch
- spm_json += ' "toolchain-bin-dir": "%s/bin",\n' % swift_toolchain
+ spm_json += ' "toolchain-bin-dir": "%s/bin",\n' % args.android_ndk
spm_json += ' "sdk": "%s/sysroot",\n' % self.ndk_toolchain_path(args)
- spm_json += ' "extra-cc-flags": [ "-fPIC", "-I%s/usr/include" ],\n' % (
- args.cross_compile_deps_path)
+ spm_json += ' "extra-cc-flags": [ "-fPIC" ],\n'
spm_json += ' "extra-swiftc-flags": [\n'
spm_json += ' "-resource-dir", "%s",\n' % resource_path
spm_json += ' "-tools-directory", "%s/bin",\n' % (
self.ndk_toolchain_path(args))
- spm_json += ' "-Xcc", "-I%s/usr/include",\n' % args.cross_compile_deps_path
spm_json += ' "-L%s/usr/lib",\n' % args.cross_compile_deps_path
spm_json += ' "-L%s/lib/gcc/%s-linux-android%s/%s.x/%s"\n' % (
self.ndk_toolchain_path(args),

View File

@ -0,0 +1,79 @@
commit 74a8de7bccc0c40381b63a79143d4ca945c0ed68
Date: Thu Aug 5 23:30:59 2021 +0530
Change the order of Workspace toolchain C/Swift flags to match the command-line (#3636)
* Move Workspace UserToolchain C/Swift flags to just before the command-line flags,
so both are after the package's internal flags.
This makes sure internal package paths are searched first, before external flags
are applied.
diff --git a/swiftpm/Sources/Build/BuildPlan.swift b/swiftpm/Sources/Build/BuildPlan.swift
index 78072f5b..fb78b54f 100644
--- a/swiftpm/Sources/Build/BuildPlan.swift
+++ b/swiftpm/Sources/Build/BuildPlan.swift
@@ -330,7 +330,6 @@ public final class ClangTargetBuildDescription {
args += ["-fobjc-arc"]
}
args += buildParameters.targetTripleArgs(for: target)
- args += buildParameters.toolchain.extraCCFlags
args += ["-g"]
if buildParameters.triple.isWindows() {
args += ["-gcodeview"]
@@ -373,6 +372,7 @@ public final class ClangTargetBuildDescription {
args += ["-include", resourceAccessorHeaderFile.pathString]
}
+ args += buildParameters.toolchain.extraCCFlags
// User arguments (from -Xcc and -Xcxx below) should follow generated arguments to allow user overrides
args += buildParameters.flags.cCompilerFlags
@@ -724,7 +724,6 @@ public final class SwiftTargetBuildDescription {
}
args += buildParameters.indexStoreArguments(for: target)
- args += buildParameters.toolchain.extraSwiftCFlags
args += optimizationArguments
args += testingArguments
args += ["-g"]
@@ -791,6 +790,7 @@ public final class SwiftTargetBuildDescription {
args += ["-emit-module-interface-path", parseableModuleInterfaceOutputPath.pathString]
}
+ args += buildParameters.toolchain.extraSwiftCFlags
// User arguments (from -Xswiftc) should follow generated arguments to allow user overrides
args += buildParameters.swiftCompilerFlags
return args
@@ -907,7 +907,6 @@ public final class SwiftTargetBuildDescription {
result += ["-swift-version", swiftVersion.rawValue]
result += buildParameters.indexStoreArguments(for: target)
- result += buildParameters.toolchain.extraSwiftCFlags
result += optimizationArguments
result += testingArguments
result += ["-g"]
@@ -919,6 +918,7 @@ public final class SwiftTargetBuildDescription {
result += buildParameters.sanitizers.compileSwiftFlags()
result += ["-parseable-output"]
result += self.buildSettingsFlags()
+ result += buildParameters.toolchain.extraSwiftCFlags
result += buildParameters.swiftCompilerFlags
return result
}
@@ -1165,7 +1165,6 @@ public final class ProductBuildDescription {
/// The arguments to link and create this product.
public func linkArguments() throws -> [String] {
var args = [buildParameters.toolchain.swiftCompiler.pathString]
- args += buildParameters.toolchain.extraSwiftCFlags
args += buildParameters.sanitizers.linkSwiftFlags()
args += additionalFlags
@@ -1286,6 +1285,7 @@ public final class ProductBuildDescription {
// building for Darwin in debug configuration.
args += swiftASTs.flatMap{ ["-Xlinker", "-add_ast_path", "-Xlinker", $0.pathString] }
+ args += buildParameters.toolchain.extraSwiftCFlags
// User arguments (from -Xlinker and -Xswiftc) should follow generated arguments to allow user overrides
args += buildParameters.linkerFlags
args += stripInvalidArguments(buildParameters.swiftCompilerFlags)

View File

@ -1,153 +0,0 @@
diff --git a/swiftpm/Utilities/bootstrap b/swiftpm/Utilities/bootstrap
index ead6af68..95a8427f 100755
--- a/swiftpm/Utilities/bootstrap
+++ b/swiftpm/Utilities/bootstrap
@@ -143,6 +143,9 @@ def add_build_args(parser):
dest="cross_compile_hosts",
help="List of cross compile hosts targets.",
default=[])
+ parser.add_argument(
+ "--cross-compile-flags",
+ help="Swift flags to cross-compile the PackageDescription libraries")
def add_test_args(parser):
"""Configures the parser with the arguments necessary for the test action."""
@@ -195,8 +198,12 @@ def parse_build_args(args):
args.clang_path = get_clang_path(args)
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.
- args.target_dir = os.path.join(args.build_dir, "apple/Products")
+ if args.cross_compile_hosts:
+ if "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")
+ elif re.match('android-', args.cross_compile_hosts):
+ args.target_dir = os.path.join(args.build_dir, get_build_target(args,cross_compile=True))
else:
args.target_dir = os.path.join(args.build_dir, get_build_target(args))
args.bootstrap_dir = os.path.join(args.target_dir, "bootstrap")
@@ -270,10 +277,13 @@ def get_ninja_path(args):
else:
return call_output(["which", "ninja"], verbose=args.verbose)
-def get_build_target(args):
+def get_build_target(args, cross_compile=False):
"""Returns the target-triple of the current machine."""
try:
- target_info_json = subprocess.check_output([args.swiftc_path, '-print-target-info'], stderr=subprocess.PIPE, universal_newlines=True).strip()
+ if cross_compile:
+ target_info_json = subprocess.check_output([args.swiftc_path, '-print-target-info'] + args.cross_compile_flags.split(), stderr=subprocess.PIPE, universal_newlines=True).strip()
+ else:
+ target_info_json = subprocess.check_output([args.swiftc_path, '-print-target-info'], stderr=subprocess.PIPE, universal_newlines=True).strip()
args.target_info = json.loads(target_info_json)
return args.target_info["target"]["unversionedTriple"]
except Exception as e:
@@ -307,8 +317,11 @@ def build(args):
build_yams(args)
build_swift_argument_parser(args)
build_swift_driver(args)
+ build_swiftpm_with_cmake(args)
+
+ if args.cross_compile_flags:
+ build_packagedescription_libs_with_cmake(args)
- build_swiftpm_with_cmake(args)
build_swiftpm_with_swiftpm(args,integrated_swift_driver=False)
def test(args):
@@ -441,11 +454,15 @@ def install_binary(args, binary, dest_dir):
# Build functions
# -----------------------------------------------------------
-def build_with_cmake(args, cmake_args, source_path, build_dir, targets=[]):
+def build_with_cmake(args, cmake_args, source_path, build_dir, targets=[], cross_compile=False):
"""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 cross_compile:
+ swift_flags = args.cross_compile_flags + " -Xcc -I@TERMUX_PREFIX@/include"
+ else:
+ swift_flags = ""
+
if args.sysroot:
swift_flags = "-sdk %s" % args.sysroot
@@ -567,29 +584,37 @@ def add_rpath_for_cmake_build(args, rpath):
note(' '.join(add_rpath_cmd))
subprocess.call(add_rpath_cmd, stderr=subprocess.PIPE)
+def build_packagedescription_libs_with_cmake(args):
+ """Builds the PackageDescription libraries using CMake."""
+ note("Building PackageDescription libraries (with CMake)")
+
+ cmake_flags = ["-DFIND_PM_DEPS:BOOL=NO"]
+ targets = ["PD4", "PD4_2"]
+ if re.match('android-', args.cross_compile_hosts):
+ cmake_flags.append("-DCMAKE_SYSTEM_NAME=Android")
+ cmake_flags.append("-DCMAKE_SYSTEM_VERSION=1")
+
+ build_with_cmake(args, cmake_flags, args.project_root, args.bootstrap_dir,
+ targets, cross_compile=True)
+
def build_swiftpm_with_cmake(args):
"""Builds SwiftPM using CMake."""
note("Building SwiftPM (with CMake)")
- if args.bootstrap:
- cmake_flags = [
- get_llbuild_cmake_arg(args),
- "-DTSC_DIR=" + os.path.join(args.tsc_build_dir, "cmake/modules"),
- "-DYams_DIR=" + os.path.join(args.yams_build_dir, "cmake/modules"),
- "-DArgumentParser_DIR=" + os.path.join(args.swift_argument_parser_build_dir, "cmake/modules"),
- "-DSwiftDriver_DIR=" + os.path.join(args.swift_driver_build_dir, "cmake/modules"),
- "-DFIND_PM_DEPS:BOOL=YES",
- ]
- else:
- cmake_flags = [ "-DFIND_PM_DEPS:BOOL=NO" ]
+ cmake_flags = [
+ get_llbuild_cmake_arg(args),
+ "-DTSC_DIR=" + os.path.join(args.tsc_build_dir, "cmake/modules"),
+ "-DYams_DIR=" + os.path.join(args.yams_build_dir, "cmake/modules"),
+ "-DArgumentParser_DIR=" + os.path.join(args.swift_argument_parser_build_dir, "cmake/modules"),
+ "-DSwiftDriver_DIR=" + os.path.join(args.swift_driver_build_dir, "cmake/modules"),
+ "-DFIND_PM_DEPS:BOOL=YES",
+ ]
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)
- targets = [] if args.bootstrap else ["PD4", "PD4_2"]
-
- build_with_cmake(args, cmake_flags, args.project_root, args.bootstrap_dir, targets)
+ build_with_cmake(args, cmake_flags, args.project_root, args.bootstrap_dir)
if args.llbuild_link_framework:
add_rpath_for_cmake_build(args, args.llbuild_build_dir)
@@ -763,8 +788,10 @@ def get_swiftpm_flags(args):
)
# Don't use GNU strerror_r on Android.
- if 'ANDROID_DATA' in os.environ:
+ if 'ANDROID_DATA' in os.environ or re.match(
+ 'android-', args.cross_compile_hosts):
build_flags.extend(["-Xswiftc", "-Xcc", "-Xswiftc", "-U_GNU_SOURCE"])
+ build_flags.extend(["-Xlinker", "-landroid-spawn"])
# On ELF platforms, remove the host toolchain's stdlib absolute rpath from
# installed executables and shared libraries.
@@ -775,6 +802,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 cross_compile_hosts and re.match('android-', cross_compile_hosts):
+ build_flags.extend([
+ "--destination", "@TERMUX_PKG_BUILDDIR@/swiftpm-android-flags.json",
+ "-Xlinker", "-rpath", "-Xlinker", "@TERMUX_PREFIX@/lib",
+ "-Xcc", "-I@TERMUX_PREFIX@/include",
+ ])
elif cross_compile_hosts:
error("cannot cross-compile for %s" % cross_compile_hosts)

View File

@ -1,18 +0,0 @@
{
"version": 1,
"target": "@SWIFT_ARCH@-unknown-linux-android",
"toolchain-bin-dir": "@TERMUX_STANDALONE_TOOLCHAIN@/bin",
"sdk": "@TERMUX_STANDALONE_TOOLCHAIN@/sysroot",
"extra-cc-flags": [
"-fPIC"
],
"extra-swiftc-flags": [
"-resource-dir", "@TERMUX_PREFIX@/lib/swift",
"-tools-directory", "@TERMUX_STANDALONE_TOOLCHAIN@/@TERMUX_HOST_PLATFORM@/bin",
"-Xclang-linker", "--target=@CCTERMUX_HOST_PLATFORM@", "-L@TERMUX_PREFIX@/lib",
"-L@TERMUX_STANDALONE_TOOLCHAIN@/lib/gcc/@TERMUX_HOST_PLATFORM@/4.9.x"
],
"extra-cpp-flags": [
"-lstdc++"
]
}

View File

@ -0,0 +1,45 @@
--- a/sourcekit-lsp/Utilities/build-script-helper.py
+++ b/sourcekit-lsp/Utilities/build-script-helper.py
@@ -66,7 +66,7 @@
]
if args.cross_compile_host:
- swiftpm_args += ['--destination', args.cross_compile_config]
+ swiftpm_args += ['--destination', args.cross_compile_config, '-Xcc', '-I@TERMUX_PREFIX@/include', '-Xswiftc', '-Xclang-linker', '-Xswiftc', '--target=@CCTERMUX_HOST_PLATFORM@', '-Xlinker', '-landroid-spawn', '-Xlinker', '-rpath', '-Xlinker', '@TERMUX_PREFIX@/lib']
return swiftpm_args
diff --git a/swiftpm/Utilities/bootstrap b/swiftpm/Utilities/bootstrap
index 1f673fdd..e51616cb 100755
--- a/swiftpm/Utilities/bootstrap
+++ b/swiftpm/Utilities/bootstrap
@@ -800,6 +800,7 @@ def get_swiftpm_flags(args):
if 'ANDROID_DATA' in os.environ or (args.cross_compile_hosts and re.match(
'android-', args.cross_compile_hosts)):
build_flags.extend(["-Xswiftc", "-Xcc", "-Xswiftc", "-U_GNU_SOURCE"])
+ build_flags.extend(["-Xlinker", "-landroid-spawn"])
# On ELF platforms, remove the host toolchain's stdlib absolute rpath from
# installed executables and shared libraries.
@@ -811,7 +812,7 @@ def get_swiftpm_flags(args):
if build_target == 'x86_64-apple-macosx' and "macosx-arm64" in cross_compile_hosts:
build_flags += ["--arch", "x86_64", "--arch", "arm64"]
elif cross_compile_hosts and re.match('android-', cross_compile_hosts):
- build_flags.extend(["--destination", args.cross_compile_config])
+ build_flags.extend(["--destination", args.cross_compile_config, "-Xcc", "-I@TERMUX_PREFIX@/include", "-Xswiftc", "-Xclang-linker", "-Xswiftc", "--target=@CCTERMUX_HOST_PLATFORM@", "-Xlinker", "-rpath", "-Xlinker", "@TERMUX_PREFIX@/lib"])
elif cross_compile_hosts:
error("cannot cross-compile for %s" % cross_compile_hosts)
diff --git a/swift-driver/Utilities/build-script-helper.py b/swift-driver/Utilities/build-script-helper.py
index 91a8d57..48bffd6 100755
--- a/swift-driver/Utilities/build-script-helper.py
+++ b/swift-driver/Utilities/build-script-helper.py
@@ -98,7 +98,7 @@ def get_swiftpm_options(args):
]
if args.cross_compile_hosts:
- swiftpm_args += [ '--destination', args.cross_compile_config ]
+ swiftpm_args += [ '--destination', args.cross_compile_config, '-Xcc', '-I@TERMUX_PREFIX@/include', '-Xswiftc', '-Xclang-linker', '-Xswiftc', '--target=@CCTERMUX_HOST_PLATFORM@', '-Xlinker', '-landroid-spawn', '-Xlinker', '-rpath', '-Xlinker', '@TERMUX_PREFIX@/lib']
if 'ANDROID_DATA' in os.environ or (args.cross_compile_hosts and re.match(
'android-', args.cross_compile_hosts[0])):