Skip to content

Commit

Permalink
fix: add missed extra link flags to support to enable 16K page size f… (
Browse files Browse the repository at this point in the history
#2143)

…or android
  • Loading branch information
peilinok authored and guoxianzhe committed Dec 17, 2024
1 parent 7bd2893 commit 43df691
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion android/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,20 @@ target_link_libraries(${LIBRARY_NAME}
)

# Support Android 15 16k page size
target_link_options(${LIBRARY_NAME} PRIVATE "-Wl,-z,max-page-size=16384")
if (${ANDROID_ABI} STREQUAL "arm64-v8a" OR ${ANDROID_ABI} STREQUAL "x86_64")
target_link_options(${LIBRARY_NAME} PRIVATE "-Wl,-z,max-page-size=16384")

# https://github.com/llvm/llvm-project/pull/66042
# the default linker is llvm lld since ndk r22, and gnu ld is used before ndk r22
# so we need to add extra flags for 16K when ANDROID_NDK_MAJOR less than 22 and the linker is not lld
# coz the ld linker need to set common-page-size=16384 to align all sections to 16K page size
if(ANDROID_NDK_MAJOR LESS 22 AND NOT CMAKE_SHARED_LINKER_FLAGS MATCHES "-fuse-ld=lld" AND NOT CMAKE_MODULE_LINKER_FLAGS MATCHES "-fuse-ld=lld" AND NOT CMAKE_EXE_LINKER_FLAGS MATCHES "-fuse-ld=lld")
message(STATUS "ndk version is ${ANDROID_NDK_MAJOR} and use ld linker, add -Wl,-z,common-page-size=16384")
set_target_properties(${LIBRARY_NAME} PROPERTIES
LINK_FLAGS "-Wl,-z,common-page-size=16384"
)
endif()
endif()

set(THIRD_PARTY_INCLUDE_DIRS
"${CMAKE_CURRENT_SOURCE_DIR}/third_party/include/iris"
Expand Down

0 comments on commit 43df691

Please sign in to comment.