Skip to content

Commit 0191f36

Browse files
committed
Patch and build against LTS NDK 26b also on CI
1 parent 48c4993 commit 0191f36

11 files changed

+612
-33
lines changed

.github/workflows/sdks.yml

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ jobs:
5959
matrix:
6060
version: [release, devel, trunk]
6161
arch: [aarch64, x86_64, armv7]
62+
ndk: [25c, 26b]
6263
env:
6364
ANDROID_API_LEVEL: 24
6465
steps:
@@ -86,8 +87,8 @@ jobs:
8687
id: cache-sdk
8788
uses: actions/cache@v3
8889
with:
89-
path: ~/swift-${{ matrix.version }}-android-${{ matrix.arch }}-*-sdk.tar.xz
90-
key: ${{ matrix.version }}-${{ steps.version.outputs.latest }}-${{ matrix.arch }}-bump-sdk
90+
path: ~/swift-${{ matrix.version }}-android-${{ matrix.arch }}-*-ndk${{ matrix.ndk }}-sdk.tar.xz
91+
key: ${{ matrix.version }}-${{ steps.version.outputs.latest }}-${{ matrix.arch }}-ndk${{ matrix.ndk }}-sdk
9192
- name: Clone
9293
uses: actions/checkout@v3
9394
with:
@@ -106,21 +107,28 @@ jobs:
106107
SDK=`pwd`/$SDK_NAME
107108
108109
tar xf ~/$SWIFT_TAG-ubuntu22.04.tar.gz
109-
git apply swift-android.patch swift-android-ci.patch
110+
git apply swift-android.patch swift-android-ci.patch swift-android-both-ndks.patch
111+
if [ ${{ matrix.version }} != 'release' ]; then
112+
git apply swift-android-arm.patch
113+
fi
114+
if [ ${{ matrix.ndk }} = '26b' ]; then
115+
git apply swift-android-ndk26.patch
116+
fi
110117
sed -i "s%/data/data/com.termux/files%$SDK%" $SDK/usr/lib/pkgconfig/sqlite3.pc
111118
sed -i "s%String(cString: getpass%\"fake\" //%" swiftpm/Sources/PackageRegistryTool/PackageRegistryTool+Auth.swift
112-
sed -i "s%#include <unistd%#include <signal.h>\n#include <unistd%" swift-corelibs-libdispatch/dispatch/dispatch.h
113-
sed -i "s%#include <unistd%#include <signal.h>\n#include <unistd%" llbuild/products/libllbuild/include/llbuild/buildsystem.h
114-
sed -i "s%#include <time%#include <signal.h>\n#include <time%" swift-tools-support-core/Sources/TSCclibc/include/indexstore_functions.h
115-
sed -i "s%#include <time%#include <signal.h>\n#include <time%" swift-crypto/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_asn1.h
119+
if [ ${{ matrix.ndk }} = '25c' ]; then
120+
NDK=$ANDROID_NDK
121+
else
122+
NDK=$ANDROID_NDK_LATEST_HOME
123+
fi
116124
117-
./swift/utils/build-script -RA --skip-build-cmark --build-llvm=0 --android --android-ndk $ANDROID_NDK --android-arch ${{ matrix.arch }} --android-api-level $ANDROID_API_LEVEL --build-swift-tools=0 --native-swift-tools-path=`pwd`/$SWIFT_TAG-ubuntu22.04/usr/bin --native-clang-tools-path=`pwd`/$SWIFT_TAG-ubuntu22.04/usr/bin --cross-compile-hosts=android-${{ matrix.arch }} --cross-compile-deps-path=$SDK --skip-local-build --build-swift-static-stdlib --xctest --skip-early-swift-driver --install-swift --install-libdispatch --install-foundation --install-xctest --install-destdir=$SDK --swift-install-components='clang-resource-dir-symlink;license;stdlib;sdk-overlay' --cross-compile-append-host-target-to-destdir=False -b -p --install-llbuild --sourcekit-lsp --skip-early-swiftsyntax
125+
./swift/utils/build-script -RA --skip-build-cmark --build-llvm=0 --android --android-ndk $NDK --android-arch ${{ matrix.arch }} --android-api-level $ANDROID_API_LEVEL --build-swift-tools=0 --native-swift-tools-path=`pwd`/$SWIFT_TAG-ubuntu22.04/usr/bin --native-clang-tools-path=`pwd`/$SWIFT_TAG-ubuntu22.04/usr/bin --cross-compile-hosts=android-${{ matrix.arch }} --cross-compile-deps-path=$SDK --skip-local-build --build-swift-static-stdlib --xctest --skip-early-swift-driver --install-swift --install-libdispatch --install-foundation --install-xctest --install-destdir=$SDK --swift-install-components='clang-resource-dir-symlink;license;stdlib;sdk-overlay' --cross-compile-append-host-target-to-destdir=False -b -p --install-llbuild --sourcekit-lsp --skip-early-swiftsyntax
118126
119-
cp $ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/$(echo ${{ matrix.arch }} | sed "s/v7//")-linux-android*/libc++_shared.so $SDK/usr/lib
127+
cp $NDK/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/$(echo ${{ matrix.arch }} | sed "s/v7//")-linux-android*/libc++_shared.so $SDK/usr/lib
120128
patchelf --set-rpath \$ORIGIN $SDK/usr/lib/swift/android/libdispatch.so
121129
patchelf --set-rpath \$ORIGIN/../..:\$ORIGIN $SDK/usr/lib/swift/android/lib[FXs]*.so
122130
123-
tar cJf ~/$SDK_NAME.tar.xz $SDK_NAME
131+
tar cJf ~/${SDK_NAME/-sdk/-ndk${{ matrix.ndk }}-sdk}.tar.xz $SDK_NAME
124132
rm -rf $SDK_NAME
125133
- name: Unpack ${{ matrix.version }} toolchain and SDK
126134
id: sdk-unpack
@@ -131,7 +139,7 @@ jobs:
131139
tar xf ~/${{ steps.version.outputs.tag }}-ubuntu22.04.tar.gz
132140
fi
133141
134-
tar xf ~/swift-${{ matrix.version }}-android-${{ matrix.arch }}*-${ANDROID_API_LEVEL}-sdk.tar.xz
142+
tar xf ~/swift-${{ matrix.version }}-android-${{ matrix.arch }}*-sdk.tar.xz
135143
- name: Get Swift Argument Parser package
136144
uses: actions/checkout@v3
137145
with:
@@ -149,7 +157,6 @@ jobs:
149157
- name: Build Swift crypto package
150158
run: |
151159
cd swift-crypto
152-
sed -i "s%#include <time%#include <signal.h>\n#include <time%" Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_asn1.h
153160
sed -i "s%\\\\(testsDirectory)/.*Vectors%/data/local/tmp/pack/crypto-vectors%" Tests/CryptoTests/Utils/RFCVector.swift Tests/CryptoTests/Utils/Wycheproof.swift Tests/_CryptoExtrasTests/Utils/Wycheproof.swift
154161
../sdk-config/${{ steps.version.outputs.tag }}-ubuntu22.04/usr/bin/swift build --build-tests --destination ../sdk-config/swift-${{ matrix.version }}-*-sdk/usr/swiftpm-android-${{ matrix.arch }}.json -Xlinker -rpath -Xlinker \$ORIGIN/lib/swift/android
155162
- name: Get Swift NIO package
@@ -160,7 +167,10 @@ jobs:
160167
- name: Build Swift NIO package
161168
run: |
162169
cd swift-nio
163-
git apply ../sdk-config/swift-nio-disable-ecn-tests.patch
170+
git apply ../sdk-config/swift-nio-disable-ecn-tests.patch ../sdk-config/swift-nio-force-unwrap.patch
171+
if [ ${{ matrix.ndk }} = '26b' ]; then
172+
git apply ../sdk-config/swift-nio-ndk26.patch
173+
fi
164174
../sdk-config/${{ steps.version.outputs.tag }}-ubuntu22.04/usr/bin/swift build --build-tests --destination ../sdk-config/swift-${{ matrix.version }}-*-sdk/usr/swiftpm-android-${{ matrix.arch }}.json -Xlinker -rpath -Xlinker \$ORIGIN/lib/swift/android
165175
- name: Get Swift Numerics package
166176
uses: actions/checkout@v3
@@ -180,6 +190,7 @@ jobs:
180190
run: |
181191
cd ss
182192
sed -i "s%/tmp%/data/local/tmp%" Tests/SystemTests/FileOperationsTest.swift
193+
git apply ../sdk-config/swift-system-ndk26.patch
183194
../sdk-config/${{ steps.version.outputs.tag }}-ubuntu22.04/usr/bin/swift build --build-tests --enable-test-discovery --destination ../sdk-config/swift-${{ matrix.version }}-*-sdk/usr/swiftpm-android-${{ matrix.arch }}.json -Xlinker -rpath -Xlinker \$ORIGIN/lib/swift/android
184195
- name: Get Swift Collections package
185196
uses: actions/checkout@v3
@@ -205,6 +216,7 @@ jobs:
205216
run: |
206217
cd sns
207218
sed -i "s%url: .*swift-\(\w\+\)\.git.*$%path: \"../swift-\1\"),%g" Package.swift
219+
git apply ../sdk-config/swift-nio-ssh-ndk26.patch
208220
../sdk-config/${{ steps.version.outputs.tag }}-ubuntu22.04/usr/bin/swift build --build-tests --destination ../sdk-config/swift-${{ matrix.version }}-*-sdk/usr/swiftpm-android-${{ matrix.arch }}.json -Xlinker -rpath -Xlinker \$ORIGIN/lib/swift/android
209221
- name: Get Swift NIO SSL package
210222
uses: actions/checkout@v3
@@ -214,7 +226,10 @@ jobs:
214226
- name: Build Swift NIO SSL package
215227
run: |
216228
cd snl
217-
sed -i "s%#include <time%#include <signal.h>\n#include <time%" Sources/CNIOBoringSSL/include/CNIOBoringSSL_asn1.h
229+
git apply ../sdk-config/swift-nio-ssl-force-unwrap.patch
230+
if [ ${{ matrix.ndk }} = '26b' ]; then
231+
git apply ../sdk-config/swift-nio-ssl-ndk26.patch
232+
fi
218233
SWIFTCI_USE_LOCAL_DEPS=1 ../sdk-config/${{ steps.version.outputs.tag }}-ubuntu22.04/usr/bin/swift build --build-tests --destination ../sdk-config/swift-${{ matrix.version }}-*-sdk/usr/swiftpm-android-${{ matrix.arch }}.json -Xlinker -rpath -Xlinker \$ORIGIN/lib/swift/android
219234
- name: Get Yams package
220235
uses: actions/checkout@v3
@@ -260,7 +275,7 @@ jobs:
260275
- name: Put SDK and x86_64 tests in one directory to push to Android x86_64 emulator
261276
run: |
262277
mkdir pack
263-
cp ~/swift-${{ matrix.version }}-android-${{ matrix.arch }}*-${ANDROID_API_LEVEL}-sdk.tar.xz pack
278+
cp ~/swift-${{ matrix.version }}-android-${{ matrix.arch }}*-sdk.tar.xz pack
264279
265280
if [ ${{ matrix.arch }} = 'x86_64' ]; then
266281
mkdir -p pack/lib/swift/android
@@ -295,7 +310,7 @@ jobs:
295310
- name: Upload test directory
296311
uses: actions/upload-artifact@v3
297312
with:
298-
name: sdk-tests-${{ matrix.version }}-${{ matrix.arch }}
313+
name: sdk-tests-${{ matrix.version }}-${{ matrix.arch }}-ndk${{ matrix.ndk }}
299314
path: pack/
300315
run-tests-on-android-x86_64-emulator:
301316
runs-on: macos-latest
@@ -304,11 +319,12 @@ jobs:
304319
fail-fast: false
305320
matrix:
306321
version: [release, devel, trunk]
322+
ndk: [25c, 26b]
307323
steps:
308324
- name: Download test directory
309325
uses: actions/download-artifact@v3
310326
with:
311-
name: sdk-tests-${{ matrix.version }}-x86_64
327+
name: sdk-tests-${{ matrix.version }}-x86_64-ndk${{ matrix.ndk }}
312328
path: pack
313329
- name: Run tests on Android x86_64 emulator
314330
uses: reactivecircus/android-emulator-runner@v2

swift-android-arm.patch

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
diff --git a/swift/stdlib/public/runtime/CrashHandlerLinux.cpp b/swift/stdlib/public/runtime/CrashHandlerLinux.cpp
2+
index ff44dbe7541..2f386278975 100644
3+
--- a/swift/stdlib/public/runtime/CrashHandlerLinux.cpp
4+
+++ b/swift/stdlib/public/runtime/CrashHandlerLinux.cpp
5+
@@ -243,7 +243,11 @@ handle_fatal_signal(int signum,
6+
#elif defined(__arm64__) || defined(__aarch64__)
7+
pc = (void *)(ctx->uc_mcontext.pc);
8+
#elif defined(__arm__)
9+
+#if defined(__ANDROID__)
10+
+ pc = (void *)(ctx->uc_mcontext.arm_pc);
11+
+#else
12+
pc = (void *)(ctx->uc_mcontext.gprs[15]);
13+
+#endif
14+
#endif
15+
16+
_swift_displayCrashMessage(signum, pc);

0 commit comments

Comments
 (0)