From 6d0cc9cc9ac2feb617a4e091c8faf597508af340 Mon Sep 17 00:00:00 2001 From: KLCLAU Date: Mon, 31 Aug 2026 20:58:54 -0400 Subject: [PATCH] build(android): 16 KB ELF page alignment for all bundled .so Android 15+ boots a 16 KB-page kernel and Google Play requires 16 KB compatibility for updates since Nov 2025. On a 16 KB device a 4 KB-aligned .so fails to load; on the ones still running a 4 KB kernel (e.g. current Galaxy S26) the installer shows a 'this app isn't 16 KB compatible / ELF alignment check failed' warning listing every bundled library. libmain.so and the vcpkg/FetchContent .so already inherit the NDK default, but the two out-of-tree builds do not: - DXVK (meson cross build): add -Wl,-z,max-page-size=16384 to c_link_args / cpp_link_args in meson-arm64-android-cross.ini.in. - libadrenotools + hooks (standalone CMake): add the same via CMAKE_SHARED_LINKER_FLAGS in build-adrenotools.sh. - Also pin it on the android-vulkan preset (CMAKE_SHARED/EXE_LINKER_FLAGS) so libmain.so / libSDL3 / libopenal / libgamespy are aligned regardless of NDK default. After this, readelf -l on every .so in the APK reports p_align 0x4000 and the install-time warning is gone (verified on a Galaxy S26+). Co-Authored-By: Claude Sonnet 5 --- CMakePresets.json | 2 ++ cmake/meson-arm64-android-cross.ini.in | 7 +++++-- scripts/build/android/build-adrenotools.sh | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index bff1ea339..1fd359818 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -295,6 +295,8 @@ "ANDROID_ABI": "arm64-v8a", "ANDROID_PLATFORM": "android-29", "ANDROID_STL": "c++_shared", + "CMAKE_SHARED_LINKER_FLAGS": "-Wl,-z,max-page-size=16384 -Wl,-z,common-page-size=16384", + "CMAKE_EXE_LINKER_FLAGS": "-Wl,-z,max-page-size=16384 -Wl,-z,common-page-size=16384", "SAGE_USE_DX8": "OFF", "SAGE_USE_SDL3": "ON", "SAGE_USE_OPENAL": "ON", diff --git a/cmake/meson-arm64-android-cross.ini.in b/cmake/meson-arm64-android-cross.ini.in index 28d75895e..cbf4983aa 100644 --- a/cmake/meson-arm64-android-cross.ini.in +++ b/cmake/meson-arm64-android-cross.ini.in @@ -31,5 +31,8 @@ endian = 'little' [built-in options] c_args = [] cpp_args = [] -c_link_args = [] -cpp_link_args = [] +# 16 KB ELF page alignment. Android 15+ ships (and Google Play requires, since +# Nov 2025) a 16 KB-page kernel; a 4 KB-aligned .so triggers a system "not +# 16 KB compatible" warning on install and fails to load on a real 16 KB device. +c_link_args = ['-Wl,-z,max-page-size=16384', '-Wl,-z,common-page-size=16384'] +cpp_link_args = ['-Wl,-z,max-page-size=16384', '-Wl,-z,common-page-size=16384'] diff --git a/scripts/build/android/build-adrenotools.sh b/scripts/build/android/build-adrenotools.sh index d1ef6ad38..6b85bf910 100755 --- a/scripts/build/android/build-adrenotools.sh +++ b/scripts/build/android/build-adrenotools.sh @@ -43,6 +43,7 @@ cmake -S "${SRC_DIR}" -B "${BUILD_DIR}" -G Ninja \ -DANDROID_ABI=arm64-v8a \ -DANDROID_PLATFORM="android-${ANDROID_PLATFORM}" \ -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_SHARED_LINKER_FLAGS="-Wl,-z,max-page-size=16384 -Wl,-z,common-page-size=16384" \ -DBUILD_SHARED_LIBS=ON echo "==> Building"