Fix square build failure with static lib in Jenkin

When libamdhip64_static.a is built by Jenkin, sample square cannot been
built successfully because libamdhip64_static.a is archiveved in thin
mode. Thus in the patch it will be archiveved in full mode. Meanwhile
libamdhip64_static_temp.a will be useless and thus removed.

Change-Id: Ifd3882598ef0dc5e7af8db0e389e786025ceb455


[ROCm/clr commit: 51b6c1856c]
Этот коммит содержится в:
Tao Sang
2020-05-18 16:17:34 -04:00
коммит произвёл Tao Sang
родитель 9d76c76746
Коммит 5519100f79
+5 -16
Просмотреть файл
@@ -203,17 +203,6 @@ set_target_properties(hip64 PROPERTIES PUBLIC_HEADER ${PROF_API_STR})
set_target_properties(amdhip64 PROPERTIES PUBLIC_HEADER ${PROF_API_STR})
set_target_properties(amdhip64_static PROPERTIES PUBLIC_HEADER ${PROF_API_STR})
# We expect amdhip64_static to contain objects of rocclr and hip. But linker
# let amdhip64_static contain objects of hip only. So we will use a
# a custom amdhip64_static_combiner to combine objects of vid and hip into
# amdhip64_static. To avoid amdhip64_static contains itself,
# amdhip64_static_temp is created internally.
add_library(amdhip64_static_temp STATIC
$<TARGET_OBJECTS:hip64>
)
add_library(host INTERFACE)
target_link_libraries(host INTERFACE amdhip64)
add_library(device INTERFACE)
@@ -225,19 +214,19 @@ target_link_libraries(device INTERFACE host)
# filename.
target_link_libraries(amdhip64 PRIVATE amdrocclr_static Threads::Threads dl)
target_link_libraries(amdhip64_static PRIVATE Threads::Threads dl)
target_link_libraries(amdhip64_static_temp PRIVATE Threads::Threads dl)
# combine objects of vid and hip into amdhip64_static
add_custom_target(
amdhip64_static_combiner
ALL
COMMAND rm -f $<TARGET_FILE:amdhip64_static> # Must remove old one, otherwise the new one will contain obsolete stuff
COMMAND ${CMAKE_AR} -rcsT $<TARGET_FILE:amdhip64_static> $<TARGET_FILE:amdhip64_static_temp> $<TARGET_FILE:amdrocclr_static>
DEPENDS amdhip64_static amdhip64_static_temp amdrocclr_static # To make sure this is the last step
COMMAND rm -rf static_lib_temp && mkdir static_lib_temp && cd static_lib_temp # Create temp folder to contain *.o
COMMAND ${CMAKE_AR} -x $<TARGET_FILE:amdrocclr_static> # Extract *.o from amdrocclr_static
COMMAND ${CMAKE_AR} -rcs $<TARGET_FILE:amdhip64_static> *.o # Append *.o to amdhip64_static
COMMAND cd .. && rm -rf static_lib_temp # Remove temp folder
DEPENDS amdhip64_static amdrocclr_static # To make sure this is the last step
COMMENT "Combining static libs into amdhip64_static"
)
INSTALL(PROGRAMS $<TARGET_FILE:amdhip64_static> DESTINATION lib COMPONENT MAIN)
INSTALL(PROGRAMS $<TARGET_FILE:amdhip64> DESTINATION lib COMPONENT MAIN)
INSTALL(CODE "execute_process( COMMAND ${CMAKE_COMMAND} -E create_symlink libamdhip64.so lib/libhip_hcc.so )" DESTINATION lib COMPONENT MAIN)