Skip to content
Merged
Show file tree
Hide file tree
Changes from 91 commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
5f1dbac
Add Android workflow
marcprux Mar 31, 2025
1b7e52f
Merge branch 'swiftlang:main' into main
marcprux Apr 7, 2025
c263e80
Merge branch 'swiftlang:main' into main
marcprux Apr 15, 2025
dd6d09f
Merge branch 'swiftlang:main' into main
marcprux Apr 22, 2025
6565052
Build Android image (#1)
marcprux Apr 22, 2025
5f9dab4
Merge branch 'swiftlang:main' into main
marcprux Apr 28, 2025
412e6b0
Merge branch 'swiftlang:main' into main
marcprux Apr 28, 2025
40733f7
Swift Android build 6.2 (#2)
marcprux May 1, 2025
53e361a
Swift Android build 6.2 (#3)
marcprux May 8, 2025
72964f5
Build SDK in Docker container (#4)
marcprux May 18, 2025
9160168
Merge branch 'swiftlang:main' into main
marcprux May 18, 2025
4987bcc
Checkout patches repo instead of using a git submodule
marcprux May 18, 2025
ff3f274
Update libcurl to 8.13.0
marcprux May 18, 2025
595efc3
Remove resources that we no longer use
marcprux May 18, 2025
27b1bf4
Update libcurl to 8.13.0
marcprux May 18, 2025
b898129
Update libxml2 to 2.14.2
marcprux May 18, 2025
f566b23
Build libxml2, libcurl, and boringssl with support for Android 16kb p…
marcprux May 18, 2025
529e3f1
Add build-script --extra-cmake-options=-DCMAKE_EXTRA_LINK_FLAGS=-Wl,-…
marcprux May 18, 2025
c82587d
Add 16KB page size linker flags to linker flags in swift-toolset.json
marcprux May 18, 2025
217f1d7
Add 16KB page size linker flags to linker flags in swift-toolset.json
marcprux May 19, 2025
95046b3
Build with ndk-r28b
marcprux May 19, 2025
8b18b5f
Revert to building with ndk-r27c
marcprux May 19, 2025
f67f9bf
Use official endpoints for discovering latest Swift release/devel/tru…
marcprux May 19, 2025
7011a45
Typo fix in version script
marcprux May 19, 2025
4c65a93
Cleanup for PR
marcprux May 19, 2025
d80c80b
Change BUILD_VERSION to BUILD_SCHEME and have it match release, swift…
marcprux May 19, 2025
2c07eef
Update Android README
marcprux May 19, 2025
51d93f8
Update how patches are applied
marcprux May 21, 2025
46a06df
Fix source directory for patch target
marcprux May 21, 2025
afb2918
Harmonize timestamps in artifactbundle with the swift source tag date…
marcprux May 21, 2025
a469e85
Simplify toolchain-vars.sh
marcprux May 22, 2025
dea39d7
Merge branch 'swiftlang:main' into main
marcprux May 26, 2025
b3cddbd
Merge branch 'swiftlang:main' into main
marcprux Jun 2, 2025
abd3fd1
Merge branch 'swiftlang:main' into main
marcprux Jun 13, 2025
ad24ea5
Merge branch 'swiftlang:main' into main
marcprux Jun 26, 2025
50ba1cd
Run the compiler validation suite for Android (#8)
marcprux Jun 29, 2025
71b7131
Build compiler-validated bundles from latest branch commits, not olde…
finagolfin Jun 30, 2025
e2f696a
Merge pull request #9 from swift-android-sdk/Testing
finagolfin Jul 4, 2025
3f4cd4a
gcpd 'Update patches'
marcprux Jul 16, 2025
bd0df11
Update patches and build matrix
marcprux Jul 17, 2025
80291aa
Disable compiler validated builds on self-hosted
marcprux Jul 17, 2025
18c563f
Centralize cmake variable for 6.2 in patches, as done for trunk upstream
finagolfin Jul 6, 2025
ed09034
Update disabled tests
finagolfin Jul 12, 2025
e4a96b2
Merge branch 'main' into update-patches2
marcprux Jul 17, 2025
f472e9e
Try running Docker build on macOS host
marcprux Jul 17, 2025
22a4320
Remove separate checks of libxml2, curl, and yams
marcprux Jul 18, 2025
bc3f105
Merge pull request #11 from swift-android-sdk/update-patches2
marcprux Jul 18, 2025
a7b303a
Remove upstreamed 6.2 branch patches
finagolfin Jul 18, 2025
4ed1375
Merge branch 'swiftlang:main' into main
marcprux Jul 18, 2025
3f36409
Use command-line flags to work around CMake 3.30+ linker flag bug, ra…
finagolfin Jul 21, 2025
f658604
Create an Android CMake toolchain file instead to cross-compile Testi…
finagolfin Jul 23, 2025
c9fc3d8
Install the native host LLVM tools for full compiler builds
finagolfin Jul 23, 2025
b881e14
Extend `--cross-compile-build-swift-tools=False` to disable building …
finagolfin Jul 26, 2025
9af1d90
Don't copy any libraries from the NDK: link the NDK's clang resource …
finagolfin Aug 8, 2025
5693797
Wildcard the clang version link in the post-install script in order t…
marcprux Aug 18, 2025
31f00b1
Merge pull request #13 from swift-android-sdk/clang-wildcard
marcprux Aug 22, 2025
db10f68
Merge branch 'swiftlang:main' into main
marcprux Aug 22, 2025
1221544
Switch generated shell header to use #!/usr/bin/env bash
marcprux Aug 22, 2025
f555f48
SBOM and nits (#14)
marcprux Aug 22, 2025
7696a44
Remove upstreamed patches and turn the last modifications into perl s…
finagolfin Aug 9, 2025
606ab7a
Remove self-hosted build on github CI
finagolfin Sep 3, 2025
8eb982e
Remove android_build job from pull_request workflow
marcprux Sep 4, 2025
534175d
Add license headers to Android build scripts
marcprux Sep 4, 2025
d139654
Remove unnecessary .gitignore
marcprux Sep 4, 2025
510addd
Add license header to Dockerfile
marcprux Sep 4, 2025
ee191ee
Merge branch 'swiftlang:main' into main
marcprux Sep 4, 2025
87bf6a2
Switch over to using explicit tags and branches when invoking build-d…
finagolfin Sep 7, 2025
9987e54
Merge branch 'swiftlang:main' into main
marcprux Sep 12, 2025
110ab52
Merge branch 'swiftlang:main' into main
marcprux Sep 13, 2025
811583e
Merge branch 'swiftlang:main' into main
marcprux Sep 16, 2025
3070fba
Fix build script arguments to use false instead of False due to true_…
marcprux Sep 16, 2025
bd87b1a
Build swift-6.2-RELEASE
marcprux Sep 16, 2025
ead9ba9
Apply patch from https://github.com/swiftlang/swift/pull/84061 for 6.…
marcprux Sep 16, 2025
1a19b03
Update patch application for 6.2
marcprux Sep 16, 2025
fab74d2
Change 6.2 to perform local build
marcprux Sep 16, 2025
d05b59d
Change 6.2 to perform local build on ubuntu-24.04
marcprux Sep 16, 2025
bf5d18d
Switch back to building 6.2 from a tag
marcprux Sep 16, 2025
7f71402
Switch back to building 6.2 from a tag
marcprux Sep 16, 2025
233b535
Switch back to building 6.2 from a tag
marcprux Sep 16, 2025
f8fcf04
Build the Swift 6.2 release self-hosted with compiler validation
marcprux Sep 17, 2025
2e0a326
Set minimum Android API to 24
marcprux Oct 27, 2025
865e13f
Build against swift-DEVELOPMENT-SNAPSHOT-2025-10-16-
marcprux Oct 27, 2025
9d14a52
Disable building libxml2 tests to handle missing glob function in And…
marcprux Oct 27, 2025
d7c0884
Disable building libxml2 tests to handle missing glob function in And…
marcprux Oct 27, 2025
be7a646
Build this PR without compiler validation
marcprux Oct 28, 2025
09839a9
Build this PR without compiler validation
marcprux Oct 28, 2025
19adc6b
Disable posix_spawnattr_ for Android 24
marcprux Oct 28, 2025
21c5b03
Reduce Android API from 24 to 23
marcprux Oct 28, 2025
069b38c
Restore Android minimum API to 24
marcprux Oct 28, 2025
c30a475
Add swift-nio to tests cases being run
marcprux Oct 28, 2025
8c6f92c
Reduce Android API from 24 to 23
marcprux Oct 29, 2025
f4aa58c
Try building swift-collections
marcprux Oct 29, 2025
b364c93
Try testing against emulator API level 23
marcprux Oct 29, 2025
6083eb1
Fix backtrace call
marcprux Oct 29, 2025
18e77e8
Fail with an error for posix_spawn
marcprux Oct 29, 2025
65dae50
Fix error for posix_spawn
marcprux Oct 29, 2025
6b12a06
Remove temporary swift-docker Android build workflow
marcprux Nov 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
187 changes: 187 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,190 @@ jobs:
name: docker-logs
path: |
*.log

android-build:
name: Android ${{ matrix.build-type }} ${{ matrix.swift-version }} ${{ matrix.arch }} ${{ matrix.runner }} (compiler=${{ matrix.build-compiler }})
strategy:
fail-fast: false
matrix:
include:
- swift-version: 'tag:swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a'
build-type: 'docker'
runner: 'ubuntu-24.04'
- swift-version: 'tag:swift-DEVELOPMENT-SNAPSHOT-2025-10-16-a'
build-type: 'local'
runner: 'ubuntu-24.04'
runs-on: ${{ matrix.runner }}
# 16 hour timeout
timeout-minutes: 960
steps:
- name: Free Disk Space
if: ${{ matrix.runner != 'self-hosted' }}
run: |
df -h
# brings available space from 25G to 32G
# otherwise we sometimes run out of space during the build
sudo rm -rf /usr/share/miniconda /usr/share/az* /usr/share/glade* /usr/local/share/chromium /usr/local/share/powershell /usr/share/dotnet /opt/ghc /opt/hostedtoolcache /usr/local/graalvm/ /usr/local/.ghcup/ /usr/local/lib/node_modules /usr/local/share/boost
sudo docker image prune --all --force
sudo docker builder prune -a
df -h
- name: Setup
id: config
run: |
# these variabes are used by build-docker and build-local
# to determine which Swift version to build for
echo "SWIFT_VERSION=${{ matrix.swift-version }}" >> $GITHUB_ENV
# pass the build-compiler matrix through to the build script
echo "BUILD_COMPILER=${{ matrix.build-compiler }}" >> $GITHUB_ENV
echo "TARGET_ARCHS=${{ matrix.arch }}" >> $GITHUB_ENV
echo "WORKDIR=${{ runner.temp }}/swift-android-sdk" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v4
- name: Build Android SDK (Local)
if: ${{ matrix.build-type == 'local' }}
working-directory: swift-ci/sdks/android
run: |
sudo apt install -q patchelf build-essential cmake ninja-build python3 golang git gnupg2 libcurl4-openssl-dev libedit-dev libicu-dev libncurses5-dev libpython3-dev libsqlite3-dev libxml2-dev rsync uuid-dev uuid-runtime tzdata curl unzip
./build-local ${SWIFT_VERSION} ${WORKDIR}
- name: Build Android SDK (Docker)
if: ${{ matrix.build-type == 'docker' }}
working-directory: swift-ci/sdks/android
run: |
./build-docker ${SWIFT_VERSION} ${WORKDIR}
- name: Install Host Toolchain
if: ${{ matrix.build-type == 'docker' }}
working-directory: swift-ci/sdks/android
run: |
# when building in a Docker container, we don't have a local host toolchain,
# but we need one in order to run the SDK validation tests, so we install it now
HOST_OS=ubuntu$(lsb_release -sr)
source ./scripts/toolchain-vars.sh
mkdir -p ${WORKDIR}/host-toolchain
./scripts/install-swift.sh ${WORKDIR}/host-toolchain/$SWIFT_BASE/usr
ls ${WORKDIR}/host-toolchain
${WORKDIR}/host-toolchain/*/usr/bin/swift --version
- name: Get artifact info
id: info
shell: bash
run: |
set -ex
SWIFT_ROOT=$(dirname ${WORKDIR}/host-toolchain/*/usr)
echo "swift-root=${SWIFT_ROOT}" >> $GITHUB_OUTPUT
echo "swift-path=${SWIFT_ROOT}/usr/bin/swift" >> $GITHUB_OUTPUT

ARTIFACT_PATH=$(realpath ${WORKDIR}/products/*.artifactbundle.tar.gz)
echo "artifact-path=${ARTIFACT_PATH}" >> $GITHUB_OUTPUT
echo "sdk-id=x86_64-unknown-linux-android23" >> $GITHUB_OUTPUT

ARTIFACT_EXT=".artifactbundle.tar.gz"
ARTIFACT_NAME="$(basename ${ARTIFACT_PATH} ${ARTIFACT_EXT})"
# depending on whether we are building locally or in a container, add a maker to the name
if [[ "${{ matrix.build-type }}" == 'local' ]]; then
ARTIFACT_NAME="${ARTIFACT_NAME}-local"
fi
if [[ "${{ matrix.build-compiler }}" == '1' ]]; then
ARTIFACT_NAME="${ARTIFACT_NAME}-hostbuild"
fi
# artifacts need a unique name so we suffix with the matrix arch(s)
if [[ ! -z "${{ matrix.arch }}" ]]; then
ARTIFACT_NAME="${ARTIFACT_NAME}-$(echo ${{ matrix.arch }} | tr ',' '-')"
fi
ARTIFACT_NAME="${ARTIFACT_NAME}${ARTIFACT_EXT}"

# There is no way to prevent even a single-file artifact from being zipped:
# https://github.com/actions/upload-artifact?tab=readme-ov-file#zip-archives
# so the actual artifact download will look like:
# swift-6.1-RELEASE_android-0.1-x86_64.artifactbundle.tar.gz.zip
echo "artifact-name=${ARTIFACT_NAME}" >> $GITHUB_OUTPUT
- name: Upload SDK artifactbundle
uses: actions/upload-artifact@v4
with:
compression-level: 0
name: ${{ steps.info.outputs.artifact-name }}
path: ${{ steps.info.outputs.artifact-path }}
- name: Cleanup
if: ${{ matrix.runner != 'self-hosted' }}
run: |
# need to free up some space or else when installing we get: No space left on device
df -h
rm -rf ${WORKDIR}/{build,source}
sudo docker image prune --all --force
sudo docker builder prune -a
df -h
- name: Install artifactbundle
if: ${{ matrix.runner != 'self-hosted' }}
shell: bash
run: |
set -ex
${{ steps.info.outputs.swift-path }} sdk install ${{ steps.info.outputs.artifact-path }}
${{ steps.info.outputs.swift-path }} sdk configure --show-configuration $(${{ steps.info.outputs.swift-path }} sdk list | head -n 1) ${{ steps.info.outputs.sdk-id }}
# recent releases require that ANDROID_NDK_ROOT *not* be set
# see https://github.com/swiftlang/swift-driver/pull/1879
echo "ANDROID_NDK_ROOT=" >> $GITHUB_ENV

- name: Create Demo Project
if: ${{ matrix.runner != 'self-hosted' }}
run: |
cd ${{ runner.temp }}
mkdir DemoProject
cd DemoProject
${{ steps.info.outputs.swift-path }} --version
${{ steps.info.outputs.swift-path }} package init
echo 'import Foundation' >> Sources/DemoProject/DemoProject.swift
echo 'import FoundationEssentials' >> Sources/DemoProject/DemoProject.swift
echo 'import FoundationXML' >> Sources/DemoProject/DemoProject.swift
echo 'import FoundationNetworking' >> Sources/DemoProject/DemoProject.swift
echo 'import Dispatch' >> Sources/DemoProject/DemoProject.swift
echo 'import Android' >> Sources/DemoProject/DemoProject.swift
- name: Test Demo Project on Android
uses: skiptools/swift-android-action@main
if: ${{ matrix.runner != 'self-hosted' }}
with:
# only test for the complete arch SDK build to speed up CI
#run-tests: ${{ matrix.arch == '' }}
package-path: ${{ runner.temp }}/DemoProject
installed-sdk: ${{ steps.info.outputs.sdk-id }}
installed-swift: ${{ steps.info.outputs.swift-root }}

- name: Checkout swift-algorithms
if: ${{ matrix.runner != 'self-hosted' }}
uses: actions/checkout@v4
with:
repository: apple/swift-algorithms
path: swift-algorithms
- name: Test swift-algorithms
if: ${{ matrix.runner != 'self-hosted' }}
uses: skiptools/swift-android-action@main
with:
package-path: swift-algorithms
installed-sdk: ${{ steps.info.outputs.sdk-id }}
installed-swift: ${{ steps.info.outputs.swift-root }}

- name: Checkout swift-system
if: ${{ matrix.runner != 'self-hosted' }}
uses: actions/checkout@v4
with:
repository: apple/swift-system
path: swift-system
- name: Test swift-system
if: ${{ matrix.runner != 'self-hosted' }}
uses: skiptools/swift-android-action@main
with:
package-path: swift-system
installed-sdk: ${{ steps.info.outputs.sdk-id }}
installed-swift: ${{ steps.info.outputs.swift-root }}

- name: Checkout swift-crypto
if: ${{ matrix.runner != 'self-hosted' }}
uses: actions/checkout@v4
with:
repository: apple/swift-crypto
path: swift-crypto
- name: Test swift-crypto
if: ${{ matrix.runner != 'self-hosted' }}
uses: skiptools/swift-android-action@main
with:
package-path: swift-crypto
installed-sdk: ${{ steps.info.outputs.sdk-id }}
installed-swift: ${{ steps.info.outputs.swift-root }}

2 changes: 1 addition & 1 deletion swift-ci/sdks/android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ which will build the sources for each of the specified
architectures and then combines the SDKs into a single
artifactbundle with targetTriples for each of the supported
architectures (`aarch64`, `x86_64`, `aarmv7`)
and Android API levels (28-35).
and Android API levels (24-35).

## Specifying Architectures

Expand Down
12 changes: 0 additions & 12 deletions swift-ci/sdks/android/build-docker
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
TARGET_ARCHS=${TARGET_ARCHS:-aarch64,x86_64,armv7}

ANDROID_NDK_VERSION=android-ndk-r27d
ANDROID_API=28

BASEPATH=$(dirname $(realpath $0))
cd ${BASEPATH}
Expand All @@ -39,16 +38,6 @@ source ./scripts/toolchain-vars.sh
# Check-out and patch the sources
./scripts/fetch-source.sh --source-dir ${WORKDIR}/source

# This `git grep` invocation in a trunk test fails in our Docker for some
# reason, so just turn it into a plain `grep` again.
perl -pi -e 's:"git",:#:' ${WORKDIR}/source/swift-project/swift/test/Misc/verify-swift-feature-testing.test-sh

# Work around swiftlang/swift-driver#1822 for now
perl -pi -g -we "s#(call rm ... \".\{LIBDISPATCH_BUILD_DIR\}\"\n(\s+)fi\n)#\1\2if [[ -d \"\\\${ANDROID_NDK}\" ]]; then call ln -sf \"\\\${SWIFT_BUILD_PATH}/lib/swift\" \"\\\${ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib\"; fi#" ${WORKDIR}/source/swift-project/swift/utils/build-script-impl

# disable backtrace() for Android (needs either API33+ or libandroid-execinfo, or to manually add in backtrace backport)
perl -pi -e 's;os\(Android\);os\(AndroidDISABLED\);g' ${WORKDIR}/source/swift-project/swift-testing/Sources/Testing/SourceAttribution/Backtrace.swift

mkdir -p ${WORKDIR}/products
chmod ugo+rwx ${WORKDIR}/products

Expand All @@ -70,6 +59,5 @@ $DOCKER run -i --rm \
--products-dir "/products" \
--host-toolchain "/usr/local/swift" \
--build-compiler "${BUILD_COMPILER}" \
--android-api "${ANDROID_API}" \
--ndk-home "/usr/local/ndk/${ANDROID_NDK_VERSION}" \
--archs "${TARGET_ARCHS}"
11 changes: 0 additions & 11 deletions swift-ci/sdks/android/build-local
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
TARGET_ARCHS=${TARGET_ARCHS:-aarch64,x86_64,armv7}

ANDROID_NDK_VERSION=android-ndk-r27d
ANDROID_API=28

BASEPATH=$(dirname $(realpath $0))
cd ${BASEPATH}
Expand Down Expand Up @@ -61,15 +60,6 @@ fi

# Check-out and patch the sources
./scripts/fetch-source.sh --source-dir ${WORKDIR}/source
# This `git grep` invocation in a trunk test fails in our Docker for some
# reason, so just turn it into a plain `grep` again.
perl -pi -e 's:"git",:#:' ${WORKDIR}/source/swift-project/swift/test/Misc/verify-swift-feature-testing.test-sh

# Work around swiftlang/swift-driver#1822 for now
perl -pi -g -we "s#(call rm ... \".\{LIBDISPATCH_BUILD_DIR\}\"\n(\s+)fi\n)#\1\2if [[ -d \"\\\${ANDROID_NDK}\" ]]; then call ln -sf \"\\\${SWIFT_BUILD_PATH}/lib/swift\" \"\\\${ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib\"; fi#" ${WORKDIR}/source/swift-project/swift/utils/build-script-impl

# disable backtrace() for Android (needs either API33+ or libandroid-execinfo, or to manually add in backtrace backport)
perl -pi -e 's;os\(Android\);os\(AndroidDISABLED\);g' ${WORKDIR}/source/swift-project/swift-testing/Sources/Testing/SourceAttribution/Backtrace.swift

mkdir -p ${WORKDIR}/products

Expand All @@ -79,6 +69,5 @@ mkdir -p ${WORKDIR}/products
--build-dir "${WORKDIR}/build" \
--build-compiler "${BUILD_COMPILER}" \
--host-toolchain "${HOST_TOOLCHAIN}" \
--android-api "${ANDROID_API}" \
--ndk-home "${ANDROID_NDK_HOME}" \
--archs "${TARGET_ARCHS}"
4 changes: 2 additions & 2 deletions swift-ci/sdks/android/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ declare_package boringssl "boringssl" "OpenSSL AND ISC AND MIT" \
android_sdk_version=0.1
sdk_name=
archs=aarch64,armv7,x86_64
android_api=28
android_api=23
build_type=Release
parallel_jobs=$(($(nproc --all) + 2))
source_dir=
Expand Down Expand Up @@ -320,12 +320,12 @@ for arch in $archs; do
-DCMAKE_TOOLCHAIN_FILE=$ndk_home/build/cmake/android.toolchain.cmake \
-DCMAKE_BUILD_TYPE=$build_type \
-DCMAKE_EXTRA_LINK_FLAGS="-rtlib=compiler-rt -unwindlib=libunwind -stdlib=libc++ -fuse-ld=lld -lc++ -lc++abi -Wl,-z,max-page-size=16384" \
-DCMAKE_BUILD_TYPE=$build_type \
-DCMAKE_INSTALL_PREFIX=$sdk_root/usr \
-DLIBXML2_WITH_PYTHON=NO \
-DLIBXML2_WITH_ICU=NO \
-DLIBXML2_WITH_ICONV=NO \
-DLIBXML2_WITH_LZMA=NO \
-DLIBXML2_WITH_TESTS=OFF \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_STATIC_LIBS=ON

Expand Down
23 changes: 23 additions & 0 deletions swift-ci/sdks/android/scripts/fetch-source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,26 @@ pushd boringssl >/dev/null 2>&1
git checkout ${BORINGSSL_VERSION}
popd >/dev/null 2>&1
groupend

groupstart "Patchin Sources"
# This `git grep` invocation in a trunk test fails in our Docker for some
# reason, so just turn it into a plain `grep` again.
perl -pi -e 's:"git",:#:' swift-project/swift/test/Misc/verify-swift-feature-testing.test-sh

# Work around swiftlang/swift-driver#1822 for now
perl -pi -g -we "s#(call rm ... \".\{LIBDISPATCH_BUILD_DIR\}\"\n(\s+)fi\n)#\1\2if [[ -d \"\\\${ANDROID_NDK}\" ]]; then call ln -sf \"\\\${SWIFT_BUILD_PATH}/lib/swift\" \"\\\${ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib\"; fi#" swift-project/swift/utils/build-script-impl

# disable backtrace() for Android (needs either API33+ or libandroid-execinfo, or to manually add in backtrace backport)
perl -pi -e 's;os\(Android\);os\(AndroidDISABLED\);g' swift-project/swift-testing/Sources/Testing/SourceAttribution/Backtrace.swift

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch isn't necessary anymore. Swift Testing uses dlsym() to look up backtrace() before calling it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I'll remove it.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, it is still needed for the 6.2 branch though.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Derp. OK, I'll put it back.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah but remove it for main! 😭

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meaning?

Copy link

@grynspan grynspan Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to get this patch out of the way now, then revisit if needed when we add #available to the mix. I don't like having an official toolchain that isn't building from actual source. Makes for spooky bugs I can't diagnose or fix.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, we have much bigger problems with Testing, as any Swift package with macros sees strange build errors when cross-compiling, swiftlang/swift-package-manager#8094, so I wouldn't worry about many using Testing until that is fixed. 😉 We will probably have to add doc telling people to only use XCTest on Android until then.

As for this change, rather than putting in logic to check both scheme and tag names that use 6.2 and only applying this change then, let's decide after the next trunk tag, when people can try the new #available(Android feature on their code finally, if we want to submit that new feature for 6.2. If not, I guarantee you that I will elide this change for 6.3 alone before the branch in a couple weeks. 👍

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We definitely don't want to tell people to only use XCTest! Given that Swift Testing is part of the toolchain, there should be no reason a developer who can use XCTest can't use Swift Testing.

But okay, I'll stop complaining until after the next tag.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that Swift Testing is part of the toolchain, there should be no reason a developer who can use XCTest can't use Swift Testing.

Given that long-standing issue with cross-compiling macros for tests, I don't see any way around warning Android users off Testing for now.


# Disable posix_spawnattr_* calls for Android API 24
perl -pi -e 's;try _throwIfPosixError\(posix_spawnattr_init;//try _throwIfPosixError\(posix_spawnattr_init;g' swift-project/swift-corelibs-foundation/Sources/Foundation/Process.swift
perl -pi -e 's;try _throwIfPosixError\(posix_spawnattr_setflags;//try _throwIfPosixError\(posix_spawnattr_setflags;g' swift-project/swift-corelibs-foundation/Sources/Foundation/Process.swift
perl -pi -e 's;posix_spawnattr_destroy;//posix_spawnattr_destroy;g' swift-project/swift-corelibs-foundation/Sources/Foundation/Process.swift

# fix getgrgid_r and getgrnam_r missing from Android API 23
perl -pi -e 's;getgrgid_r;{ _, _, _, _, _ in 0 };g' swift-project/swift-foundation/Sources/FoundationEssentials/Platform.swift
perl -pi -e 's;getgrnam_r;{ _, _, _, _, _ in 0 };g' swift-project/swift-foundation/Sources/FoundationEssentials/Platform.swift

groupend

4 changes: 2 additions & 2 deletions swift-ci/sdks/android/scripts/toolchain-vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ elif [[ $SWIFT_VERSION == scheme:* ]]; then
echo "Building $SWIFT_VERSION with prebuilt Swift $RELEASE_TAG compiler"
BUILD_COMPILER=yes
echo "Branch scheme builds always build the Swift compiler from source and take much longer."
else
echo "Invalid Swift version=${SWIFT_VERSION}"
else
echo "Invalid SWIFT_VERSION: $SWIFT_VERSION"
exit 1
fi

Expand Down
Loading