upgpkg(swift): 5.6.2 to 5.6.3
This commit is contained in:
parent
4274558372
commit
a06a89a012
|
@ -154,7 +154,7 @@ jobs:
|
|||
|
||||
- name: Free additional disk space (if necessary)
|
||||
run: |
|
||||
if grep -q '^clvk$\|^dart$\|^rust$\|^rustc-nightly$\|^swift$' ./built_termux-main_packages.txt; then
|
||||
if grep -q '^clvk$\|^dart$\|^rust$\|^rustc-nightly$' ./built_termux-main_packages.txt; then
|
||||
echo "Free additional disk space on host"
|
||||
sudo apt purge -yq $(dpkg -l | grep '^ii' | awk '{ print $2 }' | grep -P '(cabal-|dotnet-|ghc-|libmono|php)') \
|
||||
liblldb-6.0 libllvm6.0:amd64 mono-runtime-common monodoc-manual powershell ruby
|
||||
|
|
|
@ -2,10 +2,10 @@ TERMUX_PKG_HOMEPAGE=https://swift.org/
|
|||
TERMUX_PKG_DESCRIPTION="Swift is a high-performance system programming language"
|
||||
TERMUX_PKG_LICENSE="Apache-2.0, NCSA"
|
||||
TERMUX_PKG_MAINTAINER="@buttaface"
|
||||
TERMUX_PKG_VERSION=5.6.2
|
||||
TERMUX_PKG_VERSION=5.6.3
|
||||
SWIFT_RELEASE="RELEASE"
|
||||
TERMUX_PKG_SRCURL=https://github.com/apple/swift/archive/swift-$TERMUX_PKG_VERSION-$SWIFT_RELEASE.tar.gz
|
||||
TERMUX_PKG_SHA256=8176efb376e83b358cd088683e5214d8db864386dae745f94618745b1ab89a19
|
||||
TERMUX_PKG_SHA256=ba76a631b634efebfc5aa01942ab9371e7574f6d69eb08942bbefe04116f039c
|
||||
TERMUX_PKG_HOSTBUILD=true
|
||||
TERMUX_PKG_DEPENDS="clang, libandroid-glob, libandroid-posix-semaphore, libandroid-spawn, libcurl, libicu, libicu-static, libsqlite, libuuid, libxml2, libdispatch, llbuild"
|
||||
TERMUX_PKG_BUILD_DEPENDS="rsync"
|
||||
|
@ -34,21 +34,21 @@ termux_step_post_get_source() {
|
|||
mv .temp swift
|
||||
|
||||
declare -A library_checksums
|
||||
library_checksums[swift-cmark]=931dafb52749313bd7cefd743e9624d2cf244d7581e5540e82e33a0f866fbb31
|
||||
library_checksums[llvm-project]=dc876801beb1bcbbea9d023ff2aba6381ca5e63ad6462327e2191acf10804eb8
|
||||
library_checksums[swift-corelibs-libdispatch]=ddf90b72521cf836e5ff6537a140fa08c4a3227f9d52d308cb4571c517030c76
|
||||
library_checksums[swift-corelibs-foundation]=fc7be74a20938f9249ca104b9610a6d6e79f5e243f33d789d9795c3f247c57fa
|
||||
library_checksums[swift-corelibs-xctest]=4918429f4bc30b3cd8bd149096d56fd9f055c3ef82622934f64dddfa9aff9880
|
||||
library_checksums[swift-llbuild]=ba95bc71a20978bc5f411d10079de9ff228868f3fd9068d81b4be1998e5dc7d3
|
||||
library_checksums[swift-cmark]=a950b87ee3165d311d440c688132c42066d4915280df6e80a1a505a942b1dc28
|
||||
library_checksums[llvm-project]=4e414881b7f405a537014ad09004e0b4b4ed29480d8b82da6fbfc8a0d16feaa9
|
||||
library_checksums[swift-corelibs-libdispatch]=e71ebdc2bd573de3af2777816e0f034f29cf16b42025ab3b95e15c71159bab5c
|
||||
library_checksums[swift-corelibs-foundation]=33c27428d29092cbd214d8e8e6f281fffc28f4557f10366e4f6f3ac45b34c315
|
||||
library_checksums[swift-corelibs-xctest]=c5ced7851691ce8b30e333fe49aa94c448cb86e502d49f9921a9679a530a7a2d
|
||||
library_checksums[swift-llbuild]=4b2f230cc1f0a5857717715ddfe7f532d434311c76801c65ca1ad8ace4a9ad18
|
||||
library_checksums[swift-argument-parser]=a4d4c08cf280615fe6e00752ef60e28e76f07c25eb4706a9269bf38135cd9c3f
|
||||
library_checksums[Yams]=8bbb28ef994f60afe54668093d652e4d40831c79885fa92b1c2cd0e17e26735a
|
||||
library_checksums[swift-crypto]=86d6c22c9f89394fd579e967b0d5d0b6ce33cdbf52ba70f82fa313baf70c759f
|
||||
library_checksums[swift-system]=865b8c380455eef27e73109835142920c60ae4c4f4178a3d12ad04acc83f1371
|
||||
library_checksums[swift-driver]=97b515d684f26e9097bde7068e38f445898a8ab695478ca3ce64bc9969bc2fcb
|
||||
library_checksums[swift-tools-support-core]=d14a30cfd9628a59a44011cce0465d9fcb1e55fc74e62d7f807c98e66ddb822c
|
||||
library_checksums[swift-package-manager]=ea7eccebe14d84b9e12a8464a26acc2b8b094cd44eb1cc2c86c82d1ef5856c54
|
||||
library_checksums[indexstore-db]=6820ead230a04dc62c863f14a5db62ce8ba373257a4cb99e50096e32c83c9f5c
|
||||
library_checksums[sourcekit-lsp]=e1c70a099eb981b967baaf9f788af439633027c86a8b27cd39039b5c41e86700
|
||||
library_checksums[swift-driver]=a317d194e0eb1c39fd28644597c8dfe4c89cd611fe8ca9cc8765551994583879
|
||||
library_checksums[swift-tools-support-core]=171235636aaa3a82a2a47dfd1a9e493dc034d3f929e64200544f714750076ea3
|
||||
library_checksums[swift-package-manager]=420491446bf25409169c621955c2901d2edc11844834acc32f5311d6b719ef51
|
||||
library_checksums[indexstore-db]=0eb0e73ecab6d4c7d8e9cc4ade8d83e31a406070e0a655afb3a9b0d4dc50f3d7
|
||||
library_checksums[sourcekit-lsp]=497432deb1ee6fc004196b2240fc6a1bb83d6590fef83d97193b3bc4b41ab62c
|
||||
|
||||
for library in "${!library_checksums[@]}"; do \
|
||||
GH_ORG="apple"
|
||||
|
@ -100,20 +100,11 @@ termux_step_host_build() {
|
|||
CLANGXX=$(command -v clang++-12)
|
||||
fi
|
||||
|
||||
local SKIP_BUILD="--skip-build-compiler-rt"
|
||||
test $TERMUX_ARCH != 'aarch64' && SKIP_BUILD="--skip-build-cmark --skip-build-llvm --skip-build-swift"
|
||||
|
||||
# Natively compile llvm-tblgen and some other files needed later.
|
||||
SWIFT_BUILD_ROOT=$TERMUX_PKG_HOSTBUILD_DIR $TERMUX_PKG_SRCDIR/swift/utils/build-script \
|
||||
-R --no-assertions -j $TERMUX_MAKE_PROCESSES $SWIFT_PATH_FLAGS \
|
||||
$SKIP_BUILD --skip-early-swift-driver --build-toolchain-only \
|
||||
--host-cc=$CLANG --host-cxx=$CLANGXX
|
||||
|
||||
if [ "$TERMUX_ARCH" == "aarch64" ]; then
|
||||
rm $TERMUX_PKG_HOSTBUILD_DIR/swift-linux-x86_64/lib/swift/FrameworkABIBaseline
|
||||
cp -r $SWIFT_BINDIR/../lib/swift $TERMUX_PKG_HOSTBUILD_DIR/swift-linux-x86_64/lib
|
||||
ln -sf $SWIFT_BINDIR/../lib/clang/13.0.0 $TERMUX_PKG_HOSTBUILD_DIR/swift-linux-x86_64/lib/swift/clang
|
||||
fi
|
||||
--skip-build-cmark --skip-build-llvm --skip-build-swift --skip-early-swift-driver \
|
||||
--build-toolchain-only --host-cc=$CLANG --host-cxx=$CLANGXX
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -130,19 +121,12 @@ termux_step_make() {
|
|||
termux_setup_swift
|
||||
ln -sf $TERMUX_PKG_HOSTBUILD_DIR/llvm-linux-x86_64 $TERMUX_PKG_BUILDDIR/llvm-linux-x86_64
|
||||
|
||||
local SWIFT_TOOLCHAIN=
|
||||
if [ "$SWIFT_ARCH" = "aarch64" ]; then
|
||||
ln -sf $TERMUX_PKG_HOSTBUILD_DIR/swift-linux-x86_64 $TERMUX_PKG_BUILDDIR/swift-linux-x86_64
|
||||
else
|
||||
SWIFT_TOOLCHAIN="--native-swift-tools-path=$SWIFT_BINDIR"
|
||||
fi
|
||||
|
||||
SWIFT_BUILD_FLAGS="$SWIFT_BUILD_FLAGS --android
|
||||
--android-ndk $TERMUX_STANDALONE_TOOLCHAIN --android-arch $SWIFT_ARCH
|
||||
--build-toolchain-only --skip-local-build --skip-local-host-install
|
||||
--cross-compile-hosts=android-$SWIFT_ARCH
|
||||
--cross-compile-deps-path=$(dirname $TERMUX_PREFIX)
|
||||
$SWIFT_TOOLCHAIN
|
||||
--native-swift-tools-path=$SWIFT_BINDIR
|
||||
--native-clang-tools-path=$SWIFT_BINDIR
|
||||
--cross-compile-append-host-target-to-destdir=False"
|
||||
fi
|
||||
|
|
|
@ -1,110 +0,0 @@
|
|||
From 7b2256f97b59192046eab312838f467def880605
|
||||
Date: Sun, 9 Jan 2022 21:45:13 +0530
|
||||
Subject: [PATCH] [android] Move the string and other tags in pointers to the
|
||||
second byte because Android enabled memory tagging
|
||||
|
||||
Starting with Android 11, AArch64 placed a tag in the top byte of pointers to
|
||||
allocations, which has been slowly rolling out to more devices and collides
|
||||
with Swift's tags. Moving these tags to the second byte works around this
|
||||
problem.
|
||||
---
|
||||
lib/IRGen/MetadataRequest.cpp | 28 ++++++++++--
|
||||
lib/IRGen/SwiftTargetInfo.cpp | 15 +++++--
|
||||
stdlib/public/SwiftShims/System.h | 9 ++++
|
||||
|
||||
diff --git a/swift/lib/IRGen/MetadataRequest.cpp b/swift/lib/IRGen/MetadataRequest.cpp
|
||||
index 370b5bab779e2..d96e7b0d0f576 100644
|
||||
--- a/swift/lib/IRGen/MetadataRequest.cpp
|
||||
+++ b/swift/lib/IRGen/MetadataRequest.cpp
|
||||
@@ -2681,9 +2681,16 @@ emitMetadataAccessByMangledName(IRGenFunction &IGF, CanType type,
|
||||
unsigned mangledStringSize;
|
||||
std::tie(mangledString, mangledStringSize) =
|
||||
IGM.getTypeRef(type, CanGenericSignature(), MangledTypeRefRole::Metadata);
|
||||
-
|
||||
- assert(mangledStringSize < 0x80000000u
|
||||
- && "2GB of mangled name ought to be enough for anyone");
|
||||
+
|
||||
+ // Android AArch64 reserves the top byte of the address for memory tagging
|
||||
+ // since Android 11, so only use the bottom 23 bits to store this size
|
||||
+ // and the 24th bit to signal that there is a size.
|
||||
+ if (IGM.Triple.isAndroid() && IGM.Triple.getArch() == llvm::Triple::aarch64)
|
||||
+ assert(mangledStringSize < 0x00800001u &&
|
||||
+ "8MB of mangled name ought to be enough for Android AArch64");
|
||||
+ else
|
||||
+ assert(mangledStringSize < 0x80000000u &&
|
||||
+ "2GB of mangled name ought to be enough for anyone");
|
||||
|
||||
// Get or create the cache variable if necessary.
|
||||
auto cache = IGM.getAddrOfTypeMetadataDemanglingCacheVariable(type,
|
||||
@@ -2753,6 +2760,21 @@ emitMetadataAccessByMangledName(IRGenFunction &IGF, CanType type,
|
||||
auto contBB = subIGF.createBasicBlock("");
|
||||
llvm::Value *comparison = subIGF.Builder.CreateICmpSLT(load,
|
||||
llvm::ConstantInt::get(IGM.Int64Ty, 0));
|
||||
+
|
||||
+ // Check if the 24th bit is set on Android AArch64 and only instantiate the
|
||||
+ // type metadata if it is, as otherwise it might be negative only because
|
||||
+ // of the memory tag on Android.
|
||||
+ if (IGM.Triple.isAndroid() &&
|
||||
+ IGM.Triple.getArch() == llvm::Triple::aarch64) {
|
||||
+
|
||||
+ auto getBitAfterAndroidTag = subIGF.Builder.CreateAnd(
|
||||
+ load, llvm::ConstantInt::get(IGM.Int64Ty, 0x0080000000000000));
|
||||
+ auto checkNotAndroidTag = subIGF.Builder.CreateICmpNE(
|
||||
+ getBitAfterAndroidTag, llvm::ConstantInt::get(IGM.Int64Ty, 0));
|
||||
+
|
||||
+ comparison = subIGF.Builder.CreateAnd(comparison, checkNotAndroidTag);
|
||||
+ }
|
||||
+
|
||||
comparison = subIGF.Builder.CreateExpect(comparison,
|
||||
llvm::ConstantInt::get(IGM.Int1Ty, 0));
|
||||
subIGF.Builder.CreateCondBr(comparison, isUnfilledBB, contBB);
|
||||
diff --git a/swift/lib/IRGen/SwiftTargetInfo.cpp b/swift/lib/IRGen/SwiftTargetInfo.cpp
|
||||
index 97b70d6d75c0a..b2b2e70d3434e 100644
|
||||
--- a/swift/lib/IRGen/SwiftTargetInfo.cpp
|
||||
+++ b/swift/lib/IRGen/SwiftTargetInfo.cpp
|
||||
@@ -36,10 +36,17 @@ static void setToMask(SpareBitVector &bits, unsigned size, uint64_t mask) {
|
||||
/// Configures target-specific information for arm64 platforms.
|
||||
static void configureARM64(IRGenModule &IGM, const llvm::Triple &triple,
|
||||
SwiftTargetInfo &target) {
|
||||
- setToMask(target.PointerSpareBits, 64,
|
||||
- SWIFT_ABI_ARM64_SWIFT_SPARE_BITS_MASK);
|
||||
- setToMask(target.ObjCPointerReservedBits, 64,
|
||||
- SWIFT_ABI_ARM64_OBJC_RESERVED_BITS_MASK);
|
||||
+ if (triple.isAndroid()) {
|
||||
+ setToMask(target.PointerSpareBits, 64,
|
||||
+ SWIFT_ABI_ANDROID_ARM64_SWIFT_SPARE_BITS_MASK);
|
||||
+ setToMask(target.ObjCPointerReservedBits, 64,
|
||||
+ SWIFT_ABI_ANDROID_ARM64_OBJC_RESERVED_BITS_MASK);
|
||||
+ } else {
|
||||
+ setToMask(target.PointerSpareBits, 64,
|
||||
+ SWIFT_ABI_ARM64_SWIFT_SPARE_BITS_MASK);
|
||||
+ setToMask(target.ObjCPointerReservedBits, 64,
|
||||
+ SWIFT_ABI_ARM64_OBJC_RESERVED_BITS_MASK);
|
||||
+ }
|
||||
setToMask(target.IsObjCPointerBit, 64, SWIFT_ABI_ARM64_IS_OBJC_BIT);
|
||||
|
||||
if (triple.isOSDarwin()) {
|
||||
diff --git a/swift/stdlib/public/SwiftShims/System.h b/swift/stdlib/public/SwiftShims/System.h
|
||||
index 978ec41f1eafb..7ec3961fa0fc3 100644
|
||||
--- a/swift/stdlib/public/SwiftShims/System.h
|
||||
+++ b/swift/stdlib/public/SwiftShims/System.h
|
||||
@@ -152,10 +152,19 @@
|
||||
/// Darwin reserves the low 4GB of address space.
|
||||
#define SWIFT_ABI_DARWIN_ARM64_LEAST_VALID_POINTER 0x100000000ULL
|
||||
|
||||
+// Android AArch64 reserves the top byte for pointer tagging since Android 11,
|
||||
+// so shift the spare bits tag to the second byte and zero the ObjC tag.
|
||||
+#define SWIFT_ABI_ANDROID_ARM64_SWIFT_SPARE_BITS_MASK 0x00F0000000000007ULL
|
||||
+#define SWIFT_ABI_ANDROID_ARM64_OBJC_RESERVED_BITS_MASK 0x0000000000000000ULL
|
||||
+
|
||||
+#if defined(__ANDROID__) && defined(__aarch64__)
|
||||
+#define SWIFT_ABI_ARM64_SWIFT_SPARE_BITS_MASK SWIFT_ABI_ANDROID_ARM64_SWIFT_SPARE_BITS_MASK
|
||||
+#else
|
||||
// TBI guarantees the top byte of pointers is unused, but ARMv8.5-A
|
||||
// claims the bottom four bits of that for memory tagging.
|
||||
// Heap objects are eight-byte aligned.
|
||||
#define SWIFT_ABI_ARM64_SWIFT_SPARE_BITS_MASK 0xF000000000000007ULL
|
||||
+#endif
|
||||
|
||||
// Objective-C reserves just the high bit for tagged pointers.
|
||||
#define SWIFT_ABI_ARM64_OBJC_RESERVED_BITS_MASK 0x8000000000000000ULL
|
|
@ -0,0 +1,54 @@
|
|||
From 70a8c30f1a1ae35e7742ee2224bdcf8eb95572a5 Mon Sep 17 00:00:00 2001
|
||||
Date: Sat, 13 Aug 2022 11:06:02 +0530
|
||||
Subject: [PATCH] [Driver] Work around lld 13+ issue with --gc-sections for ELF
|
||||
by adding -z nostart-stop-gc
|
||||
|
||||
diff --git a/swift/lib/Driver/UnixToolChains.cpp b/swift/lib/Driver/UnixToolChains.cpp
|
||||
index dc14e7782c79a..6f85e245a002e 100644
|
||||
--- a/swift/lib/Driver/UnixToolChains.cpp
|
||||
+++ b/swift/lib/Driver/UnixToolChains.cpp
|
||||
@@ -184,6 +184,17 @@ toolchains::GenericUnix::constructInvocation(const DynamicLinkJobAction &job,
|
||||
#else
|
||||
Arguments.push_back(context.Args.MakeArgString("-fuse-ld=" + Linker));
|
||||
#endif
|
||||
+ // Starting with lld 13, Swift stopped working with the lld --gc-sections
|
||||
+ // implementation for ELF, unless -z nostart-stop-gc is also passed to lld:
|
||||
+ //
|
||||
+ // https://reviews.llvm.org/D96914
|
||||
+ if (Linker == "lld" || (Linker.length() > 5 &&
|
||||
+ Linker.substr(Linker.length() - 6) == "ld.lld")) {
|
||||
+ Arguments.push_back("-Xlinker");
|
||||
+ Arguments.push_back("-z");
|
||||
+ Arguments.push_back("-Xlinker");
|
||||
+ Arguments.push_back("nostart-stop-gc");
|
||||
+ }
|
||||
}
|
||||
|
||||
// Configure the toolchain.
|
||||
From 546768bb95b0bcc3fb480525f269d838c76da530 Mon Sep 17 00:00:00 2001
|
||||
Date: Sun, 14 Aug 2022 16:10:36 +0530
|
||||
Subject: [PATCH] Work around lld 13+ issue with --gc-sections for ELF by
|
||||
adding -z nostart-stop-gc
|
||||
|
||||
diff --git a/swift-driver/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift b/swift-driver/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift
|
||||
index ff2799a82..c274901b3 100644
|
||||
--- a/swift-driver/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift
|
||||
+++ b/swift-driver/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift
|
||||
@@ -84,6 +84,17 @@ extension GenericUnixToolchain {
|
||||
#else
|
||||
commandLine.appendFlag("-fuse-ld=\(linker)")
|
||||
#endif
|
||||
+ // Starting with lld 13, Swift stopped working with the lld
|
||||
+ // --gc-sections implementation for ELF, unless -z nostart-stop-gc is
|
||||
+ // also passed to lld:
|
||||
+ //
|
||||
+ // https://reviews.llvm.org/D96914
|
||||
+ if linker == "lld" || linker.hasSuffix("ld.lld") {
|
||||
+ commandLine.appendFlag(.Xlinker)
|
||||
+ commandLine.appendFlag("-z")
|
||||
+ commandLine.appendFlag(.Xlinker)
|
||||
+ commandLine.appendFlag("nostart-stop-gc")
|
||||
+ }
|
||||
}
|
||||
|
||||
// Configure the toolchain.
|
|
@ -1,292 +0,0 @@
|
|||
From 7b2256f97b59192046eab312838f467def880605
|
||||
Date: Sun, 9 Jan 2022 21:45:13 +0530
|
||||
Subject: [PATCH] [android] Move the string and other tags in pointers to the
|
||||
second byte because Android enabled memory tagging
|
||||
|
||||
Starting with Android 11, AArch64 placed a tag in the top byte of pointers to
|
||||
allocations, which has been slowly rolling out to more devices and collides
|
||||
with Swift's tags. Moving these tags to the second byte works around this
|
||||
problem.
|
||||
---
|
||||
stdlib/public/SwiftShims/HeapObject.h | 10 +++++
|
||||
stdlib/public/core/KeyPath.swift | 10 +++++
|
||||
stdlib/public/core/SmallString.swift | 9 ++++
|
||||
stdlib/public/core/StringObject.swift | 64 ++++++++++++++++++++++++++-
|
||||
stdlib/public/runtime/HeapObject.cpp | 5 +++
|
||||
|
||||
diff --git a/swift/stdlib/public/SwiftShims/HeapObject.h b/swift/stdlib/public/SwiftShims/HeapObject.h
|
||||
index 3933b0b8d40e2..f45e8774951b3 100644
|
||||
--- a/swift/stdlib/public/SwiftShims/HeapObject.h
|
||||
+++ b/swift/stdlib/public/SwiftShims/HeapObject.h
|
||||
@@ -157,12 +157,22 @@ static_assert(alignof(HeapObject) == alignof(void*),
|
||||
#endif
|
||||
#define _swift_abi_SwiftSpareBitsMask \
|
||||
(__swift_uintptr_t) SWIFT_ABI_ARM64_SWIFT_SPARE_BITS_MASK
|
||||
+#if defined(__ANDROID__)
|
||||
+#define _swift_abi_ObjCReservedBitsMask \
|
||||
+ (__swift_uintptr_t) SWIFT_ABI_ANDROID_ARM64_OBJC_RESERVED_BITS_MASK
|
||||
+#else
|
||||
#define _swift_abi_ObjCReservedBitsMask \
|
||||
(__swift_uintptr_t) SWIFT_ABI_ARM64_OBJC_RESERVED_BITS_MASK
|
||||
+#endif
|
||||
#define _swift_abi_ObjCReservedLowBits \
|
||||
(unsigned) SWIFT_ABI_ARM64_OBJC_NUM_RESERVED_LOW_BITS
|
||||
+#if defined(__ANDROID__)
|
||||
+#define _swift_BridgeObject_TaggedPointerBits \
|
||||
+ (__swift_uintptr_t) SWIFT_ABI_DEFAULT_BRIDGEOBJECT_TAG_64 >> 8
|
||||
+#else
|
||||
#define _swift_BridgeObject_TaggedPointerBits \
|
||||
(__swift_uintptr_t) SWIFT_ABI_DEFAULT_BRIDGEOBJECT_TAG_64
|
||||
+#endif
|
||||
|
||||
#elif defined(__powerpc64__)
|
||||
|
||||
diff --git a/swift/stdlib/public/core/KeyPath.swift b/swift/stdlib/public/core/KeyPath.swift
|
||||
index 2d8f03974253b..3501f31c83a9e 100644
|
||||
--- a/swift/stdlib/public/core/KeyPath.swift
|
||||
+++ b/swift/stdlib/public/core/KeyPath.swift
|
||||
@@ -1764,7 +1764,7 @@ internal struct KeyPathBuffer {
|
||||
internal mutating func pushRaw(size: Int, alignment: Int)
|
||||
-> UnsafeMutableRawBufferPointer {
|
||||
var baseAddress = buffer.baseAddress.unsafelyUnwrapped
|
||||
- var misalign = Int(bitPattern: baseAddress) % alignment
|
||||
+ var misalign = Int(bitPattern: baseAddress) & (alignment - 1)
|
||||
if misalign != 0 {
|
||||
misalign = alignment - misalign
|
||||
baseAddress = baseAddress.advanced(by: misalign)
|
||||
@@ -3242,7 +3242,7 @@ internal struct InstantiateKeyPathBuffer: KeyPathPatternVisitor {
|
||||
) {
|
||||
let alignment = MemoryLayout<T>.alignment
|
||||
var baseAddress = destData.baseAddress.unsafelyUnwrapped
|
||||
- var misalign = Int(bitPattern: baseAddress) % alignment
|
||||
+ var misalign = Int(bitPattern: baseAddress) & (alignment - 1)
|
||||
if misalign != 0 {
|
||||
misalign = alignment - misalign
|
||||
baseAddress = baseAddress.advanced(by: misalign)
|
||||
diff --git a/swift/stdlib/public/core/SmallString.swift b/swift/stdlib/public/core/SmallString.swift
|
||||
index df46b4e8bf449..ac0969b57041e 100644
|
||||
--- a/swift/stdlib/public/core/SmallString.swift
|
||||
+++ b/swift/stdlib/public/core/SmallString.swift
|
||||
@@ -23,6 +23,9 @@
|
||||
// ↑ ↑
|
||||
// first (leftmost) code unit discriminator (incl. count)
|
||||
//
|
||||
+// On Android AArch64, there is one less byte available because the discriminator
|
||||
+// is stored in the penultimate code unit instead, to match where it's stored
|
||||
+// for large strings.
|
||||
@frozen @usableFromInline
|
||||
internal struct _SmallString {
|
||||
@usableFromInline
|
||||
@@ -78,6 +81,8 @@ extension _SmallString {
|
||||
internal static var capacity: Int {
|
||||
#if arch(i386) || arch(arm) || arch(arm64_32) || arch(wasm32)
|
||||
return 10
|
||||
+#elseif os(Android) && arch(arm64)
|
||||
+ return 14
|
||||
#else
|
||||
return 15
|
||||
#endif
|
||||
@@ -111,7 +116,11 @@ extension _SmallString {
|
||||
// usage: it always clears the discriminator and count (in case it's full)
|
||||
@inlinable @inline(__always)
|
||||
internal var zeroTerminatedRawCodeUnits: RawBitPattern {
|
||||
+#if os(Android) && arch(arm64)
|
||||
+ let smallStringCodeUnitMask = ~UInt64(0xFFFF).bigEndian // zero last two bytes
|
||||
+#else
|
||||
let smallStringCodeUnitMask = ~UInt64(0xFF).bigEndian // zero last byte
|
||||
+#endif
|
||||
return (self._storage.0, self._storage.1 & smallStringCodeUnitMask)
|
||||
}
|
||||
|
||||
diff --git a/swift/stdlib/public/core/StringObject.swift b/swift/stdlib/public/core/StringObject.swift
|
||||
index b087e87f51eb7..88ff7fbf08980 100644
|
||||
--- a/swift/stdlib/public/core/StringObject.swift
|
||||
+++ b/swift/stdlib/public/core/StringObject.swift
|
||||
@@ -56,6 +56,11 @@
|
||||
can compile to a fused check-and-branch, even if that burns part of the
|
||||
encoding space.
|
||||
|
||||
+ On Android AArch64, we cannot use the top byte for large strings because it is
|
||||
+ reserved by the OS for memory tagging since Android 11, so shift the
|
||||
+ discriminator to the second byte instead. This burns one more byte on small
|
||||
+ strings.
|
||||
+
|
||||
On 32-bit platforms, we store an explicit discriminator (as a UInt8) with the
|
||||
same encoding as above, placed in the high bits. E.g. `b62` above is in
|
||||
`_discriminator`'s `b6`.
|
||||
@@ -111,8 +116,13 @@ internal struct _StringObject {
|
||||
|
||||
@inlinable @inline(__always)
|
||||
init(count: Int, variant: Variant, discriminator: UInt64, flags: UInt16) {
|
||||
+#if os(Android) && arch(arm64)
|
||||
+ _internalInvariant(discriminator & 0x00FF_0000_0000_0000 == discriminator,
|
||||
+ "only the second byte can carry the discriminator and small count on Android AArch64")
|
||||
+#else
|
||||
_internalInvariant(discriminator & 0xFF00_0000_0000_0000 == discriminator,
|
||||
"only the top byte can carry the discriminator and small count")
|
||||
+#endif
|
||||
|
||||
self._count = count
|
||||
self._variant = variant
|
||||
@@ -349,7 +359,13 @@ extension _StringObject.Nibbles {
|
||||
extension _StringObject.Nibbles {
|
||||
// Mask for address bits, i.e. non-discriminator and non-extra high bits
|
||||
@inlinable @inline(__always)
|
||||
- static internal var largeAddressMask: UInt64 { return 0x0FFF_FFFF_FFFF_FFFF }
|
||||
+ static internal var largeAddressMask: UInt64 {
|
||||
+#if os(Android) && arch(arm64)
|
||||
+ return 0xFF0F_FFFF_FFFF_FFFF
|
||||
+#else
|
||||
+ return 0x0FFF_FFFF_FFFF_FFFF
|
||||
+#endif
|
||||
+ }
|
||||
|
||||
// Mask for address bits, i.e. non-discriminator and non-extra high bits
|
||||
@inlinable @inline(__always)
|
||||
@@ -360,20 +376,32 @@ extension _StringObject.Nibbles {
|
||||
// Discriminator for small strings
|
||||
@inlinable @inline(__always)
|
||||
internal static func small(isASCII: Bool) -> UInt64 {
|
||||
+#if os(Android) && arch(arm64)
|
||||
+ return isASCII ? 0x00E0_0000_0000_0000 : 0x00A0_0000_0000_0000
|
||||
+#else
|
||||
return isASCII ? 0xE000_0000_0000_0000 : 0xA000_0000_0000_0000
|
||||
+#endif
|
||||
}
|
||||
|
||||
// Discriminator for small strings
|
||||
@inlinable @inline(__always)
|
||||
internal static func small(withCount count: Int, isASCII: Bool) -> UInt64 {
|
||||
_internalInvariant(count <= _SmallString.capacity)
|
||||
+#if os(Android) && arch(arm64)
|
||||
+ return small(isASCII: isASCII) | UInt64(truncatingIfNeeded: count) &<< 48
|
||||
+#else
|
||||
return small(isASCII: isASCII) | UInt64(truncatingIfNeeded: count) &<< 56
|
||||
+#endif
|
||||
}
|
||||
|
||||
// Discriminator for large, immortal, swift-native strings
|
||||
@inlinable @inline(__always)
|
||||
internal static func largeImmortal() -> UInt64 {
|
||||
+#if os(Android) && arch(arm64)
|
||||
+ return 0x0080_0000_0000_0000
|
||||
+#else
|
||||
return 0x8000_0000_0000_0000
|
||||
+#endif
|
||||
}
|
||||
|
||||
// Discriminator for large, mortal (i.e. managed), swift-native strings
|
||||
@@ -397,7 +425,11 @@ extension _StringObject {
|
||||
|
||||
@inlinable @inline(__always)
|
||||
internal var isImmortal: Bool {
|
||||
+#if os(Android) && arch(arm64)
|
||||
+ return (discriminatedObjectRawBits & 0x0080_0000_0000_0000) != 0
|
||||
+#else
|
||||
return (discriminatedObjectRawBits & 0x8000_0000_0000_0000) != 0
|
||||
+#endif
|
||||
}
|
||||
|
||||
@inlinable @inline(__always)
|
||||
@@ -405,7 +437,11 @@ extension _StringObject {
|
||||
|
||||
@inlinable @inline(__always)
|
||||
internal var isSmall: Bool {
|
||||
+#if os(Android) && arch(arm64)
|
||||
+ return (discriminatedObjectRawBits & 0x0020_0000_0000_0000) != 0
|
||||
+#else
|
||||
return (discriminatedObjectRawBits & 0x2000_0000_0000_0000) != 0
|
||||
+#endif
|
||||
}
|
||||
|
||||
@inlinable @inline(__always)
|
||||
@@ -419,7 +455,11 @@ extension _StringObject {
|
||||
// - Non-Cocoa shared strings
|
||||
@inlinable @inline(__always)
|
||||
internal var providesFastUTF8: Bool {
|
||||
+#if os(Android) && arch(arm64)
|
||||
+ return (discriminatedObjectRawBits & 0x0010_0000_0000_0000) == 0
|
||||
+#else
|
||||
return (discriminatedObjectRawBits & 0x1000_0000_0000_0000) == 0
|
||||
+#endif
|
||||
}
|
||||
|
||||
@inlinable @inline(__always)
|
||||
@@ -429,16 +469,26 @@ extension _StringObject {
|
||||
// conforms to `_AbstractStringStorage`
|
||||
@inline(__always)
|
||||
internal var hasStorage: Bool {
|
||||
+#if os(Android) && arch(arm64)
|
||||
+ return (discriminatedObjectRawBits & 0x00F0_0000_0000_0000) == 0
|
||||
+#else
|
||||
return (discriminatedObjectRawBits & 0xF000_0000_0000_0000) == 0
|
||||
+#endif
|
||||
}
|
||||
|
||||
// Whether we are a mortal, native (tail-allocated) string
|
||||
@inline(__always)
|
||||
internal var hasNativeStorage: Bool {
|
||||
+#if os(Android) && arch(arm64)
|
||||
+ // Android uses the same logic as explained below for other platforms,
|
||||
+ // except isSmall is at b53, so shift it to b61 first before proceeding.
|
||||
+ let bits = ~(discriminatedObjectRawBits << 8) & self._countAndFlagsBits
|
||||
+#else
|
||||
// b61 on the object means isSmall, and on countAndFlags means
|
||||
// isNativelyStored. We just need to check that b61 is 0 on the object and 1
|
||||
// on countAndFlags.
|
||||
let bits = ~discriminatedObjectRawBits & self._countAndFlagsBits
|
||||
+#endif
|
||||
let result = bits & 0x2000_0000_0000_0000 != 0
|
||||
_internalInvariant(!result || hasStorage, "native storage needs storage")
|
||||
return result
|
||||
@@ -466,7 +516,11 @@ extension _StringObject {
|
||||
@inline(__always)
|
||||
internal var largeIsCocoa: Bool {
|
||||
_internalInvariant(isLarge)
|
||||
+#if os(Android) && arch(arm64)
|
||||
+ return (discriminatedObjectRawBits & 0x0040_0000_0000_0000) != 0
|
||||
+#else
|
||||
return (discriminatedObjectRawBits & 0x4000_0000_0000_0000) != 0
|
||||
+#endif
|
||||
}
|
||||
|
||||
// Whether this string is in one of our fastest representations:
|
||||
@@ -535,7 +589,11 @@ extension _StringObject {
|
||||
|
||||
@inlinable
|
||||
internal static func getSmallCount(fromRaw x: UInt64) -> Int {
|
||||
+#if os(Android) && arch(arm64)
|
||||
+ return Int(truncatingIfNeeded: (x & 0x000F_0000_0000_0000) &>> 48)
|
||||
+#else
|
||||
return Int(truncatingIfNeeded: (x & 0x0F00_0000_0000_0000) &>> 56)
|
||||
+#endif
|
||||
}
|
||||
|
||||
@inlinable @inline(__always)
|
||||
@@ -546,7 +604,11 @@ extension _StringObject {
|
||||
|
||||
@inlinable
|
||||
internal static func getSmallIsASCII(fromRaw x: UInt64) -> Bool {
|
||||
+#if os(Android) && arch(arm64)
|
||||
+ return x & 0x0040_0000_0000_0000 != 0
|
||||
+#else
|
||||
return x & 0x4000_0000_0000_0000 != 0
|
||||
+#endif
|
||||
}
|
||||
@inlinable @inline(__always)
|
||||
internal var smallIsASCII: Bool {
|
||||
diff --git a/swift/stdlib/public/runtime/HeapObject.cpp b/swift/stdlib/public/runtime/HeapObject.cpp
|
||||
index 7f6f6ddbdaee1..d1ab476740acd 100644
|
||||
--- a/swift/stdlib/public/runtime/HeapObject.cpp
|
||||
+++ b/swift/stdlib/public/runtime/HeapObject.cpp
|
||||
@@ -66,6 +66,10 @@ static inline bool isValidPointerForNativeRetain(const void *p) {
|
||||
// arm64_32 is special since it has 32-bit pointers but __arm64__ is true.
|
||||
// Catch it early since __POINTER_WIDTH__ is generally non-portable.
|
||||
return p != nullptr;
|
||||
+#elif defined(__ANDROID__) && defined(__aarch64__)
|
||||
+ // Check the top of the second byte instead, since Android AArch64 reserves
|
||||
+ // the top byte for its own pointer tagging since Android 11.
|
||||
+ return (intptr_t)((uintptr_t)p << 8) > 0;
|
||||
#elif defined(__x86_64__) || defined(__arm64__) || defined(__aarch64__) || defined(_M_ARM64) || defined(__s390x__) || (defined(__powerpc64__) && defined(__LITTLE_ENDIAN__))
|
||||
// On these platforms, except s390x, the upper half of address space is reserved for the
|
||||
// kernel, so we can assume that pointer values in this range are invalid.
|
|
@ -20,15 +20,6 @@ index 7ebcdc070c1..5a6ed88182e 100644
|
|||
|
||||
def swiftpm_config(self, args, output_dir, swift_toolchain, resource_path):
|
||||
config_file = '%s/swiftpm-android-%s.json' % (output_dir, args.android_arch)
|
||||
@@ -190,7 +190,7 @@ class AndroidPlatform(Platform):
|
||||
spm_json += ' "version": 1,\n'
|
||||
spm_json += ' "target": "%s-unknown-linux-android%s",\n' % (
|
||||
args.android_arch, args.android_api_level)
|
||||
- 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' % (
|
||||
@@ -203,6 +203,7 @@ class AndroidPlatform(Platform):
|
||||
spm_json += ' "-tools-directory", "%s/bin",\n' % (
|
||||
self.ndk_toolchain_path(args))
|
||||
|
|
|
@ -1,110 +0,0 @@
|
|||
diff --git a/sourcekit-lsp/Utilities/build-script-helper.py b/sourcekit-lsp/Utilities/build-script-helper.py
|
||||
--- a/sourcekit-lsp/Utilities/build-script-helper.py
|
||||
+++ b/sourcekit-lsp/Utilities/build-script-helper.py
|
||||
@@ -93,6 +93,10 @@
|
||||
|
||||
def handle_invocation(swift_exec, args):
|
||||
swiftpm_args = get_swiftpm_options(args)
|
||||
+ if args.cross_compile_host and re.match('android-aarch64', args.cross_compile_host):
|
||||
+ swiftpm_exec = os.path.join(os.path.realpath(os.getenv("SWIFT_BINDIR")), "swift")
|
||||
+ else:
|
||||
+ swiftpm_exec = swift_exec
|
||||
|
||||
env = os.environ
|
||||
# Set the toolchain used in tests at runtime
|
||||
@@ -120,7 +124,7 @@
|
||||
env['SWIFT_EXEC'] = '%sc' % (swift_exec)
|
||||
|
||||
if args.action == 'build':
|
||||
- swiftpm('build', swift_exec, swiftpm_args, env)
|
||||
+ swiftpm('build', swiftpm_exec, swiftpm_args, env)
|
||||
elif args.action == 'test':
|
||||
if not args.skip_long_tests:
|
||||
env['SOURCEKIT_LSP_ENABLE_LONG_TESTS'] = '1'
|
||||
@@ -135,9 +139,9 @@
|
||||
test_args += ['--parallel']
|
||||
swiftpm('test', swift_exec, test_args, env)
|
||||
elif args.action == 'install':
|
||||
- bin_path = swiftpm_bin_path(swift_exec, swiftpm_args, env)
|
||||
+ bin_path = swiftpm_bin_path(swiftpm_exec, swiftpm_args, env)
|
||||
swiftpm_args += ['-Xswiftc', '-no-toolchain-stdlib-rpath']
|
||||
- swiftpm('build', swift_exec, swiftpm_args, env)
|
||||
+ swiftpm('build', swiftpm_exec, swiftpm_args, env)
|
||||
|
||||
if not args.install_prefixes:
|
||||
args.install_prefixes = [args.toolchain]
|
||||
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 575fa374ad..3554577f92 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
|
||||
@@ -202,7 +202,7 @@ class Product(object):
|
||||
if self.is_darwin_host(host_target):
|
||||
install_destdir = self.host_install_destdir(host_target)
|
||||
else:
|
||||
- install_destdir = os.path.join(install_destdir, self.args.host_target)
|
||||
+ return os.path.join(os.path.dirname(self.build_dir), "swift-%s" % self.args.host_target)
|
||||
return targets.toolchain_path(install_destdir,
|
||||
self.args.install_prefix)
|
||||
|
||||
diff --git a/swift-driver/Utilities/build-script-helper.py b/swift-driver/Utilities/build-script-helper.py
|
||||
--- a/swift-driver/Utilities/build-script-helper.py
|
||||
+++ b/swift-driver/Utilities/build-script-helper.py
|
||||
@@ -166,6 +167,10 @@
|
||||
toolchain_bin = os.path.join(args.toolchain, 'bin')
|
||||
swift_exec = os.path.join(toolchain_bin, 'swift')
|
||||
swiftc_exec = os.path.join(toolchain_bin, 'swiftc')
|
||||
+ if args.cross_compile_hosts and re.match('android-aarch64', args.cross_compile_hosts[0]):
|
||||
+ swiftpm_exec = os.path.join(os.path.realpath(os.getenv("SWIFT_BINDIR")), "swift")
|
||||
+ else:
|
||||
+ swiftpm_exec = swift_exec
|
||||
|
||||
# Platform-specific targets for which we must build swift-driver
|
||||
if args.cross_compile_hosts:
|
||||
@@ -190,7 +194,7 @@
|
||||
|
||||
if args.action == 'build':
|
||||
if args.cross_compile_hosts and not re.match('-macosx', args.cross_compile_hosts[0]):
|
||||
- swiftpm('build', swift_exec, swiftpm_args, env)
|
||||
+ swiftpm('build', swiftpm_exec, swiftpm_args, env)
|
||||
else:
|
||||
build_using_cmake(args, toolchain_bin, args.build_path, targets)
|
||||
|
||||
@@ -216,8 +220,8 @@
|
||||
build_using_cmake(args, toolchain_bin, args.build_path, targets)
|
||||
install(args, args.build_path, targets)
|
||||
else:
|
||||
- bin_path = swiftpm_bin_path(swift_exec, swiftpm_args, env)
|
||||
- swiftpm('build', swift_exec, swiftpm_args, env)
|
||||
+ bin_path = swiftpm_bin_path(swiftpm_exec, swiftpm_args, env)
|
||||
+ swiftpm('build', swiftpm_exec, swiftpm_args, env)
|
||||
non_darwin_install(args, bin_path)
|
||||
else:
|
||||
assert False, 'unknown action \'{}\''.format(args.action)
|
||||
diff --git a/swiftpm/Utilities/bootstrap b/swiftpm/Utilities/bootstrap
|
||||
index 6ae084e9..379d1738 100755
|
||||
--- a/swiftpm/Utilities/bootstrap
|
||||
+++ b/swiftpm/Utilities/bootstrap
|
||||
@@ -211,8 +211,9 @@ def parse_build_args(args):
|
||||
args.bootstrap_dir = os.path.join(args.target_dir, "bootstrap")
|
||||
args.conf = 'release' if args.release else 'debug'
|
||||
args.bin_dir = os.path.join(args.target_dir, args.conf)
|
||||
- args.bootstrap = not args.skip_cmake_bootstrap or \
|
||||
- not os.path.exists(os.path.join(os.path.split(args.swiftc_path)[0], "swift-build"))
|
||||
+ args.bootstrap = not args.skip_cmake_bootstrap or \
|
||||
+ (not (args.cross_compile_hosts and re.match('android-aarch64', args.cross_compile_hosts)) and \
|
||||
+ not os.path.exists(os.path.join(os.path.split(args.swiftc_path)[0], "swift-build")))
|
||||
|
||||
def parse_test_args(args):
|
||||
"""Parses and cleans arguments necessary for the test action."""
|
||||
@@ -622,7 +623,10 @@ def build_swiftpm_with_swiftpm(args, integrated_swift_driver):
|
||||
swiftpm_args.append(os.path.join(args.bootstrap_dir, "bin/swift-build"))
|
||||
else:
|
||||
note("Building SwiftPM (with a prebuilt swift-build)")
|
||||
- swiftpm_args.append(os.path.join(os.path.split(args.swiftc_path)[0], "swift-build"))
|
||||
+ if args.cross_compile_hosts and re.match('android-aarch64', args.cross_compile_hosts):
|
||||
+ swiftpm_args.append(os.path.join(os.path.realpath(os.getenv("SWIFT_BINDIR")), "swift-build"))
|
||||
+ else:
|
||||
+ swiftpm_args.append(os.path.join(os.path.split(args.swiftc_path)[0], "swift-build"))
|
||||
|
||||
swiftpm_args.append("--disable-sandbox")
|
||||
|
|
@ -19,7 +19,7 @@ termux_setup_swift() {
|
|||
termux_download \
|
||||
https://download.swift.org/swift-$TERMUX_SWIFT_VERSION-release/ubuntu2004/swift-$TERMUX_SWIFT_VERSION-$SWIFT_RELEASE/$SWIFT_BIN.tar.gz \
|
||||
$SWIFT_TAR \
|
||||
ac1c711985113d0d9daf7bf80205935a0688fb146546690d93c23df54d81cfb7
|
||||
81a81d46f517b485f16ebe41b7cf1411fd652f1290268d6983062b91cf3aee67
|
||||
|
||||
(cd $TERMUX_PKG_TMPDIR ; tar xf $SWIFT_TAR ; mv $SWIFT_BIN $SWIFT_FOLDER; rm $SWIFT_TAR)
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue