Skip to content

Swift 6.1 #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jun 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
71 changes: 29 additions & 42 deletions .github/workflows/build-android-toolchain.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
name: Build Android Toolchain

on:
# Trigger the workflow on push or pull request,
# but only for the master branch
push:
branches:
- master
pull_request:
branches:
- master
Expand All @@ -31,7 +26,7 @@ jobs:
uses: actions/cache@v4
with:
path: ~/out/swift-android/lib
key: ${{ runner.os }}-stdlib-arm64-${{ hashFiles('.swift.sum') }}
key: ${{ runner.os }}-stdlib-arm64-api29-${{ hashFiles('.swift.sum') }}
- name: Build Swift
if: steps.cache-swift-arm-64.outputs.cache-hit != 'true'
run: ./build/031-build-swift-arm64.sh
Expand Down Expand Up @@ -60,7 +55,7 @@ jobs:
uses: actions/cache@v4
with:
path: ~/out/swift-android/lib
key: ${{ runner.os }}-stdlib-arm32-${{ hashFiles('.swift.sum') }}
key: ${{ runner.os }}-stdlib-arm32-api29-${{ hashFiles('.swift.sum') }}
- name: Build Swift
if: steps.cache-swift-arm-32.outputs.cache-hit != 'true'
run: ./build/032-build-swift-arm.sh
Expand Down Expand Up @@ -89,7 +84,7 @@ jobs:
uses: actions/cache@v4
with:
path: ~/out/swift-android/lib
key: ${{ runner.os }}-stdlib-x86_64-${{ hashFiles('.swift.sum') }}
key: ${{ runner.os }}-stdlib-x86_64-api29-${{ hashFiles('.swift.sum') }}
- name: Build Swift
if: steps.cache-swift-x86_64.outputs.cache-hit != 'true'
run: ./build/033-build-swift-x86_64.sh
Expand Down Expand Up @@ -117,7 +112,7 @@ jobs:
uses: actions/cache@v4
with:
path: ~/out/swift-android/lib
key: ${{ runner.os }}-stdlib-x86-${{ hashFiles('.swift.sum') }}
key: ${{ runner.os }}-stdlib-x86-api29-${{ hashFiles('.swift.sum') }}
- name: Build Swift
if: steps.cache-swift-x86.outputs.cache-hit != 'true'
run: ./build/034-build-swift-x86.sh
Expand All @@ -142,7 +137,7 @@ jobs:
~/openssl/arm
~/openssl/x86_64
~/openssl/x86
key: openssl-1.1.1w-r4
key: openssl-3.5.0-r1
- name: Install dependencies
if: steps.cache-openssl.outputs.cache-hit != 'true'
run: ./build/000-install-dependencies-nobel.sh
Expand Down Expand Up @@ -189,7 +184,7 @@ jobs:
~/curl/arm
~/curl/x86_64
~/curl/x86
key: curl-7_88_1-r10
key: curl-8.13.0-r1
- name: Install dependencies
if: steps.cache-curl.outputs.cache-hit != 'true'
run: ./build/000-install-dependencies-nobel.sh
Expand Down Expand Up @@ -255,7 +250,7 @@ jobs:
~/libxml/arm
~/libxml/x86_64
~/libxml/x86
key: libxmlv2.13.5-r2
key: libxmlv2.14.3-r1
- name: Install dependencies
if: steps.cache-libxml.outputs.cache-hit != 'true'
run: ./build/000-install-dependencies-nobel.sh
Expand Down Expand Up @@ -298,6 +293,8 @@ jobs:
run: ./build/002-install-ndk.sh
- name: Define build folders
run: ./build/003-define-build-folders.sh
- name: Clone Swift
run: ./build/020-clone-swift.sh
- uses: actions/download-artifact@v4
with:
name: openssl-arm64-v8a
Expand All @@ -314,18 +311,8 @@ jobs:
with:
name: swift-android-arm64-v8a
path: ~/swift-android/lib
- name: Copy andorid stdlib to swift toolchain
run: cp -r ~/swift-android/lib/swift/android ~/swift-toolchain/usr/lib/swift
- name: Remove corelibs headers from swift-toolchain
run: rm -rf ~/swift-toolchain/usr/lib/swift/CoreFoundation ~/swift-toolchain/usr/lib/swift/dispatch ~/swift-toolchain/usr/lib/swift/_FoundationCShims ~/swift-toolchain/usr/lib/swift/_foundation_unicode
- name: Clone Swift
run: ./build/020-clone-swift.sh
- name: Build Corelibs
run: ./build/052-build-corelibs.sh arm64 aarch64 aarch64-linux-android arm64-v8a aarch64-linux-android
- uses: actions/upload-artifact@v4
with:
name: swift-android-clang-libs
path: ~/swift-toolchain/usr/lib/clang
- uses: actions/upload-artifact@v4
with:
name: swift-android-arm64-v8a-libs
Expand All @@ -344,6 +331,8 @@ jobs:
run: ./build/002-install-ndk.sh
- name: Define build folders
run: ./build/003-define-build-folders.sh
- name: Clone Swift
run: ./build/020-clone-swift.sh
- uses: actions/download-artifact@v4
with:
name: openssl-armeabi-v7a
Expand All @@ -360,12 +349,6 @@ jobs:
with:
name: swift-android-armeabi-v7a
path: ~/swift-android/lib
- name: Copy andorid stdlib to swift toolchain
run: cp -r ~/swift-android/lib/swift/android ~/swift-toolchain/usr/lib/swift
- name: Remove corelibs headers from swift-toolchain
run: rm -rf ~/swift-toolchain/usr/lib/swift/CoreFoundation ~/swift-toolchain/usr/lib/swift/dispatch ~/swift-toolchain/usr/lib/swift/_FoundationCShims ~/swift-toolchain/usr/lib/swift/_foundation_unicode
- name: Clone Swift
run: ./build/020-clone-swift.sh
- name: Build Corelibs
run: ./build/052-build-corelibs.sh arm armv7 arm-linux-androideabi armeabi-v7a armv7a-linux-androideabi
- uses: actions/upload-artifact@v4
Expand All @@ -386,6 +369,8 @@ jobs:
run: ./build/002-install-ndk.sh
- name: Define build folders
run: ./build/003-define-build-folders.sh
- name: Clone Swift
run: ./build/020-clone-swift.sh
- uses: actions/download-artifact@v4
with:
name: openssl-x86_64
Expand All @@ -402,12 +387,6 @@ jobs:
with:
name: swift-android-x86_64
path: ~/swift-android/lib
- name: Copy andorid stdlib to swift toolchain
run: cp -r ~/swift-android/lib/swift/android ~/swift-toolchain/usr/lib/swift
- name: Remove corelibs headers from swift-toolchain
run: rm -rf ~/swift-toolchain/usr/lib/swift/CoreFoundation ~/swift-toolchain/usr/lib/swift/dispatch ~/swift-toolchain/usr/lib/swift/_FoundationCShims ~/swift-toolchain/usr/lib/swift/_foundation_unicode
- name: Clone Swift
run: ./build/020-clone-swift.sh
- name: Build Corelibs
run: ./build/052-build-corelibs.sh x86_64 x86_64 x86_64-linux-android x86_64 x86_64-linux-android
- uses: actions/upload-artifact@v4
Expand All @@ -428,6 +407,8 @@ jobs:
run: ./build/002-install-ndk.sh
- name: Define build folders
run: ./build/003-define-build-folders.sh
- name: Clone Swift
run: ./build/020-clone-swift.sh
- uses: actions/download-artifact@v4
with:
name: openssl-x86
Expand All @@ -444,12 +425,6 @@ jobs:
with:
name: swift-android-x86
path: ~/swift-android/lib
- name: Copy andorid stdlib to swift toolchain
run: cp -r ~/swift-android/lib/swift/android ~/swift-toolchain/usr/lib/swift
- name: Remove corelibs headers from swift-toolchain
run: rm -rf ~/swift-toolchain/usr/lib/swift/CoreFoundation ~/swift-toolchain/usr/lib/swift/dispatch ~/swift-toolchain/usr/lib/swift/_FoundationCShims ~/swift-toolchain/usr/lib/swift/_foundation_unicode
- name: Clone Swift
run: ./build/020-clone-swift.sh
- name: Build Corelibs
run: ./build/052-build-corelibs.sh x86 i686 i686-linux-android x86 i686-linux-android
- uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -486,8 +461,20 @@ jobs:
path: ~/lib/swift-i686
- uses: actions/download-artifact@v4
with:
name: swift-android-clang-libs
path: ~/lib/clang
name: swift-android-arm64-v8a
path: ~/stdlib/swift-aarch64
- uses: actions/download-artifact@v4
with:
name: swift-android-armeabi-v7a
path: ~/stdlib/swift-armv7
- uses: actions/download-artifact@v4
with:
name: swift-android-x86_64
path: ~/stdlib/swift-x86_64
- uses: actions/download-artifact@v4
with:
name: swift-android-x86
path: ~/stdlib/swift-i686
- name: Collect toolchain
run: ./build/060-collect-toolchain.sh
- uses: actions/upload-artifact@v4
Expand Down
11 changes: 0 additions & 11 deletions build/000-install-dependencies-nobel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,4 @@ apt-get install -y \
rpl

clang --version

# Install swift for bootstraping
wget https://download.swift.org/swift-6.0.3-release/ubuntu2004/swift-6.0.3-RELEASE/swift-6.0.3-RELEASE-ubuntu20.04.tar.gz
tar -xvzf swift-6.0.3-RELEASE-ubuntu20.04.tar.gz
rm swift-6.0.3-RELEASE-ubuntu20.04.tar.gz
mv $HOME/swift-6.0.3-RELEASE-ubuntu20.04 $HOME/swift-toolchain
export PATH=$HOME/swift-toolchain/usr/bin:$PATH
echo "export PATH=\$HOME/swift-toolchain/usr/bin:\$PATH" >> .build_env
echo "export SWIFT_PATH=\$HOME/swift-toolchain/usr/bin" >> .build_env

swift --version

10 changes: 1 addition & 9 deletions build/002-install-ndk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,13 @@

cd $HOME

ndk=android-ndk-r26c
ndk=android-ndk-r27c
ndk_zip=$ndk-linux.zip

wget --progress=bar:force https://dl.google.com/android/repository/$ndk_zip
unzip $ndk_zip
rm $ndk_zip

# Patch: Fix `fts_open` Parameter Annotation in NDK `fts.h`
#
# In the Android NDK 26c the function `fts_open` is incorrectly
# declared to accept `char* _Nonnull const* _Nonnull` for its first parameter.
# However, the array should actually be null-terminated, indicating the pointer
# at the end may be NULL. Therefore, `_Nullable` is more appropriate.
sed -i 's/fts_open(char\* _Nonnull const\* _Nonnull/fts_open(char* _Nullable const* _Nonnull/' $ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/fts.h

# exports
echo "export ANDROID_NDK=\$HOME/$ndk" >> .build_env
echo "export ANDROID_NDK_HOME=\$ANDROID_NDK" >> .build_env
16 changes: 15 additions & 1 deletion build/020-clone-swift.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
set -ex

ROOT_DIR=$(realpath $(dirname $0))/../
BRANCH="release/6.0"
SWIFT_VERSION="6.1"
BRANCH="release/$SWIFT_VERSION"

source $HOME/.build_env

Expand Down Expand Up @@ -38,3 +39,16 @@ pushd $SWIFT_SRC
rm -rf ninja/.git

popd

# Install swift for bootstraping
pushd $HOME
wget https://download.swift.org/swift-$SWIFT_VERSION-release/ubuntu2404/swift-$SWIFT_VERSION-RELEASE/swift-$SWIFT_VERSION-RELEASE-ubuntu24.04.tar.gz
tar -xvzf swift-$SWIFT_VERSION-RELEASE-ubuntu24.04.tar.gz
rm swift-$SWIFT_VERSION-RELEASE-ubuntu24.04.tar.gz
mv $HOME/swift-$SWIFT_VERSION-RELEASE-ubuntu24.04 $HOME/swift-toolchain
export PATH=$HOME/swift-toolchain/usr/bin:$PATH
echo "export PATH=\$HOME/swift-toolchain/usr/bin:\$PATH" >> .build_env
echo "export SWIFT_PATH=\$HOME/swift-toolchain/usr/bin" >> .build_env

swift --version
popd
8 changes: 6 additions & 2 deletions build/031-build-swift-arm64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ $SWIFT_SRC/swift/utils/build-script \
--android \
--android-ndk $ANDROID_NDK \
--android-arch aarch64 \
--android-api-level 21 \
--android-api-level 29 \
--stdlib-deployment-targets=android-aarch64 \
--native-swift-tools-path=$SWIFT_PATH \
--native-clang-tools-path=$SWIFT_PATH \
--build-swift-tools=0 \
--build-llvm=0 \
--skip-build-cmark

mv $SWIFT_SRC/build/Ninja-ReleaseAssert/swift-linux-x86_64/lib $DST_ROOT/lib
mv $SWIFT_SRC/build/Ninja-ReleaseAssert/swift-linux-x86_64/lib $DST_ROOT/lib

# Move libraries to proper dst libs
mv $DST_ROOT/lib/swift/android/*.so $DST_ROOT/lib/swift/android/aarch64
mv $DST_ROOT/lib/swift/android/*.a $DST_ROOT/lib/swift/android/aarch64
8 changes: 6 additions & 2 deletions build/032-build-swift-arm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ $SWIFT_SRC/swift/utils/build-script \
--android \
--android-ndk $ANDROID_NDK \
--android-arch armv7 \
--android-api-level 21 \
--android-api-level 29 \
--stdlib-deployment-targets=android-armv7 \
--native-swift-tools-path=$SWIFT_PATH \
--native-clang-tools-path=$SWIFT_PATH \
--build-swift-tools=0 \
--build-llvm=0 \
--skip-build-cmark

mv $SWIFT_SRC/build/Ninja-ReleaseAssert/swift-linux-x86_64/lib $DST_ROOT/lib
mv $SWIFT_SRC/build/Ninja-ReleaseAssert/swift-linux-x86_64/lib $DST_ROOT/lib

# Move libraries to proper dst libs
mv $DST_ROOT/lib/swift/android/*.so $DST_ROOT/lib/swift/android/armv7
mv $DST_ROOT/lib/swift/android/*.a $DST_ROOT/lib/swift/android/armv7
8 changes: 6 additions & 2 deletions build/033-build-swift-x86_64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ $SWIFT_SRC/swift/utils/build-script \
--android \
--android-ndk $ANDROID_NDK \
--android-arch x86_64 \
--android-api-level 21 \
--android-api-level 29 \
--stdlib-deployment-targets=android-x86_64 \
--native-swift-tools-path=$SWIFT_PATH \
--native-clang-tools-path=$SWIFT_PATH \
--build-swift-tools=0 \
--build-llvm=0 \
--skip-build-cmark

mv $SWIFT_SRC/build/Ninja-ReleaseAssert/swift-linux-x86_64/lib $DST_ROOT/lib
mv $SWIFT_SRC/build/Ninja-ReleaseAssert/swift-linux-x86_64/lib $DST_ROOT/lib

# Move libraries to proper dst libs
mv $DST_ROOT/lib/swift/android/*.so $DST_ROOT/lib/swift/android/x86_64
mv $DST_ROOT/lib/swift/android/*.a $DST_ROOT/lib/swift/android/x86_64
8 changes: 6 additions & 2 deletions build/034-build-swift-x86.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ $SWIFT_SRC/swift/utils/build-script \
--android \
--android-ndk $ANDROID_NDK \
--android-arch i686 \
--android-api-level 21 \
--android-api-level 29 \
--stdlib-deployment-targets=android-i686 \
--native-swift-tools-path=$SWIFT_PATH \
--native-clang-tools-path=$SWIFT_PATH \
--build-swift-tools=0 \
--build-llvm=0 \
--skip-build-cmark

mv $SWIFT_SRC/build/Ninja-ReleaseAssert/swift-linux-x86_64/lib $DST_ROOT/lib
mv $SWIFT_SRC/build/Ninja-ReleaseAssert/swift-linux-x86_64/lib $DST_ROOT/lib

# Move libraries to proper dst libs
mv $DST_ROOT/lib/swift/android/*.so $DST_ROOT/lib/swift/android/i686
mv $DST_ROOT/lib/swift/android/*.a $DST_ROOT/lib/swift/android/i686
12 changes: 4 additions & 8 deletions build/041-build-openssl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,21 @@ set -ex

source $HOME/.build_env

OPENSSL_VERSION=1.1.1w

DOWNLOAD_URL_OPENSSL=https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz
OPENSSL_VERSION=3.5.0
DOWNLOAD_URL_OPENSSL=https://github.com/openssl/openssl/releases/download/openssl-$OPENSSL_VERSION/openssl-$OPENSSL_VERSION.tar.gz

archs=(arm arm64 x86 x86_64)

rm -rf $OPENSSL_LIBS
mkdir -p $OPENSSL_LIBS

pushd $OPENSSL_LIBS
mkdir downloads src

mkdir src/openssl
mkdir -p downloads src/openssl
wget $DOWNLOAD_URL_OPENSSL -O downloads/openssl.tar.gz
tar -xvf downloads/openssl.tar.gz -C src/openssl --strip-components=1

popd

API=24
API=29
HOST=linux-x86_64
TOOLCHAIN=$ANDROID_NDK/toolchains/llvm/prebuilt/$HOST
PATH=$TOOLCHAIN/bin:$PATH
Expand Down
Loading