From f65348cfbea4a1b0f0b36646ff7b4c9edd4a3bb4 Mon Sep 17 00:00:00 2001 From: Tao Sang Date: Tue, 2 Mar 2021 17:23:36 -0500 Subject: [PATCH] SWDEV-274915 - Prevent repeatedly linking dependence Some upstream will load hip multiple times thus Rocclr static lib will be linked to hip::amdhip64 many times. This will bring some unexpected issues such as in hipBLAS. The patch prevents his happening. Change-Id: I6bb27659f74371dae6e59c59fd6bb2022cc062ff --- hipamd/hip-config.cmake.in | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hipamd/hip-config.cmake.in b/hipamd/hip-config.cmake.in index 3f4ef7e0fb..cbb4ffe79a 100644 --- a/hipamd/hip-config.cmake.in +++ b/hipamd/hip-config.cmake.in @@ -176,7 +176,11 @@ if(HIP_RUNTIME MATCHES "rocclr") message(STATUS "hip::amdhip64 is ${amdhip64_type}") if(${amdhip64_type} STREQUAL "STATIC_LIBRARY") # For cyclic dependence - target_link_libraries(amdrocclr_static INTERFACE hip::amdhip64) + get_target_property(link_interf_libs amdrocclr_static LINK_INTERFACE_LIBRARIES) + if(NOT "${link_interf_libs}" MATCHES "hip\:\:amdhip64") + # Prevent repeatedly linking dependence + target_link_libraries(amdrocclr_static INTERFACE hip::amdhip64) + endif() endif() if(NOT WIN32)