From 43b4b345dc951f1b8fe43532119aeea60030c62e Mon Sep 17 00:00:00 2001 From: Ranjith Ramakrishnan Date: Mon, 16 Jun 2025 18:26:49 -0700 Subject: [PATCH] SWDEV-505204 - Update install location of libamdocl.so Install libamdocl.so in /opt/rocm-xxx/lib/opencl folder rather than installing in /opt/rocm-xxx/lib. ldconfig is run as part of rocm-opencl package installation. ldconfig will use the updated installation path Removed unused ROCM_PATH variable in opencl CMakeList.txt Use RPM install time variable in rpm post scripts rather than using hard coded paths --- opencl/CMakeLists.txt | 6 +----- opencl/amdocl/CMakeLists.txt | 4 ++-- opencl/packaging/CMakeLists.txt | 4 ++-- opencl/packaging/rocm-ocl-icd.postinst | 2 +- opencl/packaging/rocm-ocl-icd.rpm_post | 4 ++-- opencl/packaging/rocm-opencl.postinst | 2 +- opencl/packaging/rocm-opencl.rpm_post | 4 ++-- 7 files changed, 11 insertions(+), 15 deletions(-) diff --git a/opencl/CMakeLists.txt b/opencl/CMakeLists.txt index 7b97cfdeffe0..66c77f3ca523 100644 --- a/opencl/CMakeLists.txt +++ b/opencl/CMakeLists.txt @@ -28,6 +28,7 @@ if(ENABLE_ADDRESS_SANITIZER) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--enable-new-dtags -fuse-ld=lld -fsanitize=address -shared-libasan -g -gz -Wl,--build-id=sha1 -L${ROCM_PATH}/lib/asan") endif() +set(AMDOCL_INSTALL_LIBDIR ${PROJECT_NAME}) set(OPENCL_ICD_LOADER_HEADERS_DIR "${CMAKE_CURRENT_LIST_DIR}/khronos/headers/opencl2.2" CACHE PATH "") if(BUILD_ICD) add_subdirectory(khronos/icd) @@ -96,11 +97,6 @@ if(DEFINED ENV{ROCM_LIBPATCH_VERSION}) endif() set(CPACK_PACKAGING_INSTALL_PREFIX "/opt/rocm" CACHE PATH "Package Installation path for OpenCL") -#ROCM_PATH is needed to create symlink of libraries -if(NOT DEFINED ROCM_PATH) - string(REPLACE "/opencl" "" ROCM_PATH ${CPACK_PACKAGING_INSTALL_PREFIX}) -endif() -message (STATUS "ROCM Installation path(ROCM_PATH): ${ROCM_PATH}") configure_file( packaging/amdocl64.icd diff --git a/opencl/amdocl/CMakeLists.txt b/opencl/amdocl/CMakeLists.txt index cbe814a6e543..c624cbe4c757 100644 --- a/opencl/amdocl/CMakeLists.txt +++ b/opencl/amdocl/CMakeLists.txt @@ -129,5 +129,5 @@ target_link_libraries(amdocl PUBLIC rocclr) INSTALL(TARGETS amdocl COMPONENT MAIN RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/${AMDOCL_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/${AMDOCL_INSTALL_LIBDIR}) diff --git a/opencl/packaging/CMakeLists.txt b/opencl/packaging/CMakeLists.txt index 7d9e6366fd19..1ca0e007d91c 100644 --- a/opencl/packaging/CMakeLists.txt +++ b/opencl/packaging/CMakeLists.txt @@ -17,8 +17,8 @@ set(CPACK_DEB_COMPONENT_INSTALL ON) set(CPACK_RPM_COMPONENT_INSTALL ON) install(TARGETS clinfo DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT binary) -install(TARGETS amdocl DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT binary) -install(TARGETS amdocl DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT asan) +install(TARGETS amdocl DESTINATION ${CMAKE_INSTALL_LIBDIR}/${AMDOCL_INSTALL_LIBDIR} COMPONENT binary) +install(TARGETS amdocl DESTINATION ${CMAKE_INSTALL_LIBDIR}/${AMDOCL_INSTALL_LIBDIR} COMPONENT asan) install(FILES ${opencl_SOURCE_DIR}/LICENSE.txt DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT binary) install(FILES ${opencl_SOURCE_DIR}/LICENSE.txt DESTINATION ${CMAKE_INSTALL_DOCDIR}-asan COMPONENT asan) diff --git a/opencl/packaging/rocm-ocl-icd.postinst b/opencl/packaging/rocm-ocl-icd.postinst index e3ba5d4900a9..eb0167b177ba 100644 --- a/opencl/packaging/rocm-ocl-icd.postinst +++ b/opencl/packaging/rocm-ocl-icd.postinst @@ -5,7 +5,7 @@ set -e INSTALL_PATH=@CPACK_PACKAGING_INSTALL_PREFIX@ do_ldconfig() { - echo ${INSTALL_PATH}/@CMAKE_INSTALL_LIBDIR@ > /@CMAKE_INSTALL_SYSCONFDIR@/ld.so.conf.d/10-rocm-opencl.conf && ldconfig + echo ${INSTALL_PATH}/@CMAKE_INSTALL_LIBDIR@/@AMDOCL_INSTALL_LIBDIR@ > /@CMAKE_INSTALL_SYSCONFDIR@/ld.so.conf.d/10-rocm-opencl.conf && ldconfig } case "$1" in diff --git a/opencl/packaging/rocm-ocl-icd.rpm_post b/opencl/packaging/rocm-ocl-icd.rpm_post index 8c7657e58172..22e77ea003f0 100644 --- a/opencl/packaging/rocm-ocl-icd.rpm_post +++ b/opencl/packaging/rocm-ocl-icd.rpm_post @@ -1,3 +1,3 @@ -INSTALL_PATH=@CPACK_PACKAGING_INSTALL_PREFIX@ +INSTALL_PATH=$RPM_INSTALL_PREFIX0 -echo ${INSTALL_PATH}/@CMAKE_INSTALL_LIBDIR@ > /@CMAKE_INSTALL_SYSCONFDIR@/ld.so.conf.d/10-rocm-opencl.conf && ldconfig +echo ${INSTALL_PATH}/@CMAKE_INSTALL_LIBDIR@/@AMDOCL_INSTALL_LIBDIR@ > /@CMAKE_INSTALL_SYSCONFDIR@/ld.so.conf.d/10-rocm-opencl.conf && ldconfig diff --git a/opencl/packaging/rocm-opencl.postinst b/opencl/packaging/rocm-opencl.postinst index 930be229b5ce..55ee0208bff6 100644 --- a/opencl/packaging/rocm-opencl.postinst +++ b/opencl/packaging/rocm-opencl.postinst @@ -5,7 +5,7 @@ set -e INSTALL_PATH=@CPACK_PACKAGING_INSTALL_PREFIX@ do_ldconfig() { - echo ${INSTALL_PATH}/@CMAKE_INSTALL_LIBDIR@ > /@CMAKE_INSTALL_SYSCONFDIR@/ld.so.conf.d/10-rocm-opencl.conf && ldconfig + echo ${INSTALL_PATH}/@CMAKE_INSTALL_LIBDIR@/@AMDOCL_INSTALL_LIBDIR@ > /@CMAKE_INSTALL_SYSCONFDIR@/ld.so.conf.d/10-rocm-opencl.conf && ldconfig } diff --git a/opencl/packaging/rocm-opencl.rpm_post b/opencl/packaging/rocm-opencl.rpm_post index 8c7657e58172..22e77ea003f0 100644 --- a/opencl/packaging/rocm-opencl.rpm_post +++ b/opencl/packaging/rocm-opencl.rpm_post @@ -1,3 +1,3 @@ -INSTALL_PATH=@CPACK_PACKAGING_INSTALL_PREFIX@ +INSTALL_PATH=$RPM_INSTALL_PREFIX0 -echo ${INSTALL_PATH}/@CMAKE_INSTALL_LIBDIR@ > /@CMAKE_INSTALL_SYSCONFDIR@/ld.so.conf.d/10-rocm-opencl.conf && ldconfig +echo ${INSTALL_PATH}/@CMAKE_INSTALL_LIBDIR@/@AMDOCL_INSTALL_LIBDIR@ > /@CMAKE_INSTALL_SYSCONFDIR@/ld.so.conf.d/10-rocm-opencl.conf && ldconfig