Skip to content

Commit 1b95949

Browse files
committed
Pull in Marc's upstream patch to build for 16KB pages on the CI
1 parent a1ac798 commit 1b95949

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

.github/workflows/sdks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ jobs:
124124
125125
ANDROID_ARCH=aarch64 BUILD_SWIFT_PM=1 ${TOOLCHAIN}/bin/swift get-packages-and-swift-source.swift
126126
127-
git apply -C1 swift-android.patch swift-android-ci.patch
127+
git apply -C1 swift-android.patch swift-android-ci.patch swift-android-16k-pages.patch
128128
BUILD_FLAG="--foundation-cmake-options=-DCMAKE_SHARED_LINKER_FLAGS=''"
129129
if ${{ matrix.version == 'release' }}; then
130130
perl -pi -e 's%r26%ndk/27%' swift/stdlib/cmake/modules/AddSwiftStdlib.cmake

swift-android-16k-pages.patch

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
From 8db43c6290ee04145264c04728a030dd74f87452
2+
From: Marc Prud'hommeaux <[email protected]>
3+
Date: Sun, 18 May 2025 19:10:36 -0400
4+
Subject: Support 16 KB page sizes on Android
5+
6+
Android 15+ requires that native libraries be compiled with a linker flag to support 16 KB page sizes. See: https://developer.android.com/guide/practices/page-sizes#compile-r26-lower
7+
8+
diff --git a/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake b/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake
9+
index ce113989ad75d..089f5f30acbb5 100644
10+
--- a/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake
11+
+++ b/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake
12+
@@ -2469,6 +2469,8 @@ function(add_swift_target_library name)
13+
list(APPEND swiftlib_link_flags_all "-shared")
14+
# TODO: Instead of `lib${name}.so` find variable or target property which already have this value.
15+
list(APPEND swiftlib_link_flags_all "-Wl,-soname,lib${name}.so")
16+
+ # Ensure compatibility with Android 15+ devices using 16KB memory pages.
17+
+ list(APPEND swiftlib_link_flags_all "-Wl,-z,max-page-size=16384")
18+
endif()
19+
20+
if (SWIFTLIB_BACK_DEPLOYMENT_LIBRARY)
21+
diff --git a/swift/utils/swift_build_support/swift_build_support/targets.py b/swift/utils/swift_build_support/swift_build_support/targets.py
22+
index fba09416ddb90..7f3f35ec8097c 100644
23+
--- a/swift/utils/swift_build_support/swift_build_support/targets.py
24+
+++ b/swift/utils/swift_build_support/swift_build_support/targets.py
25+
@@ -164,7 +164,8 @@ def swift_flags(self, args):
26+
android_toolchain_path = self.ndk_toolchain_path(args)
27+
28+
flags += '-sdk %s/sysroot ' % (android_toolchain_path)
29+
- flags += '-tools-directory %s/bin' % (android_toolchain_path)
30+
+ flags += '-tools-directory %s/bin ' % (android_toolchain_path)
31+
+ flags += '-Xclang-linker -Wl,-z,max-page-size=16384'
32+
return flags
33+
34+
def cmake_options(self, args):

0 commit comments

Comments
 (0)