Skip to content

Commit 0ec78f1

Browse files
authored
SWDEV-428379 - Set LD_LIBRARY_PATH for executing the binaries from build directory (#449)
* SWDEV-428379 - Set LD_LIBRARY_PATH for executing the binaries from build directory The binaries rocfft_aot_helper and stockham_aot are getting executed from build directory during build time. The hardcoded RUNPATH in this binaries are helping to find the required libraries. Hardcoded RUNPATH will be removed and will be having relative RUNPATH with respect to install directory. LD_LIBRARY_PATH need to set during build time for a successfull exectuion of the binaries * SWDEV-436762 - Honor the LD_LIBRARY_PATH set by build scripts In ASAN build, the environment variable LD_LIBRARY_PATH is used to set libclang_rt.asan.so library path. Use the LD_LIBRARY_PATH provided by build script * SWDEV-437149 - Add RPATH to the binary rocfft_rtc_helper Since the binary is installed in /opt/rocm-ver/lib/rocfft/version_string folder, it need relative RPATH $ORIGIN/../../../lib to find rocm libraries
1 parent 670ccd1 commit 0ec78f1

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

library/src/CMakeLists.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,13 @@ target_include_directories( rocfft_rtc_helper
5555
PRIVATE
5656
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/library/src/include>
5757
)
58+
# rocfft_rtc_helper will be installed in /opt/rocm-ver/lib/rocfft/VERSION_STRING
59+
# To find rocm libraries need the relative RPATH
60+
set(APPEND_ROCMLIB_RPATH "\$ORIGIN/../../../lib")
5861
target_link_libraries( rocfft_rtc_helper PRIVATE rocfft-rtc-compile )
59-
set_target_properties( rocfft_rtc_helper PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON )
62+
set_target_properties( rocfft_rtc_helper PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON
63+
BUILD_WITH_INSTALL_RPATH TRUE
64+
INSTALL_RPATH "${APPEND_ROCMLIB_RPATH}" )
6065

6166
# Package that helps me set visibility for function names exported
6267
# from shared library
@@ -517,9 +522,11 @@ endif()
517522
set( AMDGPU_TARGETS_AOT ${AMDGPU_TARGETS} )
518523
list( REMOVE_ITEM AMDGPU_TARGETS_AOT gfx803 )
519524
list( REMOVE_ITEM AMDGPU_TARGETS_AOT gfx900 )
525+
# The binary will be having relative RUNPATH with respect to install directory
526+
# Set LD_LIBRARY_PATH for executing the binary from build directory.
520527
add_custom_command(
521528
OUTPUT rocfft_kernel_cache.db
522-
COMMAND rocfft_aot_helper \"${ROCFFT_BUILD_KERNEL_CACHE_PATH}\" ${ROCFFT_KERNEL_CACHE_PATH} $<TARGET_FILE:rocfft_rtc_helper> ${AMDGPU_TARGETS_AOT}
529+
COMMAND ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}:${ROCM_PATH}/${CMAKE_INSTALL_LIBDIR}" ./rocfft_aot_helper \"${ROCFFT_BUILD_KERNEL_CACHE_PATH}\" ${ROCFFT_KERNEL_CACHE_PATH} $<TARGET_FILE:rocfft_rtc_helper> ${AMDGPU_TARGETS_AOT}
523530
DEPENDS rocfft_aot_helper rocfft_rtc_helper
524531
COMMENT "Compile default kernels and solution-map kernels into shipped cache file"
525532
)

library/src/device/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,10 @@ if( STATUS AND NOT STATUS EQUAL 0 )
112112
message( FATAL_ERROR "Kernel generator failed (list): ${STATUS}")
113113
endif()
114114

115+
# stockham_aot will be having relative RUNPATH with respect to package install directory
116+
# Set LD_LIBRARY_PATH for running the executable from build directory
115117
add_custom_command(OUTPUT ${gen_headers}
116-
COMMAND ${PYTHON3_EXE} ${kgen}
118+
COMMAND ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}:${ROCM_PATH}/${CMAKE_INSTALL_LIBDIR}" ${PYTHON3_EXE} ${kgen}
117119
--pattern=${GENERATOR_PATTERN}
118120
--precision=${GENERATOR_PRECISION}
119121
--manual-small=${GENERATOR_MANUAL_SMALL_SIZE}

0 commit comments

Comments
 (0)