Skip to content

Android: link every native library for 16 KB pages (#41) - #70

Merged
schindlershadow merged 1 commit into
mainfrom
android-16k-align
Nov 16, 2026
Merged

schindlershadow merged 1 commit into
mainfrom
android-16k-align

Conversation

@schindlershadow

Copy link
Copy Markdown
Owner

Every native library in the Android APK is now linked for 16 KB pages.

libSDL2.so, the four adrenotools hook libraries and a libmain.so linked on a PC had 4 KB LOAD alignment. NDK r27 only links with -z max-page-size=16384 when ANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES is on (the default from r28), so it is now turned on for the dependency builds (android/build_deps.py), the core's toolchain file and the game's (android_build.py write_toolchain). The on-device zig link already passed the flag, and r27c's libc++_shared.so is already aligned. apk_pack.py now warns about any lib/*.so aligned below 16 KB; docs/android.md notes it.

Tested:

  • Rebuilt deps: all five .so at 0x4000; a libmain.so linked through the new toolchain file: 0x4000; the Android core still compiles with -D__BIONIC_NO_PAGE_SIZE_MACRO.
  • Android 15 16 KB page-size emulator (x86_64, arm64 through translation): the current APK dies with SIGSEGV (SEGV_ACCERR) while its libraries load; the 16 KB build loads libSDL2 / libmain, starts SDL and opens the game window.
  • 4 KB device (Shield, Android 11): the new libraries load.
  • Not tested: the Pixel's "isn't 16 KB compatible" dialog itself (device not connected).

Fixes #41

Release notes

  • Android: the game starts on phones that use 16 KB memory pages (newer Android versions), and the "isn't 16 KB compatible" warning is gone.

🤖 Generated with Claude Code

libSDL2.so, the four adrenotools hook libraries and a libmain.so linked on
a PC had 4 KB LOAD alignment, so Android 15+ showed the "isn't 16 KB
compatible" dialog and a 16 KB-page kernel would refuse to load them.
The NDK r27 toolchain links with -z max-page-size=16384 when
ANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES is on (the default only from r28):
turn it on for the dependency builds, the core's and the game's toolchain
files. The on-device zig link already passed the flag; libc++_shared.so
from r27c is already 16 KB aligned.

apk_pack.py now warns about any lib/*.so aligned below 16 KB.

Tested on the Android 15 16 KB page-size emulator image (x86_64, arm64 apps
through translation): the current APK dies with SIGSEGV (SEGV_ACCERR) as its
libraries load; with the 16 KB-aligned libraries libSDL2/libmain load, SDL
starts and the game window opens. On a 4 KB device (Shield, Android 11) the
new libraries load too.

Fixes #41

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schindlershadow
schindlershadow merged commit 2b48eaf into main Nov 16, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android: native libraries are not 16 KB page-size aligned

1 participant