Skip to content

Commit

Permalink
Use 16 KB ELF alignment for shared native libraries (#7897)
Browse files Browse the repository at this point in the history
  • Loading branch information
mannodermaus authored Sep 13, 2024
1 parent e564a45 commit a69ad2f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* None.

### Fixed
* None.
* Use 16 KB ELF packaging for native artifacts produced by `realm-library`, allowing them to be loaded on devices with 16 KB memory page sizes. (Issue [#7894](https://github.com/realm/realm-java/issues/7894))

### Compatibility
* File format: Generates Realms with format v23. Unsynced Realms will be upgraded from Realm Java 2.0 and later. Synced Realms can only be read and upgraded if created with Realm Java v10.0.0-BETA.1.
Expand Down
5 changes: 5 additions & 0 deletions realm/realm-library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ android {
// We did strip with cmake for release build.
// Please, Gradle, you are not that smart! Pleas DO NOT strip debug symbols for debug build!
doNotStrip "*/*/*.so"

// Use compressed shared libraries to support 16 KB ELF alignment
jniLibs {
useLegacyPackaging = true
}
}

lintOptions {
Expand Down
3 changes: 3 additions & 0 deletions realm/realm-library/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ endif()
add_library(realm-jni SHARED ${jni_SRC})
target_link_libraries(realm-jni log android Realm::ObjectStore)

# Use 16 KB ELF alignment to support devices with page size greater than 4 KB
target_link_options(realm-jni PRIVATE "-Wl,-z,max-page-size=16384")

# Strip the release so files and backup the unstripped versions
if (buildTypeCap STREQUAL "Release")
set(unstripped_SO_DIR
Expand Down

0 comments on commit a69ad2f

Please sign in to comment.