-
Notifications
You must be signed in to change notification settings - Fork 122
Add Android 16KB page size support for ONNX Runtime Extensions #1007
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1568b7f
280ffab
88a80d2
8e8698d
addf59e
d21e703
51b1a75
cf22e8f
51c9a1e
10b411a
f378a3a
73dd655
5253244
413fa53
ef29598
41a1f98
b665df4
9b31d4d
96a7194
ddbd151
ea3b171
a087d1c
ab09f98
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,124 @@ | ||||||||||
| name: Android 16KB Page Size Verification | ||||||||||
|
|
||||||||||
| on: | ||||||||||
| pull_request: | ||||||||||
| paths: | ||||||||||
| - 'CMakeLists.txt' | ||||||||||
| - 'cmake/**' | ||||||||||
| - 'java/**' | ||||||||||
| - 'tools/build.py' | ||||||||||
| - '.github/workflows/android-16kb-check.yml' | ||||||||||
|
|
||||||||||
| jobs: | ||||||||||
| verify-android-16kb-alignment: | ||||||||||
| name: Build & Verify 16KB Page Alignment (arm64-v8a) | ||||||||||
| runs-on: ubuntu-latest | ||||||||||
|
|
||||||||||
| steps: | ||||||||||
| - name: Checkout repository | ||||||||||
| uses: actions/checkout@v4 | ||||||||||
|
|
||||||||||
| - name: Set up Python | ||||||||||
| uses: actions/setup-python@v5 | ||||||||||
| with: | ||||||||||
| python-version: '3.10' | ||||||||||
|
|
||||||||||
| - name: Set up JDK 17 | ||||||||||
| uses: actions/setup-java@v4 | ||||||||||
| with: | ||||||||||
| distribution: 'temurin' | ||||||||||
| java-version: '17' | ||||||||||
|
|
||||||||||
| - name: Setup Android NDK | ||||||||||
| uses: nttld/setup-ndk@v1 | ||||||||||
| id: setup-ndk | ||||||||||
| with: | ||||||||||
| ndk-version: r25c | ||||||||||
| add-to-path: false | ||||||||||
|
|
||||||||||
| - name: Set up Android SDK | ||||||||||
| uses: android-actions/setup-android@v3 | ||||||||||
|
|
||||||||||
| - name: Build Android arm64-v8a with 16KB support | ||||||||||
| env: | ||||||||||
| ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} | ||||||||||
| run: | | ||||||||||
| set -e | ||||||||||
|
|
||||||||||
| # Use the project's build script | ||||||||||
| python tools/build.py \ | ||||||||||
| --android \ | ||||||||||
| --android_abi=arm64-v8a \ | ||||||||||
| --android_api=27 \ | ||||||||||
| --android_home=$ANDROID_HOME \ | ||||||||||
| --android_ndk_path=$ANDROID_NDK_HOME \ | ||||||||||
| --config=Release \ | ||||||||||
| --update \ | ||||||||||
| --parallel \ | ||||||||||
| --build | ||||||||||
|
|
||||||||||
| - name: Verify 16KB page alignment | ||||||||||
| env: | ||||||||||
| ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} | ||||||||||
| run: | | ||||||||||
| set -e | ||||||||||
|
|
||||||||||
| echo "=== Verifying 16KB page size alignment ===" | ||||||||||
|
|
||||||||||
| # Find android built libraries | ||||||||||
| LIBS=$(find build/Android/Release/lib -name "libortextensions.so" -o -name "libonnxruntime_extensions4j_jni.so") | ||||||||||
|
Comment on lines
+68
to
+69
|
||||||||||
| # Find android built libraries | |
| LIBS=$(find build/Android/Release/lib -name "libortextensions.so" -o -name "libonnxruntime_extensions4j_jni.so") | |
| # Find android built libraries (search recursively under build/Android, limited to lib directories) | |
| LIBS=$(find build/Android -type f -path "*/lib/*" \( -name "libortextensions.so" -o -name "libonnxruntime_extensions4j_jni.so" \)) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -218,6 +218,18 @@ if(OCOS_BUILD_ANDROID) | |
| endif() | ||
|
|
||
| set(OCOS_BUILD_JAVA ON CACHE INTERNAL "") | ||
|
|
||
| # Add 16KB page size compatibility for Android 15+ devices. | ||
| # See: https://developer.android.com/guide/practices/page-sizes | ||
| # This flag ensures binaries work on both 4KB and 16KB page size systems. | ||
| # Requires Android NDK r23 or newer because -Wl,-z,max-page-size=16384 was | ||
| # introduced in NDK r23. Ensure all build tooling (CMake, Gradle, CI) uses | ||
| # an NDK >= r23. | ||
| if(DEFINED ANDROID_NDK_MAJOR AND ANDROID_NDK_MAJOR LESS 23) | ||
| message(FATAL_ERROR "Android NDK r23 or newer is required to build with 16KB page size support. Detected ANDROID_NDK_MAJOR=${ANDROID_NDK_MAJOR}") | ||
| endif() | ||
| add_link_options(-Wl,-z,max-page-size=16384) | ||
| message(STATUS "Android build: 16KB page size support enabled") | ||
|
Comment on lines
+231
to
+232
|
||
| endif() | ||
|
|
||
| # Build the libraries with -fPIC | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.