Skip to content

Commit

Permalink
Try linking shared.so with qnn.so for android
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianlizarraga committed Dec 22, 2024
1 parent cc14971 commit 4c6a985
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
10 changes: 9 additions & 1 deletion cmake/onnxruntime_providers_cpu.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,15 @@ if (NOT onnxruntime_MINIMAL_BUILD AND NOT onnxruntime_EXTENDED_MINIMAL_BUILD
set_property(TARGET onnxruntime_providers_shared APPEND_STRING PROPERTY LINK_FLAGS "-Xlinker -exported_symbols_list ${ONNXRUNTIME_ROOT}/core/providers/shared/exported_symbols.lst")
elseif(UNIX)
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
set_property(TARGET onnxruntime_providers_shared APPEND_STRING PROPERTY LINK_FLAGS "-Xlinker --version-script=${ONNXRUNTIME_ROOT}/core/providers/shared/version_script.lds -Xlinker --gc-sections")
target_link_options(onnxruntime_providers_shared PRIVATE
"LINKER:--version-script=${ONNXRUNTIME_ROOT}/core/providers/shared/version_script.lds"
"LINKER:--gc-sections")
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
# Need to link libonnxruntime_providers_<EP>.so with libonnxruntime_providers_shared.so on Android
# because dlopen with RTLD_GLOBAL does not bring all symbols to global scope.
# See: https://github.com/android/ndk/issues/201
set(ONNXRUNTIME_PROVIDERS_SHARED onnxruntime_providers_shared)
endif()
endif()
elseif(WIN32)
set_property(TARGET onnxruntime_providers_shared APPEND_STRING PROPERTY LINK_FLAGS "-DEF:${ONNXRUNTIME_ROOT}/core/providers/shared/symbols.def")
Expand Down
18 changes: 4 additions & 14 deletions cmake/onnxruntime_providers_qnn.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,10 @@

# Set linker flags for function(s) exported by EP DLL
if(UNIX)
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
target_link_options(onnxruntime_providers_qnn PRIVATE
"LINKER:--version-script=${ONNXRUNTIME_ROOT}/core/providers/qnn/version_script.lds"
"LINKER:--gc-sections"
"LINKER:-rpath=\$ORIGIN"
"LINKER:-z,undefs"
)
else()
target_link_options(onnxruntime_providers_qnn PRIVATE
"LINKER:--version-script=${ONNXRUNTIME_ROOT}/core/providers/qnn/version_script.lds"
"LINKER:--gc-sections"
"LINKER:-rpath=\$ORIGIN"
)
endif()
target_link_options(onnxruntime_providers_qnn PRIVATE
"LINKER:--version-script=${ONNXRUNTIME_ROOT}/core/providers/qnn/version_script.lds"
"LINKER:--gc-sections"
"LINKER:-rpath=\$ORIGIN")
elseif(WIN32)
set_property(TARGET onnxruntime_providers_qnn APPEND_STRING PROPERTY LINK_FLAGS "-DEF:${ONNXRUNTIME_ROOT}/core/providers/qnn/symbols.def")
else()
Expand Down

0 comments on commit 4c6a985

Please sign in to comment.