diff --git a/packages/libdispatch/build.sh b/packages/libdispatch/build.sh index 7d817a1e589df5..bc7f0589c7387c 100644 --- a/packages/libdispatch/build.sh +++ b/packages/libdispatch/build.sh @@ -2,9 +2,8 @@ TERMUX_PKG_HOMEPAGE=https://github.com/swiftlang/swift-corelibs-libdispatch TERMUX_PKG_DESCRIPTION="The libdispatch project, for concurrency on multicore hardware" TERMUX_PKG_LICENSE="Apache-2.0" TERMUX_PKG_MAINTAINER="@finagolfin" -TERMUX_PKG_VERSION="1:6.1" -TERMUX_PKG_REVISION=1 +TERMUX_PKG_VERSION="1:6.2.1" TERMUX_PKG_SRCURL=https://github.com/swiftlang/swift-corelibs-libdispatch/archive/swift-${TERMUX_PKG_VERSION:2}-RELEASE.tar.gz -TERMUX_PKG_SHA256=5bba8d7442890f7dbd37a9245340c5bb0c4c924dee6180ba30385b24e3fdf121 +TERMUX_PKG_SHA256=18c6d5945e6668c1928deb72f524dfa26ad9d1b226c7d618cdf766885ccc433c TERMUX_PKG_AUTO_UPDATE=false TERMUX_PKG_DEPENDS="libc++, libblocksruntime" diff --git a/packages/llbuild/build.sh b/packages/llbuild/build.sh index bdd40ac289cf72..6d9c9b3c2a1e5b 100644 --- a/packages/llbuild/build.sh +++ b/packages/llbuild/build.sh @@ -2,9 +2,8 @@ TERMUX_PKG_HOMEPAGE=https://github.com/swiftlang/swift-llbuild TERMUX_PKG_DESCRIPTION="A low-level build system, used by the Swift Package Manager" TERMUX_PKG_LICENSE="Apache-2.0, NCSA" TERMUX_PKG_MAINTAINER="@finagolfin" -TERMUX_PKG_VERSION=6.1 -TERMUX_PKG_REVISION=1 +TERMUX_PKG_VERSION=6.2.1 TERMUX_PKG_SRCURL=https://github.com/swiftlang/swift-llbuild/archive/swift-${TERMUX_PKG_VERSION}-RELEASE.tar.gz -TERMUX_PKG_SHA256=68df17453b52ac9fd334dec53e05f87c49e3458db0800273ff1f675525504996 +TERMUX_PKG_SHA256=fdc26af47b53779776f1294f674886c774636ef0b0b1b2c2ed90f9626bd018ed TERMUX_PKG_DEPENDS="libc++, libandroid-spawn, libsqlite" TERMUX_PKG_NO_STATICSPLIT=true diff --git a/packages/llbuild/lib-llvm-Support-CmakeLists.txt.patch b/packages/llbuild/lib-llvm-Support-CmakeLists.txt.patch index 9771b7016ad3f4..9ddd3ff132cdd6 100644 --- a/packages/llbuild/lib-llvm-Support-CmakeLists.txt.patch +++ b/packages/llbuild/lib-llvm-Support-CmakeLists.txt.patch @@ -5,7 +5,7 @@ index 8e79e18..a844183 100644 @@ -65,5 +65,5 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") endif() - if(${CMAKE_SYSTEM_NAME} MATCHES "Android|Darwin|Linux") + if(${CMAKE_SYSTEM_NAME} MATCHES "Android|Darwin|Linux|FreeBSD") - target_link_libraries(llvmSupport PRIVATE curses) + target_link_libraries(llvmSupport PRIVATE android-spawn curses) endif() diff --git a/packages/swift/build.sh b/packages/swift/build.sh index 83c1664b29bbdb..811fa90f8474f1 100644 --- a/packages/swift/build.sh +++ b/packages/swift/build.sh @@ -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="@finagolfin" -TERMUX_PKG_VERSION=6.1.3 +TERMUX_PKG_VERSION=6.2.1 SWIFT_RELEASE="RELEASE" TERMUX_PKG_SRCURL=https://github.com/swiftlang/swift/archive/swift-$TERMUX_PKG_VERSION-$SWIFT_RELEASE.tar.gz -TERMUX_PKG_SHA256=2a4f0045f7439c3dbed39f67487729a10bc8a8042c4a1d24a63db455ee67cd5f +TERMUX_PKG_SHA256=39825af3b1ab523ed4970e1315a14b5379fb5f8046170c27a330a179d982fe2a TERMUX_PKG_AUTO_UPDATE=false TERMUX_PKG_HOSTBUILD=true TERMUX_PKG_DEPENDS="clang, libandroid-execinfo, libandroid-glob, libandroid-posix-semaphore, libandroid-shmem, libandroid-spawn, libandroid-spawn-static, libandroid-sysv-semaphore, libcurl, libuuid, libxml2, libdispatch, llbuild, pkg-config, swift-sdk-${TERMUX_ARCH/_/-}" @@ -35,30 +35,36 @@ termux_step_post_get_source() { mv .temp swift declare -A library_checksums - library_checksums[swift-cmark]=bc69d7838b25c66f8cdafcb4d6f957a33b8136de69dbed08653a47a880867da4 - library_checksums[llvm-project]=831136c438a64742f32a0d3280d2842311d2470101d5f6fc9509cbfcaab1ccd2 - library_checksums[swift-experimental-string-processing]=e60e4cf4c8c2f4d31e77e7511b80f957b5898b1d6977c1d50f6166d777250f30 - library_checksums[swift-syntax]=6c02c84c4e8064eb243b3f411fb2b52421b823a5ed77b85805f20e8ea4accf85 - library_checksums[swift-corelibs-libdispatch]=9599cc787f7e52f1815de127389aaf2359f5fe430844c1d97b1a3e9838ceea54 - library_checksums[swift-corelibs-foundation]=3ab783ec14137c8eca5d2afac1903cae7a6b2b16e43ef56c175807c161e6965e - library_checksums[swift-foundation]=4a628ebec75da0de604d58162a84b0bba2b668b3baf36a9c45ab971197738be5 - library_checksums[swift-foundation-icu]=f7d19fb430004ecf69c312bab9b355e9f542c839e43848353b19fa04901e7fc6 - library_checksums[swift-corelibs-xctest]=d36525da839ceacbcf944111a05e55141ca469aeb7257a8ad40072c7ee9a908b + library_checksums[swift-cmark]=4f54c388f9a98527cf751ffedb35898c2198b4f23cf16d109203f9ba54a62379 + library_checksums[llvm-project]=c0bd5b4bc69dceda1dda5aabee6f24e42e87ec2ccb0ee5f002448ab3c4769fdf + library_checksums[swift-experimental-string-processing]=a0055310ebc885ba4781edbcc9aaf44f7ae0cdbc633846bc0a9a6b3f53b29029 + library_checksums[swift-syntax]=c407424ca6da371425fbbe2a3f097f9df25118764a45b4a3af5e6d0ca4abc14a + library_checksums[swift-corelibs-libdispatch]=18c6d5945e6668c1928deb72f524dfa26ad9d1b226c7d618cdf766885ccc433c + library_checksums[swift-corelibs-foundation]=c395a3ca39291bda0f03946c2c4b5730ed02d629a3539adaf90184300228ea72 + library_checksums[swift-foundation]=411b967971eaa6c6ab4a1ba84fd145c17f4cb053515277bb903f18bf0183edb0 + library_checksums[swift-foundation-icu]=6e8ce5b8491821e840ea720b795264b5dcc98ad38ea122bc016593ac2be1f520 + library_checksums[swift-corelibs-xctest]=b0d7922af89146ab5a12d9744e965ca3bf587c9bbda2f435ab56a6dad86004a5 library_checksums[swift-toolchain-sqlite]=c8704e70c4847a8dbd47aafb25d293fbe1e1bafade16cfa64e04f751e33db0ca - library_checksums[swift-llbuild]=ab40529401814b69e45c15a5ca5618063819197c9d905c1bad73c9b41976a573 - library_checksums[swift-testing]=81db185d5c0d7e3914b1e01a45ba79a316a1e711a790254c0b00cbc87f8b59ce + library_checksums[swift-llbuild]=fdc26af47b53779776f1294f674886c774636ef0b0b1b2c2ed90f9626bd018ed + library_checksums[swift-testing]=871e4eb07c1467dcac331f2bfa591cbd0a46dc2fee953f67f9b1402941fbd681 library_checksums[swift-argument-parser]=d5bad3a1da66d9f4ceb0a347a197b8fdd243a91ff6b2d72b78efb052b9d6dd33 - library_checksums[Yams]=a81c6b93f5d26bae1b619b7f8babbfe7c8abacf95b85916961d488888df886fb library_checksums[swift-collections]=7e5e48d0dc2350bed5919be5cf60c485e72a30bd1f2baf718a619317677b91db library_checksums[swift-crypto]=5c860c0306d0393ff06268f361aaf958656e1288353a0e23c3ad20de04319154 - library_checksums[swift-system]=02e13a7f77887c387f5aa1de05f4d4b8b158c35145450e1d9557d6c42b06cd1f + library_checksums[swift-system]=4bf5d5db04d48f484289371b63dd7bdced0db1ab1307c49127b9f894341a521d library_checksums[swift-asn1]=e0da995ae53e6fcf8251887f44d4030f6600e2f8f8451d9c92fcaf52b41b6c35 library_checksums[swift-certificates]=fcaca458aab45ee69b0f678b72c2194b15664cc5f6f5e48d0e3f62bc5d1202ca - library_checksums[swift-driver]=7ec505045455629d64bed8405da486760fc4016a6675fe2029f00fb957f86e2d - library_checksums[swift-tools-support-core]=77c8cbe97273c15a216b7319ccbc862c150b15c5bd4f0184b06f111bba89977e - library_checksums[swift-package-manager]=016dea5cc0bcd18735f7fb44231ae1e2143f10da9f9b2a3bd198d5c3ecbb63b8 - library_checksums[indexstore-db]=23d80191e3d0acf2b67b2ee8af271af90e9c0d7c48ee3623d9600f63f4923207 - library_checksums[sourcekit-lsp]=8d7dc4ec1475d560dadb620e364c0b0e344224549b74de607aaf10aa7e18c67e + library_checksums[swift-driver]=004db94c753b437c7ec8260a27f0b79509389503e661dacd244547fdfa1edc23 + library_checksums[swift-tools-support-core]=a1783534192eaef6de498c10ac02fab70aa64cbc9750252b30ff856046962530 + library_checksums[swift-build]=6284de0771da435c99af96aa1109029ffa47c18a3fb507d1c3266c42e9e7b0f1 + library_checksums[swift-package-manager]=b8f9d96ec4095e46d021dce896d47991ab30d7a487511054a9e630aff4303e42 + library_checksums[indexstore-db]=d13695451dfdbb5719527ec66f588da1f5b350553c231655d5dc1e4e84105cec + library_checksums[swift-docc]=954dcba69da56c63e1636f0dece60d4c8c1250e6bc2b97e20f72e50b068fdd1d + library_checksums[swift-docc-symbolkit]=47e9b732a3e03a803e962333f6934d2648e6685f17328dad7c56874047366b1d + library_checksums[swift-lmdb]=0e60fb6e3ff82253c529f1e0e902f556e8749c963ceb4db8305d2af152da465e + library_checksums[swift-markdown]=2cdb1751c22a22eb16b92cd12bb7c7d27d7af103173df1893c2c813dc2098a9e + library_checksums[swift-nio]=feb16b6d0e6d010be14c6732d7b02ddbbdc15a22e3912903f08ef5d73928f90d + library_checksums[swift-atomics]=33d9f4fbaeddee4bda3af2be126791ee8acf3d3c24a2244457641a20d39aec12 + library_checksums[sourcekit-lsp]=0ff9f6f2547b6585512193ee6d87980bc45b71051e19a74d3f09ba257b8123fe for library in "${!library_checksums[@]}"; do \ GH_ORG="apple" @@ -68,6 +74,9 @@ termux_step_post_get_source() { elif [ "$library" = "swift-asn1" ]; then SRC_VERSION="1.0.0" TAR_NAME=$SRC_VERSION + elif [ "$library" = "swift-atomics" ]; then + SRC_VERSION="1.2.0" + TAR_NAME=$SRC_VERSION elif [ "$library" = "swift-certificates" ]; then SRC_VERSION="1.0.1" TAR_NAME=$SRC_VERSION @@ -77,17 +86,16 @@ termux_step_post_get_source() { elif [ "$library" = "swift-crypto" ]; then SRC_VERSION="3.0.0" TAR_NAME=$SRC_VERSION + elif [ "$library" = "swift-nio" ]; then + SRC_VERSION="2.65.0" + TAR_NAME=$SRC_VERSION elif [ "$library" = "swift-system" ]; then - SRC_VERSION="1.3.0" + SRC_VERSION="1.5.0" TAR_NAME=$SRC_VERSION elif [ "$library" = "swift-toolchain-sqlite" ]; then GH_ORG="swiftlang" SRC_VERSION="1.0.1" TAR_NAME=$SRC_VERSION - elif [ "$library" = "Yams" ]; then - GH_ORG="jpsim" - SRC_VERSION="5.0.6" - TAR_NAME=$SRC_VERSION else GH_ORG="swiftlang" SRC_VERSION=$SWIFT_RELEASE @@ -104,7 +112,6 @@ termux_step_post_get_source() { mv swift-cmark cmark mv swift-llbuild llbuild - mv Yams yams mv swift-package-manager swiftpm } @@ -171,7 +178,7 @@ termux_step_make_install() { rm $TERMUX_PREFIX/lib/swift{,_static}/dispatch/*.h rm $TERMUX_PREFIX/lib/swift/android/lib{dispatch,BlocksRuntime}.so mv $TERMUX_PREFIX/lib/swift/android/lib[^_]*.so $TERMUX_PREFIX/opt/ndk-multilib/$TERMUX_ARCH-linux-android*/lib - mv $TERMUX_PREFIX/lib/swift/android/lib_FoundationICU.so $TERMUX_PREFIX/opt/ndk-multilib/$TERMUX_ARCH-linux-android*/lib + mv $TERMUX_PREFIX/lib/swift/android/lib_{Testing_,}Foundation*.so $TERMUX_PREFIX/opt/ndk-multilib/$TERMUX_ARCH-linux-android*/lib mv $TERMUX_PREFIX/lib/swift/android/lib*.a $TERMUX_PREFIX/lib/swift/android/$SWIFT_ARCH mv $TERMUX_PREFIX/lib/swift_static/android/lib*.a $TERMUX_PREFIX/lib/swift_static/android/$SWIFT_ARCH diff --git a/packages/swift/swift-android-spawn.patch b/packages/swift/swift-android-spawn.patch index c116b972501061..6e40b56378fef6 100644 --- a/packages/swift/swift-android-spawn.patch +++ b/packages/swift/swift-android-spawn.patch @@ -5,7 +5,7 @@ index 8e79e18..a844183 100644 @@ -65,5 +65,5 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") endif() - if(${CMAKE_SYSTEM_NAME} MATCHES "Android|Darwin|Linux") + if(${CMAKE_SYSTEM_NAME} MATCHES "Android|Darwin|Linux|FreeBSD") - target_link_libraries(llvmSupport PRIVATE curses) + target_link_libraries(llvmSupport PRIVATE android-spawn curses) endif() @@ -90,11 +90,11 @@ diff --git a/swiftpm/Utilities/bootstrap b/swiftpm/Utilities/bootstrap index 085056de..1ded1a90 100755 --- a/swiftpm/Utilities/bootstrap +++ b/swiftpm/Utilities/bootstrap -@@ -827,6 +827,7 @@ def get_swiftpm_flags(args): - # Don't use GNU strerror_r on Android. - if '-android' in args.build_target: - build_flags.extend(["-Xswiftc", "-Xcc", "-Xswiftc", "-U_GNU_SOURCE"]) -+ build_flags.extend(["-Xlinker", "-landroid-spawn"]) - - cross_compile_hosts = args.cross_compile_hosts - if cross_compile_hosts: +@@ -941,6 +941,7 @@ def get_swiftpm_flags(args): + build_flags += ["--arch", "x86_64", "--arch", "arm64"] + elif cross_compile_hosts.startswith('android-'): + build_flags.extend(["--destination", args.cross_compile_config]) ++ build_flags.extend(["-Xlinker", "-landroid-spawn"]) + else: + logging.error("cannot cross-compile for %s", cross_compile_hosts) + raise SystemExit(1) diff --git a/packages/swift/swift-arm-casts.patch b/packages/swift/swift-arm-casts.patch deleted file mode 100644 index 749d9cede991c0..00000000000000 --- a/packages/swift/swift-arm-casts.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/swift/include/swift/AST/Attr.h b/swift/include/swift/AST/Attr.h -index 0255b38af1b..3949e62e750 100644 ---- a/swift/include/swift/AST/Attr.h -+++ b/swift/include/swift/AST/Attr.h -@@ -2661,7 +2661,7 @@ public: - - ArrayRef getSuppressedFeatures() const { - return {getTrailingObjects(), -- Bits.AllowFeatureSuppressionAttr.NumFeatures}; -+ static_cast(Bits.AllowFeatureSuppressionAttr.NumFeatures)}; - } - - static bool classof(const DeclAttribute *DA) { diff --git a/packages/swift/swift-build-arm.patch b/packages/swift/swift-build-arm.patch new file mode 100644 index 00000000000000..40f07976aadb29 --- /dev/null +++ b/packages/swift/swift-build-arm.patch @@ -0,0 +1,167 @@ +From 434d3a1ee5e666eec1437615ad328497662aa363 +From: Allan Shortlidge +Date: Thu, 25 Sep 2025 22:34:25 -0700 +Subject: [PATCH] AST: Give `CustomAvailabilityDomain` 8 byte alignment. + +`AvailabilityDomain` is a pointer union over `CustomAvailabilityDomain` and an +opaque pointer-like 24-bit value, which means the number of spare bits in an +`AvailabilityDomain` representation is one fewer than a +`CustomAvailabilityDomain` pointer. Other structures in the compiler rely on +there being at least 2 spare bits in `AvailabilityDomain`, though, which was +not the case when building for a 32 bit architecture. To ensure there are +enough spare bits, always align `CustomAvailabilityDomain` to 8 bytes, the same +as many AST data structures. + +diff --git a/swift/include/swift/AST/AvailabilityDomain.h b/swift/include/swift/AST/AvailabilityDomain.h +index 7d5ecac7df03c..3c28bf0ba757e 100644 +--- a/swift/include/swift/AST/AvailabilityDomain.h ++++ b/swift/include/swift/AST/AvailabilityDomain.h +@@ -22,6 +22,7 @@ + #include "swift/AST/AvailabilityRange.h" + #include "swift/AST/Identifier.h" + #include "swift/AST/PlatformKind.h" ++#include "swift/AST/TypeAlignments.h" + #include "swift/Basic/Assertions.h" + #include "swift/Basic/LLVM.h" + #include "swift/Basic/SourceLoc.h" +@@ -334,7 +335,8 @@ struct StableAvailabilityDomainComparator { + }; + + /// Represents an availability domain that has been defined in a module. +-class CustomAvailabilityDomain : public llvm::FoldingSetNode { ++class alignas(1 << CustomAvailabilityDomainAlignInBits) CustomAvailabilityDomain ++ : public llvm::FoldingSetNode { + public: + enum class Kind { + /// A domain that is known to be enabled at compile time. +diff --git a/swift/include/swift/AST/TypeAlignments.h b/swift/include/swift/AST/TypeAlignments.h +index b4eb926d6a1e9..c9b5d49b8f78a 100644 +--- a/swift/include/swift/AST/TypeAlignments.h ++++ b/swift/include/swift/AST/TypeAlignments.h +@@ -34,6 +34,7 @@ namespace swift { + class AttributeBase; + class BraceStmt; + class CaptureListExpr; ++ class CustomAvailabilityDomain; + class Decl; + class DeclContext; + class DifferentiableAttr; +@@ -80,6 +81,7 @@ namespace swift { + constexpr size_t ASTContextAlignInBits = 2; + constexpr size_t TypeVariableAlignInBits = 4; + constexpr size_t StoredDefaultArgumentAlignInBits = 3; ++ constexpr size_t CustomAvailabilityDomainAlignInBits = 3; + + // Well, this is the *minimum* pointer alignment; it's going to be 3 on + // 64-bit targets, but that doesn't matter. +@@ -165,6 +167,9 @@ LLVM_DECLARE_TYPE_ALIGNMENT(swift::CaseLabelItem, swift::PatternAlignInBits) + LLVM_DECLARE_TYPE_ALIGNMENT(swift::StmtConditionElement, + swift::PatternAlignInBits) + ++LLVM_DECLARE_TYPE_ALIGNMENT(swift::CustomAvailabilityDomain, ++ swift::CustomAvailabilityDomainAlignInBits) ++ + static_assert(alignof(void*) >= 2, "pointer alignment is too small"); + + #endif +diff --git a/swift/include/swift/Basic/Feature.h b/swift/include/swift/Basic/Feature.h +index b05080bbf3a..ebec19d9e53 100644 +--- a/swift/include/swift/Basic/Feature.h ++++ b/swift/include/swift/Basic/Feature.h +@@ -35,7 +35,9 @@ struct Feature { + constexpr Feature(unsigned inputKind) : kind(InnerKind(inputKind)) {} + + constexpr operator InnerKind() const { return kind; } ++#if !defined(__arm__) + constexpr explicit operator unsigned() const { return unsigned(kind); } ++#endif + constexpr explicit operator size_t() const { return size_t(kind); } + + static constexpr unsigned getNumFeatures() { +diff --git a/swift-build/Sources/SWBUtil/FSProxy.swift b/swift-build/Sources/SWBUtil/FSProxy.swift +index b446d21..f88f3c3 100644 +--- a/swift-build/Sources/SWBUtil/FSProxy.swift ++++ b/swift-build/Sources/SWBUtil/FSProxy.swift +@@ -49,7 +49,7 @@ public struct FileInfo: Equatable, Sendable { + #if os(Windows) + return (statBuf.st_mode & UInt16(ucrt.S_IFREG)) != 0 + #else +- return (statBuf.st_mode & S_IFREG) != 0 ++ return (mode_t(statBuf.st_mode) & S_IFREG) != 0 + #endif + } + +@@ -57,7 +57,7 @@ public struct FileInfo: Equatable, Sendable { + #if os(Windows) + return (statBuf.st_mode & UInt16(ucrt.S_IFDIR)) != 0 + #else +- return (statBuf.st_mode & S_IFDIR) != 0 ++ return (mode_t(statBuf.st_mode) & S_IFDIR) != 0 + #endif + } + +@@ -65,7 +65,7 @@ public struct FileInfo: Equatable, Sendable { + #if os(Windows) + return (statBuf.st_mode & UInt16(S_IFLNK)) == S_IFLNK + #else +- return (statBuf.st_mode & S_IFMT) == S_IFLNK ++ return (mode_t(statBuf.st_mode) & S_IFMT) == S_IFLNK + #endif + } + +@@ -75,7 +75,7 @@ public struct FileInfo: Equatable, Sendable { + // Don't use FileManager.isExecutableFile due to https://github.com/swiftlang/swift-foundation/issues/860 + return (statBuf.st_mode & UInt16(_S_IEXEC)) != 0 + #else +- return (statBuf.st_mode & S_IXUSR) != 0 ++ return (mode_t(statBuf.st_mode) & S_IXUSR) != 0 + #endif + } + +@@ -1395,9 +1395,9 @@ public class PseudoFS: FSProxy, @unchecked Sendable { + #else + info.st_mtimespec = timespec(tv_sec: time_t(node.timestamp), tv_nsec: 0) + #endif +- info.st_size = off_t(contents.bytes.count) +- info.st_dev = node.device +- info.st_ino = node.inode ++ info.st_size = numericCast(contents.bytes.count) ++ info.st_dev = numericCast(node.device) ++ info.st_ino = numericCast(node.inode) + return createFileInfo(info) + case .directory(let dir): + var info = stat() +@@ -1405,12 +1405,12 @@ public class PseudoFS: FSProxy, @unchecked Sendable { + info.st_mode = UInt16(ucrt.S_IFDIR) + info.st_mtimespec = timespec(tv_sec: Int64(node.timestamp), tv_nsec: 0) + #else +- info.st_mode = S_IFDIR ++ info.st_mode = numericCast(S_IFDIR) + info.st_mtimespec = timespec(tv_sec: time_t(node.timestamp), tv_nsec: 0) + #endif +- info.st_size = off_t(dir.contents.count) +- info.st_dev = node.device +- info.st_ino = node.inode ++ info.st_size = numericCast(dir.contents.count) ++ info.st_dev = numericCast(node.device) ++ info.st_ino = numericCast(node.inode) + return createFileInfo(info) + case .symlink(_): + var info = stat() +@@ -1418,12 +1418,12 @@ public class PseudoFS: FSProxy, @unchecked Sendable { + info.st_mode = UInt16(S_IFLNK) + info.st_mtimespec = timespec(tv_sec: Int64(node.timestamp), tv_nsec: 0) + #else +- info.st_mode = S_IFLNK ++ info.st_mode = numericCast(S_IFLNK) + info.st_mtimespec = timespec(tv_sec: time_t(node.timestamp), tv_nsec: 0) + #endif +- info.st_size = off_t(0) +- info.st_dev = node.device +- info.st_ino = node.inode ++ info.st_size = numericCast(0) ++ info.st_dev = numericCast(node.device) ++ info.st_ino = numericCast(node.inode) + return createFileInfo(info) + } + } diff --git a/packages/swift/swift-cmake-flags-format.patch b/packages/swift/swift-cmake-flags-format.patch index 10f21198a77120..047e0157789810 100644 --- a/packages/swift/swift-cmake-flags-format.patch +++ b/packages/swift/swift-cmake-flags-format.patch @@ -12,6 +12,15 @@ index b11313fab87..fe2e8982300 100644 class CMark(cmake_product.CMakeProduct): +@@ -54,7 +54,7 @@ class CMark(cmake_product.CMakeProduct): + + self.cmake_options.define('CMARK_THREADING', 'ON') + +- host_toolchain = self.generate_toolchain_file_for_darwin_or_linux(host_target) ++ host_toolchain = False # self.generate_toolchain_file_for_darwin_or_linux(host_target) + + (platform, _) = host_target.split('-') + if not host_toolchain and platform == "openbsd": @@ -68,6 +70,13 @@ class CMark(cmake_product.CMakeProduct): toolchain_file = self.generate_linux_toolchain_file(platform, arch) self.cmake_options.define('CMAKE_TOOLCHAIN_FILE:PATH', toolchain_file) @@ -43,6 +52,26 @@ index 744dca10fca..7b5932882f2 100644 host_config = HostSpecificConfiguration(host_target, self.args) +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 6bd94c3cad8..743f6ed3637 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 +@@ -480,11 +480,12 @@ class Product(object): + # compile on Android does not use the NDK and its CMake config. + cross_compile = platform == "linux" or \ + self.is_cross_compile_target(host_target) +- toolchain_file = self.generate_linux_toolchain_file(platform, arch, ++ if platform == "android": ++ if not cross_compile: ++ toolchain_file = self.generate_linux_toolchain_file(platform, arch, + cross_compile) +- self.cmake_options.define('CMAKE_TOOLCHAIN_FILE:PATH', toolchain_file) ++ self.cmake_options.define('CMAKE_TOOLCHAIN_FILE:PATH', toolchain_file) + +- if cross_compile and platform == "android": + resource_dir = None + # build-script-impl products build before the install and use + # the Swift stdlib from the compiler build directory instead, diff --git a/swift/utils/swift_build_support/swift_build_support/products/swift_testing.py b/swift/utils/swift_build_support/swift_build_support/products/swift_testing.py index 324d1a77eea..bd5f9c79353 100644 --- a/swift/utils/swift_build_support/swift_build_support/products/swift_testing.py @@ -57,23 +86,16 @@ index 324d1a77eea..bd5f9c79353 100644 from . import cmake_product from . import product -@@ -115,6 +117,22 @@ class SwiftTestingCMakeShim(cmake_product.CMakeProduct): +@@ -115,6 +117,15 @@ class SwiftTestingCMakeShim(cmake_product.CMakeProduct): # FIXME: If we build macros for the builder, specify the path. self.cmake_options.define('SwiftTesting_MACRO', 'NO') + if host_target.startswith('android') and self.is_cross_compile_target(host_target): + host_config = HostSpecificConfiguration(host_target, self.args) + self.cmake_options.extend(host_config.cmake_options) -+ flags = '-target %s-unknown-linux-android%s ' % (self.args.android_arch, ++ target = '%s-unknown-linux-android%s' % (self.args.android_arch, + self.args.android_api_level) -+ -+ flags += '-resource-dir %s/lib/swift ' % ( -+ self.host_install_destdir(host_target) + self.args.install_prefix) -+ -+ ndk_path = StdlibDeploymentTarget.get_target_for_name(host_target).platform.ndk_toolchain_path(self.args) -+ flags += '-sdk %s/sysroot ' % (ndk_path) -+ flags += '-tools-directory %s/bin' % (ndk_path) -+ self.cmake_options.define('CMAKE_Swift_FLAGS', flags) ++ self.cmake_options.define('CMAKE_Swift_COMPILER_TARGET', target) + self.cmake_options.define('CMAKE_CXX_COMPILER_WORKS', 'True') + self.cmake_options.define('CMAKE_FIND_ROOT_PATH', self.args.cross_compile_deps_path) + diff --git a/packages/swift/swift-cmake.patch b/packages/swift/swift-cmake.patch index 0d0559e084a27b..7a3e11384c6460 100644 --- a/packages/swift/swift-cmake.patch +++ b/packages/swift/swift-cmake.patch @@ -1,17 +1,3 @@ -diff --git a/llbuild/tests/CMakeLists.txt b/llbuild/tests/CMakeLists.txt -index ba0866b4..0f95a6b3 100644 ---- a/llbuild/tests/CMakeLists.txt -+++ b/llbuild/tests/CMakeLists.txt -@@ -46,9 +46,6 @@ if(Python_Interpreter_FOUND AND LIT_FOUND AND FILECHECK_FOUND) - add_dependencies(test-llbuild ${test_target_dependencies}) - - # Add a target for running all tests. -- if(POLICY CMP0037) -- cmake_policy(SET CMP0037 OLD) -- endif(POLICY CMP0037) - add_custom_target(test) - add_dependencies(test test-llbuild) - set_target_properties(test PROPERTIES FOLDER "Tests") diff --git a/llvm-project/clang/runtime/CMakeLists.txt b/llvm-project/clang/runtime/CMakeLists.txt index 61b1c60bf590..5b0d10a67699 100644 --- a/llvm-project/clang/runtime/CMakeLists.txt @@ -72,23 +58,23 @@ index b7503ecdd6..c643c2c9a5 100644 endif() @@ -966,7 +966,7 @@ if("${SWIFT_NATIVE_SWIFT_TOOLS_PATH}" STREQUAL "") - message(WARNING "BOOTSTRAPPING set to OFF because no Swift compiler is defined") - set(BOOTSTRAPPING_MODE "OFF") - endif() --elseif(BOOTSTRAPPING_MODE MATCHES "BOOTSTRAPPING.*") -+elseif(BOOTSTRAPPING_MODE MATCHES "HOSTTOOLS") - # If cross-compiling, we don't have to bootstrap. We can just use the previously - # built native swiftc to build the swift compiler modules. - message(STATUS "Building swift modules with previously built tools instead of bootstrapping") + message(WARNING "BOOTSTRAPPING set to OFF because no Swift compiler is defined") + set(BOOTSTRAPPING_MODE "OFF") + endif() +- elseif(BOOTSTRAPPING_MODE MATCHES "BOOTSTRAPPING.*") ++ elseif(BOOTSTRAPPING_MODE MATCHES "HOSTTOOLS") + # If cross-compiling, we don't have to bootstrap. We can just use the previously + # built native swiftc to build the swift compiler modules. + message(STATUS "Building swift modules with previously built tools instead of bootstrapping") @@ -976,7 +976,7 @@ elseif(BOOTSTRAPPING_MODE MATCHES "BOOTSTRAPPING.*") - elseif(BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING") - set(BOOTSTRAPPING_MODE "CROSSCOMPILE") - else() -- set(BOOTSTRAPPING_MODE "HOSTTOOLS") -+ set(BOOTSTRAPPING_MODE "CROSSCOMPILE") - endif() - elseif(BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS" OR SWIFT_BUILD_SWIFT_SYNTAX) - # We are building using a pre-installed host toolchain but not bootstrapping + elseif(BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING") + set(BOOTSTRAPPING_MODE "CROSSCOMPILE") + else() +- set(BOOTSTRAPPING_MODE "HOSTTOOLS") ++ set(BOOTSTRAPPING_MODE "CROSSCOMPILE") + endif() + elseif(BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS" OR SWIFT_BUILD_SWIFT_SYNTAX) + # We are building using a pre-installed host toolchain but not bootstrapping @@ -1279,7 +1280,8 @@ if (LLVM_ENABLE_DOXYGEN) message(STATUS "Doxygen: enabled") endif() @@ -99,6 +85,19 @@ index b7503ecdd6..c643c2c9a5 100644 include(Libdispatch) endif() +diff --git a/swift/cmake/modules/AddSwift.cmake b/swift/cmake/modules/AddSwift.cmake +index ed28ab1891d..b7aa589f909 100644 +--- a/swift/cmake/modules/AddSwift.cmake ++++ b/swift/cmake/modules/AddSwift.cmake +@@ -374,6 +374,8 @@ function(_add_host_variant_link_flags target) + # We need to add the math library, which is linked implicitly by libc++ + m) + ++ target_link_options(${target} PRIVATE "SHELL:-Xlinker -z -Xlinker max-page-size=16384") ++ + # link against the custom C++ library + swift_android_cxx_libraries_for_arch(${SWIFT_HOST_VARIANT_ARCH} + cxx_link_libraries) diff --git a/swift/cmake/modules/SwiftCompilerCapability.cmake b/swift/cmake/modules/SwiftCompilerCapability.cmake index d7d4381a1a7..d8c05dc6a75 100644 --- a/swift/cmake/modules/SwiftCompilerCapability.cmake @@ -128,6 +127,14 @@ index 849cf90fee0..f2a08df0e57 100644 diff --git a/swift/SwiftCompilerSources/CMakeLists.txt b/swift/SwiftCompilerSources/CMakeLists.txt --- a/swift/SwiftCompilerSources/CMakeLists.txt +++ b/swift/SwiftCompilerSources/CMakeLists.txt +@@ -162,6 +162,7 @@ function(add_swift_compiler_modules_library name) + list(APPEND sdk_option "-resource-dir" "${swift_exec_bin_dir}/../bootstrapping0/lib/swift") + endif() + elseif(BOOTSTRAPPING_MODE STREQUAL "CROSSCOMPILE") ++ set(deployment_version ${SWIFT_ANDROID_API_LEVEL}) + # NOTE: prepending allows SWIFT_COMPILER_SOURCES_SDK_FLAGS to override the + # resource directory if needed. + list(PREPEND sdk_option "-resource-dir" "${SWIFTLIB_DIR}") @@ -196,6 +196,8 @@ # Workaround for https://github.com/swiftlang/llvm-project/issues/7172 @@ -165,17 +172,21 @@ index 07a3585a66c..461a98b6856 100644 PATTERN "*.strings" ) +endif() +diff --git a/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake b/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake +index 5021409ba06..bb5bc1a6fd4 100644 --- a/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake +++ b/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake -@@ -557,7 +557,7 @@ - if(NOT CMAKE_HOST_SYSTEM MATCHES Windows) - # The Android resource dir is specified from build.ps1 on windows. - if(NOT "${SWIFT_ANDROID_NDK_PATH}" STREQUAL "") -- if("${SWIFT_ANDROID_NDK_PATH}" MATCHES "r26|r27") -+ if("${SWIFT_ANDROID_NDK_PATH}" MATCHES "r26|r27|r28") - file(GLOB RESOURCE_DIR ${SWIFT_SDK_ANDROID_ARCH_${LFLAGS_ARCH}_PATH}/../lib/clang/*) - else() - file(GLOB RESOURCE_DIR ${SWIFT_SDK_ANDROID_ARCH_${LFLAGS_ARCH}_PATH}/../lib64/clang/*) +@@ -2508,6 +2508,10 @@ function(add_swift_target_library name) + list(APPEND swiftlib_link_flags_all "-Wl,-z,max-page-size=16384") + endif() + ++ if(sdk STREQUAL "ANDROID" AND name STREQUAL "swiftCxxStdlib") ++ list(APPEND swiftlib_swift_compile_flags_all "-target" "${SWIFT_SDK_ANDROID_ARCH_${arch}_TRIPLE}${SWIFT_ANDROID_API_LEVEL}") ++ endif() ++ + if (SWIFTLIB_BACK_DEPLOYMENT_LIBRARY) + set(back_deployment_library_option BACK_DEPLOYMENT_LIBRARY ${SWIFTLIB_BACK_DEPLOYMENT_LIBRARY}) + else() 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 @@ -249,9 +260,9 @@ index 11cda641cc2..bd2cb152725 100644 swift-compatibility-symbols.cpp LLVM_LINK_COMPONENTS support @@ -26,3 +27,4 @@ swift_install_in_component( - COMPONENT compiler ) + endif() +endif() diff --git a/swift-corelibs-xctest/CMakeLists.txt b/swift-corelibs-xctest/CMakeLists.txt index 531e7c0..589930f 100644 @@ -265,21 +276,6 @@ index 531e7c0..589930f 100644 endif() endif() set_target_properties(XCTest PROPERTIES -diff --git a/swift-foundation/cmake/modules/SwiftFoundationSwiftSupport.cmake b/swift-foundation/cmake/modules/SwiftFoundationSwiftSupport.cmake -index cbdfc2a..bb4121d 100644 ---- a/swift-foundation/cmake/modules/SwiftFoundationSwiftSupport.cmake -+++ b/swift-foundation/cmake/modules/SwiftFoundationSwiftSupport.cmake -@@ -37,6 +37,10 @@ function(_swift_foundation_install_target module) - set(module_triple_command "${CMAKE_Swift_COMPILER}" -print-target-info) - if(CMAKE_Swift_COMPILER_TARGET) - list(APPEND module_triple_command -target ${CMAKE_Swift_COMPILER_TARGET}) -+ else() -+ set(arg_list ${CMAKE_Swift_FLAGS}) -+ separate_arguments(arg_list) -+ list(APPEND module_triple_command ${arg_list}) - endif() - execute_process(COMMAND ${module_triple_command} OUTPUT_VARIABLE target_info_json) - string(JSON module_triple GET "${target_info_json}" "target" "moduleTriple") diff --git a/swift-testing/CMakeLists.txt b/swift-testing/CMakeLists.txt index 1be9a4b..bd7b1bd 100644 --- a/swift-testing/CMakeLists.txt @@ -292,6 +288,15 @@ index 1be9a4b..bd7b1bd 100644 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) +@@ -39,7 +39,7 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) + +-set(CMAKE_INSTALL_RPATH "$,@loader_path/..,$ORIGIN>") ++set(CMAKE_INSTALL_RPATH "$,@loader_path/..,@TERMUX_PREFIX@/lib:$ORIGIN>") + set(CMAKE_INSTALL_REMOVE_ENVIRONMENT_RPATH YES) + + set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL) diff --git a/swift-testing/Sources/Testing/CMakeLists.txt b/swift-testing/Sources/Testing/CMakeLists.txt index e40cb1b..ff2f920 100644 --- a/swift-testing/Sources/Testing/CMakeLists.txt @@ -306,42 +311,3 @@ index e40cb1b..ff2f920 100644 endif() target_link_libraries(Testing PUBLIC Foundation) -diff --git a/swift-testing/cmake/modules/SwiftModuleInstallation.cmake b/swift-testing/cmake/modules/SwiftModuleInstallation.cmake -index 1553725..d9f9e5b 100644 ---- a/swift-testing/cmake/modules/SwiftModuleInstallation.cmake -+++ b/swift-testing/cmake/modules/SwiftModuleInstallation.cmake -@@ -51,7 +51,7 @@ function(_swift_testing_install_target module) - INSTALL_REMOVE_ENVIRONMENT_RPATH ON) - else() - set_target_properties(${module} PROPERTIES -- INSTALL_RPATH "$ORIGIN" -+ INSTALL_RPATH "@TERMUX_PREFIX@/lib:$ORIGIN" - INSTALL_REMOVE_ENVIRONMENT_RPATH ON) - endif() - -@@ -75,6 +75,10 @@ function(_swift_testing_install_target module) - set(module_triple_command "${CMAKE_Swift_COMPILER}" -print-target-info) - if(CMAKE_Swift_COMPILER_TARGET) - list(APPEND module_triple_command -target ${CMAKE_Swift_COMPILER_TARGET}) -+ else() -+ set(arg_list ${CMAKE_Swift_FLAGS}) -+ separate_arguments(arg_list) -+ list(APPEND module_triple_command ${arg_list}) - endif() - execute_process(COMMAND ${module_triple_command} OUTPUT_VARIABLE target_info_json) - string(JSON module_triple GET "${target_info_json}" "target" "moduleTriple") -diff --git a/swift-testing/cmake/modules/TargetTriple.cmake b/swift-testing/cmake/modules/TargetTriple.cmake -index e087cc4..02f3a95 100644 ---- a/swift-testing/cmake/modules/TargetTriple.cmake -+++ b/swift-testing/cmake/modules/TargetTriple.cmake -@@ -10,6 +10,10 @@ - set(SWT_TARGET_INFO_COMMAND "${CMAKE_Swift_COMPILER}" -print-target-info) - if(CMAKE_Swift_COMPILER_TARGET) - list(APPEND SWT_TARGET_INFO_COMMAND -target ${CMAKE_Swift_COMPILER_TARGET}) -+else() -+ set(arg_list ${CMAKE_Swift_FLAGS}) -+ separate_arguments(arg_list) -+ list(APPEND SWT_TARGET_INFO_COMMAND ${arg_list}) - endif() - execute_process(COMMAND ${SWT_TARGET_INFO_COMMAND} OUTPUT_VARIABLE SWT_TARGET_INFO_JSON) - string(JSON SWT_TARGET_TRIPLE GET "${SWT_TARGET_INFO_JSON}" "target" "unversionedTriple") diff --git a/packages/swift/swift-crosscompile-swift-syntax.patch b/packages/swift/swift-crosscompile-swift-syntax.patch index f986e99856fc09..b896dd4861fffc 100644 --- a/packages/swift/swift-crosscompile-swift-syntax.patch +++ b/packages/swift/swift-crosscompile-swift-syntax.patch @@ -1,29 +1,3 @@ -diff --git a/swift-syntax/Sources/SwiftLibraryPluginProvider/LibraryPluginProvider.swift b/swift-syntax/Sources/SwiftLibraryPluginProvider/LibraryPluginProvider.swift -index 44be07e2..4450c8e3 100644 ---- a/swift-syntax/Sources/SwiftLibraryPluginProvider/LibraryPluginProvider.swift -+++ b/swift-syntax/Sources/SwiftLibraryPluginProvider/LibraryPluginProvider.swift -@@ -10,7 +10,7 @@ - // - //===----------------------------------------------------------------------===// - --#if swift(>=6.0) -+#if compiler(>=6.0) - public import SwiftSyntaxMacros - @_spi(PluginMessage) public import SwiftCompilerPluginMessageHandling - private import _SwiftLibraryPluginProviderCShims -diff --git a/swift-syntax/Sources/SwiftSyntax/SyntaxText.swift b/swift-syntax/Sources/SwiftSyntax/SyntaxText.swift -index 4d877962..9e12e3a9 100644 ---- a/swift-syntax/Sources/SwiftSyntax/SyntaxText.swift -+++ b/swift-syntax/Sources/SwiftSyntax/SyntaxText.swift -@@ -10,7 +10,7 @@ - // - //===----------------------------------------------------------------------===// - --#if swift(>=6.0) -+#if compiler(>=6.0) - #if canImport(Darwin) - private import Darwin - #elseif canImport(Glibc) diff --git a/swift-syntax/cmake/modules/AddSwiftHostLibrary.cmake b/swift-syntax/cmake/modules/AddSwiftHostLibrary.cmake index 2a16fa5e..b7fedd87 100644 --- a/swift-syntax/cmake/modules/AddSwiftHostLibrary.cmake diff --git a/packages/swift/swift-foundation-ndk27.patch b/packages/swift/swift-foundation-ndk27.patch index d2bc5117299894..74e4c0dc81bb10 100644 --- a/packages/swift/swift-foundation-ndk27.patch +++ b/packages/swift/swift-foundation-ndk27.patch @@ -14,17 +14,6 @@ diff --git a/swift-corelibs-foundation/Sources/Foundation/Process.swift b/swift- index 758dd1df..02970992 100644 --- a/swift-corelibs-foundation/Sources/Foundation/Process.swift +++ b/swift-corelibs-foundation/Sources/Foundation/Process.swift -@@ -929,8 +929,8 @@ open class Process: NSObject, @unchecked Sendable { - } - let useFallbackChdir: Bool - if let dir = currentDirectoryURL?.path { -- let chdirResult = _CFPosixSpawnFileActionsChdir(fileActions, dir) -- useFallbackChdir = chdirResult == ENOSYS -+ let chdirResult = ENOSYS -+ useFallbackChdir = true - if !useFallbackChdir { - try _throwIfPosixError(chdirResult) - } @@ -944,7 +944,7 @@ open class Process: NSObject, @unchecked Sendable { var spawnAttrs: posix_spawnattr_t = posix_spawnattr_t() #endif diff --git a/packages/swift/swift-import-android.patch b/packages/swift/swift-import-android.patch index 1a5264a340c820..d3bda8e1875a5b 100644 --- a/packages/swift/swift-import-android.patch +++ b/packages/swift/swift-import-android.patch @@ -56,84 +56,46 @@ index 5f47c2f..4b5579e 100644 /// A standards-based implementation of an HMAC-based Key Derivation Function /// (HKDF). -diff --git a/swift-system/Sources/System/Internals/CInterop.swift b/swift-system/Sources/System/Internals/CInterop.swift -index 13abc75..2ad551a 100644 ---- a/swift-system/Sources/System/Internals/CInterop.swift -+++ b/swift-system/Sources/System/Internals/CInterop.swift -@@ -25,6 +25,9 @@ import Glibc - #elseif canImport(Musl) - @_implementationOnly import CSystem - import Musl -+#elseif canImport(Bionic) -+@_implementationOnly import CSystem -+import Bionic - #else - #error("Unsupported Platform") - #endif -diff --git a/swift-system/Sources/System/Internals/Constants.swift b/swift-system/Sources/System/Internals/Constants.swift -index 53e215f..27039de 100644 ---- a/swift-system/Sources/System/Internals/Constants.swift -+++ b/swift-system/Sources/System/Internals/Constants.swift -@@ -18,6 +18,8 @@ import CSystem - import ucrt - #elseif canImport(Glibc) +diff --git a/swift-docc/Sources/SwiftDocC/Infrastructure/Diagnostics/TerminalHelper.swift b/swift-docc/Sources/SwiftDocC/Infrastructure/Diagnostics/TerminalHelper.swift +index dc3e33f5..a354d3ba 100644 +--- a/swift-docc/Sources/SwiftDocC/Infrastructure/Diagnostics/TerminalHelper.swift ++++ b/swift-docc/Sources/SwiftDocC/Infrastructure/Diagnostics/TerminalHelper.swift +@@ -14,6 +14,8 @@ import Darwin.C import Glibc -+#elseif canImport(Android) -+import Android - #elseif canImport(Musl) - import CSystem - import Musl -diff --git a/swift-system/Sources/System/Internals/Exports.swift b/swift-system/Sources/System/Internals/Exports.swift -index 5b08725..899be25 100644 ---- a/swift-system/Sources/System/Internals/Exports.swift -+++ b/swift-system/Sources/System/Internals/Exports.swift -@@ -23,6 +23,9 @@ import Glibc #elseif canImport(Musl) - @_implementationOnly import CSystem import Musl +#elseif canImport(Android) -+@_implementationOnly import CSystem +import Android - #else - #error("Unsupported Platform") - #endif -@@ -58,6 +61,11 @@ internal var system_errno: CInt { - get { Musl.errno } - set { Musl.errno = newValue } - } -+#elseif canImport(Android) -+internal var system_errno: CInt { -+ get { Android.errno } -+ set { Android.errno = newValue } -+} + #elseif os(Windows) + import CRT #endif +diff --git a/swift-docc/Sources/SwiftDocC/Utility/LMDB/LMDB.swift b/swift-docc/Sources/SwiftDocC/Utility/LMDB/LMDB.swift +index 66795d87..05d40a31 100644 +--- a/swift-docc/Sources/SwiftDocC/Utility/LMDB/LMDB.swift ++++ b/swift-docc/Sources/SwiftDocC/Utility/LMDB/LMDB.swift +@@ -11,6 +11,10 @@ + public import Foundation + import CLMDB - // MARK: C stdlib decls -diff --git a/swift-system/Sources/System/Internals/Syscalls.swift b/swift-system/Sources/System/Internals/Syscalls.swift -index 555f63b..f0db35f 100644 ---- a/swift-system/Sources/System/Internals/Syscalls.swift -+++ b/swift-system/Sources/System/Internals/Syscalls.swift -@@ -15,6 +15,8 @@ import Glibc - import Musl - #elseif os(Windows) - import ucrt -+#elseif canImport(Android) ++#if canImport(Android) +import Android - #else - #error("Unsupported Platform") - #endif -diff --git a/yams/Sources/Yams/Representer.swift b/yams/Sources/Yams/Representer.swift -index a749c52..b74ef8e 100644 ---- a/yams/Sources/Yams/Representer.swift -+++ b/yams/Sources/Yams/Representer.swift -@@ -14,6 +14,10 @@ private let cpow: (_: Double, _: Double) -> Double = Darwin.pow - #elseif os(Windows) - import ucrt - private let cpow: (_: Double, _: Double) -> Double = ucrt.pow -+#elseif canImport(Bionic) -+import CoreFoundation -+import Bionic -+private let cpow: (_: Double, _: Double) -> Double = Bionic.pow - #else - import CoreFoundation - import Glibc ++#endif ++ + /** + A general utility class for LMDB. + +diff --git a/swiftpm/Sources/swift-build-prebuilts/BuildPrebuilts.swift b/swiftpm/Sources/swift-build-prebuilts/BuildPrebuilts.swift +index ffa6b7f3f..abe453232 100644 +--- a/swiftpm/Sources/swift-build-prebuilts/BuildPrebuilts.swift ++++ b/swiftpm/Sources/swift-build-prebuilts/BuildPrebuilts.swift +@@ -24,6 +24,10 @@ import struct TSCBasic.ByteString + import struct TSCBasic.SHA256 + import Workspace + ++#if canImport(Android) ++import Android ++#endif ++ + // Format for the .zip.json files. + struct Artifact: Codable { + var platform: Workspace.PrebuiltsManifest.Platform diff --git a/packages/swift/swift-remove-relative-rpaths.patch b/packages/swift/swift-remove-relative-rpaths.patch index 73047aba33468d..14b008f04d5e46 100644 --- a/packages/swift/swift-remove-relative-rpaths.patch +++ b/packages/swift/swift-remove-relative-rpaths.patch @@ -8,9 +8,9 @@ index bd31bec..737c8c3 100755 '-Xlinker', '-landroid-spawn', - '-Xlinker', '-rpath', '-Xlinker', '$ORIGIN/../lib/swift/android', + #'-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 not build_os.startswith('macosx'): + # Library rpath for swift, dispatch, Foundation, etc. when installing diff --git a/swift/cmake/modules/AddPureSwift.cmake b/swift/cmake/modules/AddPureSwift.cmake index ee668f96903..61397d3910e 100644 --- a/swift/cmake/modules/AddPureSwift.cmake @@ -54,16 +54,14 @@ diff --git a/swift-corelibs-foundation/Sources/plutil/CMakeLists.txt b/swift-cor index b1c84350..35413f0b 100644 --- a/swift-corelibs-foundation/Sources/plutil/CMakeLists.txt +++ b/swift-corelibs-foundation/Sources/plutil/CMakeLists.txt -@@ -27,9 +27,9 @@ if(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin|Windows") +@@ -27,8 +27,8 @@ if(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin|Windows") target_link_libraries(plutil PRIVATE Foundation) -set_target_properties(plutil PROPERTIES -- INSTALL_RPATH "$ORIGIN/../lib/swift/${SWIFT_SYSTEM_NAME}" -- INSTALL_REMOVE_ENVIRONMENT_RPATH ON) +- INSTALL_RPATH "$ORIGIN/../lib/swift/${SWIFT_SYSTEM_NAME}") +# set_target_properties(plutil PROPERTIES -+# INSTALL_RPATH "$ORIGIN/../lib/swift/${SWIFT_SYSTEM_NAME}" -+# INSTALL_REMOVE_ENVIRONMENT_RPATH ON) ++# INSTALL_RPATH "$ORIGIN/../lib/swift/${SWIFT_SYSTEM_NAME}") set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS plutil) install(TARGETS plutil @@ -77,9 +75,9 @@ index ce6523d5..e8d63bdd 100755 '-Xlinker', '-landroid-spawn', - '-Xlinker', '-rpath', '-Xlinker', '$ORIGIN/../lib/swift/android', + #'-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 diff --git a/swiftpm/Utilities/bootstrap b/swiftpm/Utilities/bootstrap index 92c368a86..e9d43b599 100755 --- a/swiftpm/Utilities/bootstrap diff --git a/packages/swift/swift-sdk-aarch64.subpackage.sh b/packages/swift/swift-sdk-aarch64.subpackage.sh index 92b9efc966c5e6..1e69847b03f943 100644 --- a/packages/swift/swift-sdk-aarch64.subpackage.sh +++ b/packages/swift/swift-sdk-aarch64.subpackage.sh @@ -3,6 +3,7 @@ TERMUX_SUBPKG_INCLUDE=" lib/swift/android/aarch64/*.swiftdoc lib/swift/android/aarch64/*.swiftmodule lib/swift/android/aarch64/android.modulemap +lib/swift/android/aarch64/lib_TestDiscovery.a lib/swift/android/aarch64/libswiftCxx.a lib/swift/android/aarch64/libswiftCxxStdlib.a lib/swift/android/aarch64/SwiftAndroidNDK.h diff --git a/packages/swift/swift-sdk-arm.subpackage.sh b/packages/swift/swift-sdk-arm.subpackage.sh index 2da6ba016ac105..29ac572a48503a 100644 --- a/packages/swift/swift-sdk-arm.subpackage.sh +++ b/packages/swift/swift-sdk-arm.subpackage.sh @@ -3,6 +3,7 @@ TERMUX_SUBPKG_INCLUDE=" lib/swift/android/armv7/*.swiftdoc lib/swift/android/armv7/*.swiftmodule lib/swift/android/armv7/android.modulemap +lib/swift/android/armv7/lib_TestDiscovery.a lib/swift/android/armv7/libswiftCxx.a lib/swift/android/armv7/libswiftCxxStdlib.a lib/swift/android/armv7/SwiftAndroidNDK.h diff --git a/packages/swift/swift-sdk-x86-64.subpackage.sh b/packages/swift/swift-sdk-x86-64.subpackage.sh index 84b74507377339..84ff31c045780b 100644 --- a/packages/swift/swift-sdk-x86-64.subpackage.sh +++ b/packages/swift/swift-sdk-x86-64.subpackage.sh @@ -3,6 +3,7 @@ TERMUX_SUBPKG_INCLUDE=" lib/swift/android/x86_64/*.swiftdoc lib/swift/android/x86_64/*.swiftmodule lib/swift/android/x86_64/android.modulemap +lib/swift/android/x86_64/lib_TestDiscovery.a lib/swift/android/x86_64/libswiftCxx.a lib/swift/android/x86_64/libswiftCxxStdlib.a lib/swift/android/x86_64/SwiftAndroidNDK.h diff --git a/packages/swift/swift-testing.patch b/packages/swift/swift-testing.patch index 4397f54352379a..4df51db935fecc 100644 --- a/packages/swift/swift-testing.patch +++ b/packages/swift/swift-testing.patch @@ -1,16 +1,3 @@ -diff --git a/swift/utils/swift_build_support/swift_build_support/products/swift_testing.py b/swift/utils/swift_build_support/swift_build_support/products/swift_testing.py -index b6bfa5760ef..324d1a77eea 100644 ---- a/swift/utils/swift_build_support/swift_build_support/products/swift_testing.py -+++ b/swift/utils/swift_build_support/swift_build_support/products/swift_testing.py -@@ -51,7 +51,7 @@ class SwiftTesting(product.Product): - return False - - def should_install(self, host_target): -- return self.args.install_swift_testing_macros -+ return self.args.install_swift_testing - - def _cmake_product(self, host_target): - build_root = os.path.dirname(self.build_dir) diff --git a/swift-testing/Sources/Testing/SourceAttribution/Backtrace.swift b/swift-testing/Sources/Testing/SourceAttribution/Backtrace.swift index 78227e3..e0db2e9 100644 --- a/swift-testing/Sources/Testing/SourceAttribution/Backtrace.swift @@ -24,8 +11,8 @@ index 78227e3..e0db2e9 100644 initializedCount = addresses.withMemoryRebound(to: UnsafeMutableRawPointer.self) { addresses in .init(clamping: backtrace(addresses.baseAddress!, .init(clamping: addresses.count))) } --#elseif os(Linux) || os(FreeBSD) -+#elseif os(Linux) || os(FreeBSD) || os(Android) +-#elseif os(Linux) || os(FreeBSD) || os(OpenBSD) ++#elseif os(Linux) || os(FreeBSD) || os(OpenBSD) || os(Android) initializedCount = .init(clamping: backtrace(addresses.baseAddress!, .init(clamping: addresses.count))) #elseif os(Windows) initializedCount = Int(clamping: RtlCaptureStackBackTrace(0, ULONG(clamping: addresses.count), addresses.baseAddress!, nil)) diff --git a/packages/swift/swift-utils-build-script-impl-flags.patch b/packages/swift/swift-utils-build-script-impl-flags.patch index 2582c1ee68b561..67d8913955bb41 100644 --- a/packages/swift/swift-utils-build-script-impl-flags.patch +++ b/packages/swift/swift-utils-build-script-impl-flags.patch @@ -20,9 +20,9 @@ index b1d060328bc..218c9215260 100755 if [[ ! "${SKIP_BUILD_WASM}" ]]; then @@ -1785,6 +1788,9 @@ - "${cmake_options[@]}" -DLLVM_TABLEGEN=$(build_directory "${LOCAL_HOST}" llvm)/bin/llvm-tblgen -DSWIFT_INCLUDE_TEST_BINARIES:BOOL=FALSE + -DSWIFT_INCLUDE_TOOLS:BOOL=$(true_false "${CROSS_COMPILE_BUILD_SWIFT_TOOLS}") + -DCMAKE_FIND_ROOT_PATH:PATH="${CROSS_COMPILE_DEPS_PATH}" + -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER + -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY @@ -81,12 +81,13 @@ index b1d060328bc..218c9215260 100755 fi ;; esac -@@ -2537,6 +2554,9 @@ +@@ -2537,6 +2554,10 @@ # https://cmake.org/cmake/help/latest/command/find_package.html cmake_options+=( -DCMAKE_FIND_ROOT_PATH:PATH="${CROSS_COMPILE_DEPS_PATH}" + -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER + -DCMAKE_C_FLAGS="$CFLAGS --target=$CCTERMUX_HOST_PLATFORM $CPPFLAGS" ++ -DCMAKE_CXX_FLAGS="$CXXFLAGS --target=$CCTERMUX_HOST_PLATFORM $CPPFLAGS" + -DCMAKE_EXE_LINKER_FLAGS="$LDFLAGS --target=$CCTERMUX_HOST_PLATFORM" ) fi diff --git a/packages/swift/swift-utils-swift_build_support-swift_build_support-targets.py.patch b/packages/swift/swift-utils-swift_build_support-swift_build_support-targets.py.patch index f0c241859b5710..04279eb4d2bb38 100644 --- a/packages/swift/swift-utils-swift_build_support-swift_build_support-targets.py.patch +++ b/packages/swift/swift-utils-swift_build_support-swift_build_support-targets.py.patch @@ -5,11 +5,11 @@ index 7ebcdc070c1..5a6ed88182e 100644 @@ -158,6 +158,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' + flags += '-tools-directory %s/bin ' % (android_toolchain_path) ++ flags += '-Xlinker -rpath -Xlinker @TERMUX_PREFIX@/lib ' + flags += '-Xclang-linker -Wl,-z,max-page-size=16384' return flags - def cmake_options(self, args): @@ -167,12 +168,11 @@ class AndroidPlatform(Platform): options.define('CMAKE_SYSTEM_PROCESSOR', args.android_arch if not args.android_arch == 'armv7' diff --git a/packages/swift/trigger-command b/packages/swift/trigger-command index 0412d4a5793f45..9714c537a8f09a 100644 --- a/packages/swift/trigger-command +++ b/packages/swift/trigger-command @@ -4,11 +4,11 @@ if [ x"$native_triple" != x"$swift_runtime_triple" ]; then fi install_path=$install_path/lib -for so in _FoundationICU Foundation FoundationEssentials FoundationInternationalization \ +for so in _FoundationICU _Testing_Foundation Foundation FoundationEssentials FoundationInternationalization \ FoundationNetworking FoundationXML Testing XCTest swiftCore swiftDispatch \ swiftDistributed swiftAndroid swiftObservation swiftRegexBuilder swiftRemoteMirror \ swiftSwiftOnoneSupport swiftSynchronization swift_Builtin_float swift_Concurrency \ - swift_Differentiation swift_math swift_RegexParser swift_StringProcessing + swift_Differentiation swift_math swift_RegexParser swift_StringProcessing swift_Volatile do @COMMAND@ done diff --git a/scripts/build/setup/termux_setup_swift.sh b/scripts/build/setup/termux_setup_swift.sh index 6eb6864485fe5f..1523eeaf6360bd 100644 --- a/scripts/build/setup/termux_setup_swift.sh +++ b/scripts/build/setup/termux_setup_swift.sh @@ -19,7 +19,7 @@ termux_setup_swift() { termux_download \ https://download.swift.org/swift-$TERMUX_SWIFT_VERSION-release/ubuntu2404/swift-$TERMUX_SWIFT_VERSION-$SWIFT_RELEASE/$SWIFT_BIN.tar.gz \ $SWIFT_TAR \ - f19a228960e1d8174db796dcea3defe6963b588af45fa3ddf0412adbe4b7bb84 + 4022cb64faf7e2681c19f9b62a22fb7d9055db6194d9e4a4bef9107b6ce10946 (cd $TERMUX_PKG_TMPDIR ; tar xf $SWIFT_TAR ; mv $SWIFT_BIN $SWIFT_FOLDER; rm $SWIFT_TAR) fi