Skip to content

Commit

Permalink
swift: update from 5.7.3 to 5.8 Feb 23 snapshot and move runtime libr…
Browse files Browse the repository at this point in the history
…aries to arch-specific directory
  • Loading branch information
finagolfin committed Feb 28, 2023
1 parent 1e61775 commit a1befe6
Show file tree
Hide file tree
Showing 20 changed files with 1,220 additions and 581 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-22.04
strategy:
matrix:
target_arch: [aarch64, arm, x86_64]
target_arch: [aarch64]#, arm, x86_64]
fail-fast: false
steps:
- name: Clone repository
Expand Down
6 changes: 3 additions & 3 deletions packages/libdispatch/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ TERMUX_PKG_HOMEPAGE=https://github.com/apple/swift-corelibs-libdispatch
TERMUX_PKG_DESCRIPTION="The libdispatch project, for concurrency on multicore hardware"
TERMUX_PKG_LICENSE="Apache-2.0"
TERMUX_PKG_MAINTAINER="@buttaface"
TERMUX_PKG_VERSION="1:5.7.3"
TERMUX_PKG_SRCURL=https://github.com/apple/swift-corelibs-libdispatch/archive/swift-${TERMUX_PKG_VERSION:2}-RELEASE.tar.gz
TERMUX_PKG_SHA256=4c6b7b0ecdf10e9cbe1cd007b9a09689ea412edb8e3a289ade6d105df43209f5
TERMUX_PKG_VERSION="1:5.8"
TERMUX_PKG_SRCURL=https://github.com/apple/swift-corelibs-libdispatch/archive/swift-${TERMUX_PKG_VERSION:2}-DEVELOPMENT-SNAPSHOT-2023-02-23-a.tar.gz
TERMUX_PKG_SHA256=c448a64e96895a349606a69f858129c3246fbf58f0215206a071d171145d0100
TERMUX_PKG_DEPENDS="libc++, libblocksruntime"
6 changes: 3 additions & 3 deletions packages/llbuild/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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_LICENSE="Apache-2.0, NCSA"
TERMUX_PKG_MAINTAINER="@buttaface"
TERMUX_PKG_VERSION=5.7
TERMUX_PKG_SRCURL=https://github.com/apple/swift-llbuild/archive/swift-${TERMUX_PKG_VERSION}-RELEASE.tar.gz
TERMUX_PKG_SHA256=048bfb7f8b3baece8fc3b4f30ed7a96619a7817c5dbe02976c087eafb610bcd3
TERMUX_PKG_VERSION=5.8
TERMUX_PKG_SRCURL=https://github.com/apple/swift-llbuild/archive/swift-${TERMUX_PKG_VERSION}-DEVELOPMENT-SNAPSHOT-2023-02-23-a.tar.gz
TERMUX_PKG_SHA256=714fbc611021d21f70f0c9a7670ae09504961a853567c142dc06b2b8a86016f8
TERMUX_PKG_DEPENDS="libc++, libandroid-spawn, libsqlite"
57 changes: 30 additions & 27 deletions packages/swift/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.7.3
SWIFT_RELEASE="RELEASE"
TERMUX_PKG_VERSION=5.8
SWIFT_RELEASE="DEVELOPMENT-SNAPSHOT-2023-02-23-a"
TERMUX_PKG_SRCURL=https://github.com/apple/swift/archive/swift-$TERMUX_PKG_VERSION-$SWIFT_RELEASE.tar.gz
TERMUX_PKG_SHA256=8cda906403c12c5bf6ba4afea14fd494b6f08354e3e43be521f52e5cc5709eb8
TERMUX_PKG_SHA256=0366041d69a46c1a79709c51ae363dd153fe8e1bd23a94a363da423491eda1bb
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"
Expand All @@ -18,7 +18,7 @@ TERMUX_PKG_NO_STATICSPLIT=true
TERMUX_PKG_FORCE_CMAKE=true
TERMUX_CMAKE_BUILD=Ninja

SWIFT_COMPONENTS="autolink-driver;compiler;clang-resource-dir-symlink;swift-remote-mirror;parser-lib;license;sourcekit-inproc;stdlib;sdk-overlay"
SWIFT_COMPONENTS="autolink-driver;compiler;clang-resource-dir-symlink;swift-remote-mirror;license;sourcekit-inproc;static-mirror-lib;stdlib;sdk-overlay"
SWIFT_TOOLCHAIN_FLAGS="-RA --llvm-targets-to-build='X86;ARM;AArch64' -j $TERMUX_MAKE_PROCESSES"
SWIFT_PATH_FLAGS="--build-subdir=. --install-destdir=/ --install-prefix=$TERMUX_PREFIX"
SWIFT_BUILD_FLAGS="$SWIFT_TOOLCHAIN_FLAGS $SWIFT_PATH_FLAGS"
Expand All @@ -34,23 +34,24 @@ termux_step_post_get_source() {
mv .temp swift

declare -A library_checksums
library_checksums[swift-cmark]=143a58286e611460ba5ffe3d53d8be5bfbe655f9eba4571201537bb417547b63
library_checksums[llvm-project]=003e933dcfe8251ab0d809aba36d8f38d3cafa5946df2e0f0713962d9e5ebd62
library_checksums[swift-experimental-string-processing]=86f5e1c9336fc4fc7529554418bff760aaafc8397dc29c4e56a5b1334dcdffba
library_checksums[swift-corelibs-libdispatch]=4c6b7b0ecdf10e9cbe1cd007b9a09689ea412edb8e3a289ade6d105df43209f5
library_checksums[swift-corelibs-foundation]=78852bcfcf703957953761cbd18a2398c31b25f26ddf3ac18983b959e1564f3d
library_checksums[swift-corelibs-xctest]=4f152a62522008c09948202cd94d1d25c42b68ef5c8eb21abaa9855ea3e5a47f
library_checksums[swift-llbuild]=bf1f1ca43d4f658813382ddb144d11f2ccd79ab7b10b31fde673087587310909
library_checksums[swift-argument-parser]=a4d4c08cf280615fe6e00752ef60e28e76f07c25eb4706a9269bf38135cd9c3f
library_checksums[Yams]=b31b6df500d6191368c93f605690ca9857fff7c6fd1c8897e9765fb624535c63
library_checksums[swift-collections]=575cf0f88d9068411f9acc6e3ca5d542bef1cc9e87dc5d69f7b5a1d5aec8c6b6
library_checksums[swift-crypto]=86d6c22c9f89394fd579e967b0d5d0b6ce33cdbf52ba70f82fa313baf70c759f
library_checksums[swift-corelibs-foundation]=d003f86bf232a08139e03f23c26ee8bebff5c8f858353725bc60dc3273ffa025
library_checksums[swift-crypto]=84cec042505e1c5bf3dd14a1bb18d0c06c5a9435b7b10a69709101b602285ff5
library_checksums[swift-system]=865b8c380455eef27e73109835142920c60ae4c4f4178a3d12ad04acc83f1371
library_checksums[swift-driver]=4a730616abd89191dfbebae888bc9c2436447868b69b2d4dcb7dbb2111ad2863
library_checksums[swift-tools-support-core]=a0c54390f93642ee5df61bc65274c8c6a11e35177fb20188c1d9b710d69ef319
library_checksums[swift-package-manager]=01ed764386cbac24c07497b192261746ddc961ce876f5f94bdcebccc1322105c
library_checksums[indexstore-db]=210eff2343c4b122fd8622af7f0ad19cca41838dac66db8b5a35d477eaae79a0
library_checksums[sourcekit-lsp]=cabcc7b5b839fff159210a04303660646ba2d1f51c9cf288c3a6df3373cbcd96
library_checksums[swift-corelibs-libdispatch]=c448a64e96895a349606a69f858129c3246fbf58f0215206a071d171145d0100
library_checksums[llvm-project]=736123030c6a00e6be85b25b01b266e98d6c66e9d1d0d4c57a1139705507b4a6
library_checksums[swift-tools-support-core]=c6581ae8b5cd512957df05e3950c11571bbb7e7b2cb772ea622482dfdbd589db
library_checksums[swift-collections]=575cf0f88d9068411f9acc6e3ca5d542bef1cc9e87dc5d69f7b5a1d5aec8c6b6
library_checksums[swift-driver]=35d016dd28646501165af38b47a3c116c3a3f86900f678d09d4e875ed786643c
library_checksums[swift-experimental-string-processing]=bd1242e3a139b8df46d52a2153d1a1f0fac1f838f154c56963b05201eb1c6401
library_checksums[swift-package-manager]=fd302a9e0afcf6d8051bd7fd2a2f2033d2850e27ec84b2c3067f7fbdff1378ac
library_checksums[swift-cmark]=cc6774242039f3e6b78fb42e09a0202acb530756ed04c639b99e56e680d695ba
library_checksums[swift-argument-parser]=a4d4c08cf280615fe6e00752ef60e28e76f07c25eb4706a9269bf38135cd9c3f
library_checksums[sourcekit-lsp]=9f1bc2515fd1c32e31a00183675896f30b473503195472b707d9a2fae3a06797
library_checksums[indexstore-db]=9f6cc58c1f252e43271338ca0c6b23f0ebd53f6ebf77037b35a5a7db459416c5
library_checksums[swift-syntax]=2200a667af2c81d7841e9c98f6ecd82814ce0464e64319f4610a1c224802547b
library_checksums[swift-corelibs-xctest]=34e0296b4631d8fe666ad92cf575c3f2e9ad68ca65cfc27572180db1c2ac9f8c
library_checksums[swift-llbuild]=714fbc611021d21f70f0c9a7670ae09504961a853567c142dc06b2b8a86016f8
library_checksums[Yams]=ec1ad699c30f0db45520006c63a88cc1c946a7d7b36dff32a96460388c0a4af2

for library in "${!library_checksums[@]}"; do \
GH_ORG="apple"
Expand All @@ -61,14 +62,14 @@ termux_step_post_get_source() {
SRC_VERSION="1.0.1"
TAR_NAME=$SRC_VERSION
elif [ "$library" = "swift-crypto" ]; then
SRC_VERSION="1.1.5"
SRC_VERSION="2.2.3"
TAR_NAME=$SRC_VERSION
elif [ "$library" = "swift-system" ]; then
SRC_VERSION="1.1.1"
TAR_NAME=$SRC_VERSION
elif [ "$library" = "Yams" ]; then
GH_ORG="jpsim"
SRC_VERSION="5.0.0"
SRC_VERSION="5.0.1"
TAR_NAME=$SRC_VERSION
else
SRC_VERSION=$SWIFT_RELEASE
Expand Down Expand Up @@ -109,7 +110,7 @@ termux_step_host_build() {
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-cmark --skip-build-llvm --skip-build-swift --skip-early-swift-driver \
--build-toolchain-only --host-cc=$CLANG --host-cxx=$CLANGXX
--skip-early-swiftsyntax --build-toolchain-only --host-cc=$CLANG --host-cxx=$CLANGXX
fi
}

Expand All @@ -121,8 +122,7 @@ termux_step_make() {
termux_setup_swift
ln -sf $TERMUX_PKG_HOSTBUILD_DIR/llvm-linux-x86_64 $TERMUX_PKG_BUILDDIR/llvm-linux-x86_64

BOOTSTRAP=
test $SWIFT_ARCH == 'armv7' && BOOTSTRAP='--bootstrapping=off'
BOOTSTRAP='--bootstrapping=off'

SWIFT_BUILD_FLAGS="$SWIFT_BUILD_FLAGS --android
--android-ndk $TERMUX_STANDALONE_TOOLCHAIN --android-arch $SWIFT_ARCH
Expand All @@ -136,7 +136,7 @@ termux_step_make() {

SWIFT_BUILD_ROOT=$TERMUX_PKG_BUILDDIR $TERMUX_PKG_SRCDIR/swift/utils/build-script \
$SWIFT_BUILD_FLAGS --xctest -b -p --swift-driver --sourcekit-lsp \
--android-api-level $TERMUX_PKG_API_LEVEL \
--android-api-level $TERMUX_PKG_API_LEVEL --skip-early-swiftsyntax \
--build-swift-static-stdlib --swift-install-components=$SWIFT_COMPONENTS \
--llvm-install-components=IndexStore --install-llvm --install-swift \
--install-libdispatch --install-foundation --install-xctest --install-llbuild \
Expand All @@ -145,11 +145,14 @@ termux_step_make() {

termux_step_make_install() {
rm $TERMUX_PREFIX/lib/swift/pm/llbuild/libllbuild.so
rm $TERMUX_PREFIX/lib/swift/android/lib{dispatch,BlocksRuntime}.so
rm $TERMUX_PREFIX/lib/swift/android/$SWIFT_ARCH/lib{dispatch,BlocksRuntime}.so

if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then
rm $TERMUX_PREFIX/swiftpm-android-$SWIFT_ARCH.json
mv $TERMUX_PREFIX/glibc-native.modulemap \
$TERMUX_PREFIX/lib/swift/android/$SWIFT_ARCH/glibc.modulemap
rm $TERMUX_PREFIX/lib/swift/android/lib[^_]*.so
patchelf --set-rpath $TERMUX_PREFIX/lib:\$ORIGIN/../../android/$SWIFT_ARCH $TERMUX_PREFIX/lib/swift/pm/*API/lib*.so
patchelf --set-rpath $TERMUX_PREFIX/lib:\$ORIGIN/../lib/swift/android/$SWIFT_ARCH $TERMUX_PREFIX/bin/swift-package
fi
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
diff --git a/llvm-project/clang/lib/Driver/ToolChains/Linux.cpp b/llvm-project/clang/lib/Driver/ToolChains/Linux.cpp
index 0836903a0..e556e56fd 100644
--- a/llvm-project/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/llvm-project/clang/lib/Driver/ToolChains/Linux.cpp
@@ -162,8 +162,8 @@
@@ -162,8 +162,8 @@ static StringRef getOSLibDir(const llvm::Triple &Triple, const ArgList &Args) {
// FIXME: This is a bit of a hack. We should really unify this code for
// reasoning about oslibdir spellings with the lib dir spellings in the
// GCCInstallationDetector, but that is a more significant refactoring.
Expand All @@ -11,27 +13,27 @@
return "lib32";

if (Triple.getArch() == llvm::Triple::x86_64 && Triple.isX32())
@@ -287,7 +287,7 @@
@@ -287,7 +287,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
if (Triple.getVendor() == llvm::Triple::OpenEmbedded &&
Triple.isArch64Bit())
addPathIfExists(D, SysRoot + "/usr/" + OSLibDir, Paths);
addPathIfExists(D, concat(SysRoot, "/usr", OSLibDir), Paths);
- else
+ else if (!IsAndroid)
addPathIfExists(D, SysRoot + "/usr/lib/../" + OSLibDir, Paths);
addPathIfExists(D, concat(SysRoot, "/usr/lib/..", OSLibDir), Paths);
if (IsRISCV) {
StringRef ABIName = tools::riscv::getRISCVABI(Args, Triple);
@@ -311,7 +311,15 @@
@@ -311,7 +311,15 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
}

addPathIfExists(D, SysRoot + "/lib", Paths);
- addPathIfExists(D, SysRoot + "/usr/lib", Paths);
addPathIfExists(D, concat(SysRoot, "/lib"), Paths);
- addPathIfExists(D, concat(SysRoot, "/usr/lib"), Paths);
+ bool nativeBuild = MultiarchTriple == getMultiarchTriple(D, llvm::Triple(llvm::sys::getDefaultTargetTriple()), SysRoot);
+ if (nativeBuild || !IsAndroid)
+ addPathIfExists(D, SysRoot + "/usr/lib", Paths);
+ addPathIfExists(D, concat(SysRoot, "/usr/lib"), Paths);
+
+ if (IsAndroid) {
+ addPathIfExists(D, SysRoot + "/usr/" + MultiarchTriple + "/lib", Paths);
+ addPathIfExists(D, "/system/" + OSLibDir, Paths);
+ addPathIfExists(D, concat(SysRoot, "/usr/", MultiarchTriple, "/lib"), Paths);
+ addPathIfExists(D, concat("/system/", OSLibDir), Paths);
+ ExtraOpts.push_back("-rpath=" + SysRoot + "/usr/lib");
+ }
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/llvm-project/clang/tools/driver/cc1depscan_main.cpp 2022-08-28 12:37:53.827579690 +0000
+++ b/llvm-project/clang/tools/driver/cc1depscan_main.cpp 2022-08-28 12:39:25.307724796 +0000
@@ -68,7 +68,7 @@
ALWAYS_ENABLED_STATISTIC(NumRequests, "Number of -cc1 update requests");

#ifdef CLANG_HAVE_RLIMITS
-#if defined(__linux__) && defined(__PIE__)
+#if defined(__linux__) && defined(__PIE__) && !defined(__ANDROID__)
static size_t getCurrentStackAllocation() {
// If we can't compute the current stack usage, allow for 512K of command
// line arguments and environment.
28 changes: 20 additions & 8 deletions packages/swift/swift-android-spawn.patch
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,30 @@ index 8e79e18..a844183 100644
- target_link_libraries(llvmSupport PRIVATE curses)
+ target_link_libraries(llvmSupport PRIVATE android-spawn curses)
endif()
diff --git a/llvm-project/clang/tools/driver/CMakeLists.txt b/llvm-project/clang/tools/driver/CMakeLists.txt
index dd34c12880..ffd68d908b 100644
--- a/llvm-project/clang/tools/driver/CMakeLists.txt
+++ b/llvm-project/clang/tools/driver/CMakeLists.txt
@@ -97,6 +97,7 @@ if (APPLE)
set(TOOL_INFO_VERSION)
set(TOOL_INFO_BUILD_VERSION)
endif()
+target_link_libraries(clang PRIVATE "android-spawn")

if(CLANG_ORDER_FILE AND
(LLVM_LINKER_IS_LD64 OR LLVM_LINKER_IS_GOLD OR LLVM_LINKER_IS_LLD))
diff --git a/sourcekit-lsp/Utilities/build-script-helper.py b/sourcekit-lsp/Utilities/build-script-helper.py
index a64795c..d48876d 100755
--- a/sourcekit-lsp/Utilities/build-script-helper.py
+++ b/sourcekit-lsp/Utilities/build-script-helper.py
@@ -54,6 +54,7 @@ def get_swiftpm_options(args):
if 'ANDROID_DATA' in os.environ or (args.cross_compile_host and re.match(
'android-', args.cross_compile_host)):
swiftpm_args += [
+ '-Xlinker', '-landroid-spawn',
'-Xlinker', '-rpath', '-Xlinker', '$ORIGIN/../lib/swift/android',
# SwiftPM will otherwise try to compile against GNU strerror_r on
# Android and fail.
@@ -124,6 +124,7 @@ def get_swiftpm_options(swift_exec: str, args: argparse.Namespace) -> List[str]:
if 'ANDROID_DATA' in os.environ or (args.cross_compile_host and re.match(
'android-', args.cross_compile_host)):
swiftpm_args += [
+ '-Xlinker', '-landroid-spawn',
'-Xlinker', '-rpath', '-Xlinker', '$ORIGIN/../lib/swift/android',
# SwiftPM will otherwise try to compile against GNU strerror_r on
# Android and fail.
diff --git a/swift-corelibs-foundation/Sources/Foundation/CMakeLists.txt b/swift-corelibs-foundation/Sources/Foundation/CMakeLists.txt
index 016bf294..cd534f16 100644
--- a/swift-corelibs-foundation/Sources/Foundation/CMakeLists.txt
Expand Down
Loading

0 comments on commit a1befe6

Please sign in to comment.