Support 16 KB page sizes on Android (#81596)

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
This commit is contained in:
Marc Prud'hommeaux
2025-07-29 17:12:22 +02:00
committed by Finagolfin
parent 5cc6f245d0
commit 7f09af24cf
2 changed files with 4 additions and 1 deletions

View File

@@ -2504,6 +2504,8 @@ function(add_swift_target_library name)
list(APPEND swiftlib_link_flags_all "-shared")
# TODO: Instead of `lib${name}.so` find variable or target property which already have this value.
list(APPEND swiftlib_link_flags_all "-Wl,-soname,lib${name}.so")
# Ensure compatibility with Android 15+ devices using 16KB memory pages.
list(APPEND swiftlib_link_flags_all "-Wl,-z,max-page-size=16384")
endif()
if (SWIFTLIB_BACK_DEPLOYMENT_LIBRARY)

View File

@@ -164,7 +164,8 @@ class AndroidPlatform(Platform):
android_toolchain_path = self.ndk_toolchain_path(args)
flags += '-sdk %s/sysroot ' % (android_toolchain_path)
flags += '-tools-directory %s/bin' % (android_toolchain_path)
flags += '-tools-directory %s/bin ' % (android_toolchain_path)
flags += '-Xclang-linker -Wl,-z,max-page-size=16384'
return flags
def cmake_options(self, args):