From df815ed48db555220fc7b8533fa29c0a41db0200 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Sat, 18 Jul 2026 00:21:16 -0400 Subject: [PATCH 1/3] Fix Android CI: correct armv7 triple and emulator OOM The Swift Android SDK names its armv7 target triples armv7-unknown-linux-android (not androideabi), so build against armv7-unknown-linux-android28 directly. Also free disk space before the emulator job, which was getting OOM-killed (adb exit 137) right after boot. --- .github/workflows/swift-android.yml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/swift-android.yml b/.github/workflows/swift-android.yml index 2c4fbd8..49a1456 100644 --- a/.github/workflows/swift-android.yml +++ b/.github/workflows/swift-android.yml @@ -15,6 +15,9 @@ jobs: uses: skiptools/swift-android-action@v2 with: swift-version: 6.3.3 + # Free disk space before launching the emulator; without the headroom + # the emulator has been getting OOM-killed (adb exit 137) right after boot. + free-disk-space: true android-armv7: name: Android (armv7 cross-compile) @@ -38,12 +41,8 @@ jobs: swift sdk list # armv7 can't run on the x86_64 emulator, so this is a cross-compile check # only. The bundle installs as a single multi-arch SDK; the architecture is - # selected by target triple. Read the exact armv7 triple (with its - # API-level suffix) from the installed SDK metadata rather than pinning it. + # selected by target triple. The SDK's armv7 triples are named + # `armv7-unknown-linux-android` (not `...androideabi`), one per + # Android API level 28-36. - name: Build (armv7) - run: | - set -eux - TRIPLE=$(grep -rhoE 'armv7-unknown-linux-androideabi[0-9]*' ~/.swiftpm | sort -u | head -1) - test -n "$TRIPLE" - echo "Using target triple: $TRIPLE" - swift build --swift-sdk "$TRIPLE" + run: swift build --swift-sdk armv7-unknown-linux-android28 From 5ecc9372a7e43934c767a6b403311cb617b91863 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Sat, 18 Jul 2026 00:46:48 -0400 Subject: [PATCH 2/3] Build armv7 Android via the action so the NDK is provisioned A bare swift:6.3.3 container can't cross-compile for Android: the SDK bundle's ndk-sysroot (semaphore.h, libc, etc.) comes from the Android NDK, which the container lacks. Run the armv7 build through skiptools/swift-android-action, which installs the NDK and wires ANDROID_NDK_HOME, retargeting the compile to armv7 via swift-build-flags. Tests are disabled so no emulator is launched. --- .github/workflows/swift-android.yml | 33 ++++++++++++----------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/.github/workflows/swift-android.yml b/.github/workflows/swift-android.yml index 49a1456..02a418d 100644 --- a/.github/workflows/swift-android.yml +++ b/.github/workflows/swift-android.yml @@ -22,27 +22,20 @@ jobs: android-armv7: name: Android (armv7 cross-compile) runs-on: ubuntu-latest - container: swift:6.3.3 steps: - name: Checkout uses: actions/checkout@v4 - - name: Install dependencies - run: apt-get update -y && apt-get install -y curl - - name: Install Swift Android SDK - # The Android SDK artifact bundle is only published for 6.3.3, and the - # host toolchain must match the bundle version exactly (Swift's module - # format isn't cross-patch-compatible) — hence the swift:6.3.3 container. - run: | - set -eux - url="https://download.swift.org/swift-6.3.3-release/android-sdk/swift-6.3.3-RELEASE/swift-6.3.3-RELEASE_android.artifactbundle.tar.gz" - curl -fsSL "$url" -o android.artifactbundle.tar.gz - swift sdk install android.artifactbundle.tar.gz \ - --checksum d160cc3206dd1886dae3fef2337af5e25ec034692cd0ec225721c56cc69da7f5 - swift sdk list # armv7 can't run on the x86_64 emulator, so this is a cross-compile check - # only. The bundle installs as a single multi-arch SDK; the architecture is - # selected by target triple. The SDK's armv7 triples are named - # `armv7-unknown-linux-android` (not `...androideabi`), one per - # Android API level 28-36. - - name: Build (armv7) - run: swift build --swift-sdk armv7-unknown-linux-android28 + # only (build-tests/run-tests off skips the emulator entirely). The action + # provisions the Android NDK and points the SDK at it via ANDROID_NDK_HOME; + # a bare `swift:6.3.3` container can't build for Android because the SDK's + # `ndk-sysroot` (semaphore.h, libc, …) is supplied by the NDK, not the + # bundle. The action's build command already targets x86_64, so append a + # second `--swift-sdk` for armv7 (last one wins) to retarget the compile. + - name: Cross-compile for armv7 + uses: skiptools/swift-android-action@v2 + with: + swift-version: 6.3.3 + build-tests: false + run-tests: false + swift-build-flags: --swift-sdk armv7-unknown-linux-android28 From 10fa4462ec817bf51c57bf9d843c9f40ca069717 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Sat, 18 Jul 2026 01:23:37 -0400 Subject: [PATCH 3/3] Harden Android emulator boot against intermittent exit 137 The GitHub-hosted x86_64 emulator was dying with SIGKILL (exit 137) right after reporting boot, failing the unit-test job non-deterministically. Force a cold boot with software rendering and a longer boot timeout so the emulator starts deterministically instead of restoring a crash-prone snapshot. --- .github/workflows/swift-android.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/swift-android.yml b/.github/workflows/swift-android.yml index 02a418d..c42b953 100644 --- a/.github/workflows/swift-android.yml +++ b/.github/workflows/swift-android.yml @@ -15,9 +15,15 @@ jobs: uses: skiptools/swift-android-action@v2 with: swift-version: 6.3.3 - # Free disk space before launching the emulator; without the headroom - # the emulator has been getting OOM-killed (adb exit 137) right after boot. + # Free disk space before launching the emulator for extra headroom. free-disk-space: true + # The GitHub-hosted x86_64 emulator intermittently dies with exit 137 + # right after "Emulator booted" (adb: device offline). Force a cold boot + # (-no-snapshot, avoiding a crash-prone snapshot restore) with software + # rendering (-gpu swiftshader_indirect) and a generous boot timeout to + # make the boot deterministic. + android-emulator-options: -no-snapshot -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -camera-front none + android-emulator-boot-timeout: 900 android-armv7: name: Android (armv7 cross-compile)