Skip to content

Conversation

@ssk18
Copy link

@ssk18 ssk18 commented Nov 11, 2025

Add linker flags and build configuration to support Android devices
using 16KB page sizes. This ensures compatibility with Android 15+
devices while maintaining backward compatibility with 4KB page systems.

Changes:

  • CMakeLists.txt: Add -Wl,-z,max-page-size=16384 linker flag for
    Android shared and executable targets
  • cmake/ext_java.cmake: Configure JNI library with 16KB page alignment
  • tools/build.py: Enable ANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES flag
  • java/build-android.gradle: Add NDK ABI filters and CMake arguments
  • java/src/test/android/app/build.gradle: Configure test app for 16KB

Technical details:

  • All LOAD segments now align to 0x4000 (16384 bytes)
  • Applied to libonnxruntime_extensions4j_jni.so and libortextensions.so

Testing:

  • Built AAR for arm64-v8a architecture
  • Verified LOAD segment alignment using NDK's llvm-readelf
  • Confirmed both native libraries use 16KB page alignment"

@ssk18 ssk18 requested a review from a team as a code owner November 11, 2025 22:20
  enable 16KB page size compatibility for Android 15+ devices.

  - Apply -Wl,-z,max-page-size=16384 linker flag to all Android targets
  - Modernize to target_link_options() for better maintainability
  - Add Clang/GNU compiler check before applying flags
  - Configure Gradle with -DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON
  - Support all ABIs: arm64-v8a, armeabi-v7a, x86_64, x86
@ssk18
Copy link
Author

ssk18 commented Nov 11, 2025

@microsoft-github-policy-service agree

@sayanshaw24
Copy link
Collaborator

/azp run extensions.ci

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

  - Add README section explaining ANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES option
  - Add GitHub workflow to verify 16KB alignment on arm64-v8a builds
@ssk18 ssk18 requested a review from edgchen1 November 12, 2025 01:49
@@ -0,0 +1,127 @@
name: Android 16KB Page Size Verification
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sayanshaw24 is it ok to add a new workflow for this check? or would it be preferable to add it to the existing CI build pipeline?

@ssk18 ssk18 requested a review from edgchen1 November 12, 2025 19:47
@edgchen1 edgchen1 requested a review from sayanshaw24 November 13, 2025 03:40
@ssk18 ssk18 requested a review from edgchen1 November 13, 2025 14:18
@ssk18
Copy link
Author

ssk18 commented Nov 14, 2025

@edgchen1 is it a pre existing issue in tokenizer that's causing the workflow failure?

@edgchen1
Copy link
Contributor

@edgchen1 is it a pre existing issue in tokenizer that's causing the workflow failure?

hm, it looks unrelated to the changes in this PR. are you able to reproduce it locally? looks like tokenizer_common.h is missing an #include <unordered_map>

@ssk18
Copy link
Author

ssk18 commented Nov 14, 2025

@edgchen1 Locally, I am able to create a shared library without any issue and, i am using NDK 26.1 but in a workflow it is NDK r25c. Not sure, if that is causing the failure. If you agree, I can add "#include <unordered_map>" and see if it works.

@edgchen1
Copy link
Contributor

If you agree, I can add "#include <unordered_map>" and see if it works.

sure, I think it's good to add it anyway. the tokenizer_common.h header should be able to be included independently.

@ssk18 ssk18 requested a review from edgchen1 November 14, 2025 22:45
@edgchen1
Copy link
Contributor

/azp run onnxruntime-extensions.CI

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ssk18
Copy link
Author

ssk18 commented Nov 15, 2025

so, libonnxruntime_extensions4j_jni.so and libortextensions.so passes as expected but CI workflow is checking all other libraries as well. Removed checks for other shared libraries.

@edgchen1
Copy link
Contributor

/azp run onnxruntime-extensions.CI

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ssk18
Copy link
Author

ssk18 commented Nov 17, 2025

@edgchen1 these CI failures look unrelated to this change.

@edgchen1
Copy link
Contributor

@edgchen1 these CI failures look unrelated to this change.

they are not related to this change. we'll need to look into it.

@JR-05
Copy link

JR-05 commented Nov 19, 2025

I urgently need to solve this problem when 16kb support will be available.

@edgchen1
Copy link
Contributor

/azp run onnxruntime-extensions.CI

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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.

4 participants