Skip to content

ADFA-1431 16kb page alignment#864

Closed
hal-eisen-adfa wants to merge 2 commits into
stagefrom
ADFA-1431-Fix-16kB-page-alignment
Closed

ADFA-1431 16kb page alignment#864
hal-eisen-adfa wants to merge 2 commits into
stagefrom
ADFA-1431-Fix-16kB-page-alignment

Conversation

@hal-eisen-adfa

Copy link
Copy Markdown
Collaborator

ndk was already at v28 so this is mainly adding the CMake build flags

libandroid-tree-sitter.so comes from external dependency com.itsaky.androidide.treesitter:android-tree-sitter:4.3.1. This requires an update from the dependency maintainer. Document this limitation.

libdt_socket.so, libjdwp.so, libnpt.so may come from Android runtime or external sources. If they're pre-built, they'll need to be rebuilt with alignment flags or updated.

@coderabbitai

coderabbitai Bot commented Jan 21, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Release Notes: 16 KB Page Alignment Support

Overview

  • Added CMake and Android.mk build flags to enforce 16 KB page alignment across native libraries

Changes Made

  • llama-impl: Added -Wl,-z,max-page-size=16384 linker flag to CMakeLists.txt
  • shizuku-manager: Added -Wl,-z,max-page-size=16384 to both Debug and Release builds for libshizuku.so and adb targets
  • termux-emulator: Added -Wl,-z,max-page-size=16384 to Android.mk LOCAL_LDFLAGS
  • termux-shared: Added -Wl,-z,max-page-size=16384 to Android.mk LOCAL_LDFLAGS for local-socket module
  • app/build.gradle.kts: Added documentation comments regarding native library compression and page alignment considerations

⚠️ Known Risks & Limitations

  • External Dependency: libandroid-tree-sitter.so (from com.itsaky.androidide.treesitter:android-tree-sitter:4.3.1) is not yet updated by the dependency maintainer to support 16 KB alignment. Action required: Dependency maintainer must update the artifact.

  • Pre-built System Libraries: libdt_socket.so, libjdwp.so, and libnpt.so (from Android runtime or external sources) may require rebuilding with alignment flags or replacement to meet the 16 KB page alignment requirement if sourced as pre-built artifacts.

  • Incomplete Alignment: The application may not be fully 16 KB page aligned until external dependencies and pre-built libraries are updated/rebuilt. Testing on target Android versions is recommended.

Walkthrough

The changes add -Wl,-z,max-page-size=16384 linker options and supporting documentation comments across multiple build configuration files (CMake, Android NDK, and Gradle) to enforce 16 KB maximum page size alignment for native libraries in the project.

Changes

Cohort / File(s) Summary
Gradle build script documentation
app/build.gradle.kts, termux/termux-emulator/build.gradle.kts, termux/termux-shared/build.gradle.kts
Added multi-line comments documenting linker flag behavior and 16 KB page alignment considerations for native dependencies
CMake linker configuration
llama-impl/src/main/cpp/CMakeLists.txt, subprojects/shizuku-manager/src/main/jni/CMakeLists.txt
Added target_link_options with -Wl,-z,max-page-size=16384 flag for shared library targets in Release and Debug builds
Android.mk linker configuration
termux/termux-emulator/src/main/jni/Android.mk, termux/termux-shared/src/main/cpp/Android.mk
Added LOCAL_LDFLAGS with -Wl,-z,max-page-size=16384 flag to linker configuration

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Behold the linker flags so neat,
Page alignment, sixteen KB sweet,
Across each config, docs so clear,
Native libraries aligned, no fear!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'ADFA-1431 16kb page alignment' clearly summarizes the main change across all modified files, which consistently add 16 KB page alignment flags to CMake and build configurations.
Description check ✅ Passed The description directly relates to the changeset, explaining the rationale (NDK v28 and CMake flags), and documenting dependencies and limitations regarding library compatibility with the alignment requirement.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@hal-eisen-adfa

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jan 21, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@hal-eisen-adfa hal-eisen-adfa requested a review from a team January 21, 2026 02:22
@itsaky-adfa

itsaky-adfa commented Jan 22, 2026

Copy link
Copy Markdown
Contributor

@hal-eisen-adfa The documentation mentions that Android NDK r28 and higher automatically handle this and changes to build scripts should not be required.

NDK version r28 and higher compile 16 KB-aligned by default.

I recently published v4.3.2 of the android-tree-sitter library which was compiled with 16-KB page size support. We need to upgrade sora-editor (to v0.24.4) and android-tree-sitter dependencies for that to take effect (see ADFA-2376).

Also, libdt_socket.so, libjdwp.so, libnpt.so are no longer included in Code On the Go APKs.

@hal-eisen-adfa

Copy link
Copy Markdown
Collaborator Author

Actually, we don't need this. All 4kb libraries have either been removed or updated.

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.

3 participants