Skip to content

Commit 66e4516

Browse files
committed
Apply patches for 16KB page size for swiftlang/swift#81596
1 parent 4ed1375 commit 66e4516

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

swift-ci/sdks/android/patches/apply-patches.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
patches_dir=$(dirname $(realpath -- "${BASH_SOURCE[0]}"))
44
cd ${1}
55

6+
# https://github.com/swiftlang/swift/pull/81596
7+
git apply -v -C1 ${patches_dir}/page-size-16KB-81398-AddSwiftStdlib.patch
8+
git apply -v -C1 ${patches_dir}/page-size-16KB-81398-targets.patch
9+
610
case "${BUILD_SCHEME}" in
711
swift-*-branch)
812
git apply -v -C1 ${patches_dir}/swift-android.patch
@@ -20,3 +24,4 @@ esac
2024

2125
# disable backtrace() for Android (needs either API33+ or libandroid-execinfo, or to manually add in backtrace backport)
2226
perl -pi -e 's;os\(Android\);os\(AndroidDISABLED\);g' swift-testing/Sources/Testing/SourceAttribution/Backtrace.swift
27+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
From 8db43c6290ee04145264c04728a030dd74f87452 Mon Sep 17 00:00:00 2001
2+
From: Marc Prud'hommeaux <[email protected]>
3+
Date: Sun, 18 May 2025 19:10:36 -0400
4+
Subject: [PATCH] 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+
stdlib/cmake/modules/AddSwiftStdlib.cmake | 2 ++
9+
1 file changed, 2 insertions(+)
10+
11+
diff --git a/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake b/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake
12+
index ce113989ad75d..089f5f30acbb5 100644
13+
--- a/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake
14+
+++ b/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake
15+
@@ -2469,6 +2469,8 @@ function(add_swift_target_library name)
16+
list(APPEND swiftlib_link_flags_all "-shared")
17+
# TODO: Instead of `lib${name}.so` find variable or target property which already have this value.
18+
list(APPEND swiftlib_link_flags_all "-Wl,-soname,lib${name}.so")
19+
+ # Ensure compatibility with Android 15+ devices using 16KB memory pages.
20+
+ list(APPEND swiftlib_link_flags_all "-Wl,-z,max-page-size=16384")
21+
endif()
22+
23+
if (SWIFTLIB_BACK_DEPLOYMENT_LIBRARY)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/swift/utils/swift_build_support/swift_build_support/targets.py b/swift/utils/swift_build_support/swift_build_support/targets.py
2+
index fba09416ddb..3fbc51955f4 100644
3+
--- a/swift/utils/swift_build_support/swift_build_support/targets.py
4+
+++ b/swift/utils/swift_build_support/swift_build_support/targets.py
5+
@@ -165,6 +165,7 @@ class AndroidPlatform(Platform):
6+
7+
flags += '-sdk %s/sysroot ' % (android_toolchain_path)
8+
flags += '-tools-directory %s/bin' % (android_toolchain_path)
9+
+ flags += '--Xclang-linker -Wl,-z,max-page-size=16384'
10+
return flags
11+
12+
def cmake_options(self, args):
13+

0 commit comments

Comments
 (0)