diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f1ac60ccb..3201ea0368 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,6 +84,10 @@ set(ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}") set(LIB_DIR "${ROOT_DIR}/src") set(TEST_DIR "${ROOT_DIR}/test") +# To set additional RUNPATH in libraries +# installed in /opt/rocm-ver/lib/roctracer +set(ROCM_APPEND_PRIVLIB_RPATH "$ORIGIN/..") + find_package( amd_comgr REQUIRED CONFIG HINTS ${CMAKE_INSTALL_PREFIX} @@ -233,24 +237,6 @@ install( DESTINATION ${CMAKE_INSTALL_LIBDIR}/${ROCPROFILER_NAME} COMPONENT runtime) -# librocprof-tool.so -install( - FILES ${PROJECT_BINARY_DIR}/test/librocprof-tool.so - DESTINATION ${CMAKE_INSTALL_LIBDIR}/${ROCPROFILER_NAME} - COMPONENT runtime) - -install( - FILES ${PROJECT_BINARY_DIR}/test/librocprof-tool.so - DESTINATION ${CMAKE_INSTALL_LIBDIR}/${ROCPROFILER_NAME} - COMPONENT asan) - -install( - FILES ${PROJECT_BINARY_DIR}/test/rocprof-ctrl - DESTINATION ${CMAKE_INSTALL_LIBDIR}/${ROCPROFILER_NAME} - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ - WORLD_EXECUTE - COMPONENT runtime) - # File reorg backward compatibility for non ASAN packaging if(NOT ENABLE_ASAN_PACKAGING) # File reorg Backward compatibility diff --git a/plugin/att/CMakeLists.txt b/plugin/att/CMakeLists.txt index 4384bb93eb..bbac725438 100644 --- a/plugin/att/CMakeLists.txt +++ b/plugin/att/CMakeLists.txt @@ -33,7 +33,8 @@ set_target_properties( att_plugin PROPERTIES CXX_VISIBILITY_PRESET hidden LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../exportmap - LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib/rocprofiler) + LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib/rocprofiler + INSTALL_RPATH "${ROCM_APPEND_PRIVLIB_RPATH}") target_compile_definitions(att_plugin PRIVATE HIP_PROF_HIP_API_STRING=1 __HIP_PLATFORM_HCC__=1) diff --git a/plugin/cli/CMakeLists.txt b/plugin/cli/CMakeLists.txt index 2090c8a952..2eb2796d2f 100644 --- a/plugin/cli/CMakeLists.txt +++ b/plugin/cli/CMakeLists.txt @@ -29,7 +29,8 @@ set_target_properties( cli_plugin PROPERTIES CXX_VISIBILITY_PRESET hidden LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../exportmap - LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib/rocprofiler) + LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib/rocprofiler + INSTALL_RPATH "${ROCM_APPEND_PRIVLIB_RPATH}") target_compile_definitions(cli_plugin PRIVATE HIP_PROF_HIP_API_STRING=1 __HIP_PLATFORM_HCC__=1) diff --git a/plugin/ctf/CMakeLists.txt b/plugin/ctf/CMakeLists.txt index 9cab0cb143..62898aafba 100644 --- a/plugin/ctf/CMakeLists.txt +++ b/plugin/ctf/CMakeLists.txt @@ -36,7 +36,8 @@ set_target_properties( ctf_plugin PROPERTIES CXX_VISIBILITY_PRESET hidden LINK_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/../exportmap" - LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib/rocprofiler") + LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib/rocprofiler" + INSTALL_RPATH "${ROCM_APPEND_PRIVLIB_RPATH}") set(METADATA_STREAM_FILE_DIR "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/plugin/ctf") target_compile_definitions( ctf_plugin diff --git a/plugin/file/CMakeLists.txt b/plugin/file/CMakeLists.txt index 2eb52c6fa4..e683073475 100644 --- a/plugin/file/CMakeLists.txt +++ b/plugin/file/CMakeLists.txt @@ -29,7 +29,8 @@ set_target_properties( file_plugin PROPERTIES CXX_VISIBILITY_PRESET hidden LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../exportmap - LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib/rocprofiler) + LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib/rocprofiler + INSTALL_RPATH "${ROCM_APPEND_PRIVLIB_RPATH}") target_compile_definitions(file_plugin PRIVATE HIP_PROF_HIP_API_STRING=1 __HIP_PLATFORM_HCC__=1) diff --git a/plugin/perfetto/CMakeLists.txt b/plugin/perfetto/CMakeLists.txt index 55f95f5549..39156df88b 100644 --- a/plugin/perfetto/CMakeLists.txt +++ b/plugin/perfetto/CMakeLists.txt @@ -7,7 +7,8 @@ set_target_properties( perfetto_plugin PROPERTIES CXX_VISIBILITY_PRESET hidden LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../exportmap - LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib/rocprofiler) + LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib/rocprofiler + INSTALL_RPATH "${ROCM_APPEND_PRIVLIB_RPATH}") target_compile_definitions(perfetto_plugin PRIVATE HIP_PROF_HIP_API_STRING=1 __HIP_PLATFORM_HCC__=1) diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt index e763a5611b..ceb3a43bc0 100644 --- a/src/tools/CMakeLists.txt +++ b/src/tools/CMakeLists.txt @@ -16,7 +16,8 @@ set_target_properties( rocprofiler_tool PROPERTIES CXX_VISIBILITY_PRESET hidden LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/rocprofiler - LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/exportmap) + LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/exportmap + INSTALL_RPATH "${ROCM_APPEND_PRIVLIB_RPATH}") target_include_directories( rocprofiler_tool PRIVATE ${PROJECT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} @@ -70,7 +71,8 @@ add_subdirectory(rocprofv2) add_executable(ctrl ctrl.cpp) set_target_properties(ctrl PROPERTIES RUNTIME_OUTPUT_DIRECTORY - ${CMAKE_BINARY_DIR}/libexec/rocprofiler) + ${CMAKE_BINARY_DIR}/libexec/rocprofiler + INSTALL_RPATH "$ORIGIN/../../${CMAKE_INSTALL_LIBDIR}") target_link_options( rocprofiler_tool PRIVATE -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/exportmap -Wl,--no-undefined) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8a8b4583c2..8f0094e957 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -178,6 +178,8 @@ install( # Building ctrl test executable add_executable(${EXE_NAME} ${CTRL_SRC} ${UTIL_SRC} ${KERN_SRC}) +set_target_properties( ${EXE_NAME} PROPERTIES + INSTALL_RPATH "${ROCM_APPEND_PRIVLIB_RPATH}") target_include_directories(${EXE_NAME} PRIVATE ${TEST_DIR} ${ROOT_DIR} ${PROJECT_SOURCE_DIR}/include) target_link_libraries(${EXE_NAME} hsa-runtime64::hsa-runtime64 hsakmt::hsakmt @@ -190,11 +192,17 @@ install( TARGETS ${EXE_NAME} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/tests-v1/test COMPONENT tests) +install( + TARGETS ${EXE_NAME} + DESTINATION ${CMAKE_INSTALL_LIBDIR}/${ROCPROFILER_NAME} + COMPONENT runtime) # Build test library set(TEST_LIB "rocprof-tool") set(TEST_LIB_SRC ${TEST_DIR}/tool/tool.cpp ${UTIL_SRC}) add_library(${TEST_LIB} SHARED ${TEST_LIB_SRC}) +set_target_properties( ${TEST_LIB} PROPERTIES + INSTALL_RPATH "${ROCM_APPEND_PRIVLIB_RPATH}") target_include_directories(${TEST_LIB} PRIVATE ${TEST_DIR} ${ROOT_DIR} ${PROJECT_SOURCE_DIR}/include) target_link_libraries(${TEST_LIB} ${ROCPROFILER_TARGET} hsa-runtime64::hsa-runtime64 @@ -204,6 +212,14 @@ install( TARGETS ${TEST_LIB} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/tests-v1/test COMPONENT tests) +install( + TARGETS ${TEST_LIB} + DESTINATION ${CMAKE_INSTALL_LIBDIR}/${ROCPROFILER_NAME} + COMPONENT runtime) +install( + TARGETS ${TEST_LIB} + DESTINATION ${CMAKE_INSTALL_LIBDIR}/${ROCPROFILER_NAME} + COMPONENT asan) # Build memory test bench add_custom_target(