From 863ff04c65713f8043e5e4979970206be7db60c3 Mon Sep 17 00:00:00 2001 From: adrianlizarraga Date: Wed, 18 Dec 2024 20:56:17 -0800 Subject: [PATCH] Use -z undefs on android --- cmake/onnxruntime_providers_qnn.cmake | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/cmake/onnxruntime_providers_qnn.cmake b/cmake/onnxruntime_providers_qnn.cmake index 6eb547927073b..505c357d516d0 100644 --- a/cmake/onnxruntime_providers_qnn.cmake +++ b/cmake/onnxruntime_providers_qnn.cmake @@ -29,15 +29,20 @@ # Set linker flags for function(s) exported by EP DLL if(UNIX) - string(CONCAT ONNXRUNTIME_PROVIDERS_QNN_LINK_FLAGS - "-Xlinker --version-script=${ONNXRUNTIME_ROOT}/core/providers/qnn/version_script.lds " - "-Xlinker --gc-sections -Xlinker -rpath=\\$ORIGIN") if(CMAKE_SYSTEM_NAME STREQUAL "Android") - string(CONCAT ONNXRUNTIME_PROVIDERS_QNN_LINK_FLAGS - "${ONNXRUNTIME_PROVIDERS_QNN_LINK_FLAGS} " - "-Xlinker --allow-shlib-undefined") # Allow undefined global symbols (e.g., Provider_GetHost) in shared library + 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() - set_property(TARGET onnxruntime_providers_qnn APPEND_STRING PROPERTY LINK_FLAGS "${ONNXRUNTIME_PROVIDERS_QNN_LINK_FLAGS}") elseif(WIN32) set_property(TARGET onnxruntime_providers_qnn APPEND_STRING PROPERTY LINK_FLAGS "-DEF:${ONNXRUNTIME_ROOT}/core/providers/qnn/symbols.def") else()