diff --git a/projects/rdc/CMakeLists.txt b/projects/rdc/CMakeLists.txt index 35a41abacf..bc161f9be5 100755 --- a/projects/rdc/CMakeLists.txt +++ b/projects/rdc/CMakeLists.txt @@ -75,12 +75,33 @@ include(GNUInstallDirs) # ROCM_DIR should be passed in via command line; it will be used # in sub-projects. Override with -DROCM_DIR= set(ROCM_DIR "/opt/rocm" CACHE STRING "ROCm directory.") -# LIB_RUNPATH is later used for linking + +# Only populate RUNPATH if ROCM_RPATH env variable is set +# Mostly makes sense in ROCm build scripts context +# +# Best attempt at finding libraries without modifying LD_LIBRARY_PATH +# +# Reasons for some $ORIGIN paths: +# $ORIGIN +# - rocm/lib/librdc.so needs rocm/lib/librocm_smi64.so +# $ORIGIN/.. +# - rocm/lib/rdc/librdc_rocp.so needs rocm/lib/rdc/../librdc_bootstrap.so +# $ORIGIN/../lib +# - rocm/bin/rdci needs rocm/lib/../lib/librdc_bootstrap.so.0 +# - rocm/bin/rdcd needs rocm/lib/../lib/librdc_bootstrap.so.0 +# $ORIGIN/../lib/rdc/grpc/lib +# - rocm/lib/librdc_client.so needs rocm/lib/../lib/rdc/grpc/lib/libgrpc++.so +# All other versions are for inconsistencies between systems and custom installation paths if(DEFINED ENV{ROCM_RPATH}) - set(RDC_RUNPATH "\$ORIGIN:\$ORIGIN/../lib:\$ORIGIN/../lib64:\$ORIGIN/../lib/rdc:\$ORIGIN/../lib64/rdc") - set(GRPC_RUNPATH "\$ORIGIN/../grpc/lib:\$ORIGIN/../lib/grpc/lib:\$ORIGIN/../lib/rdc/grpc/lib:\$ORIGIN/../lib64/rdc/grpc/lib") - set(GRPC_RUNPATH64 "\$ORIGIN/../grpc/lib64:\$ORIGIN/../lib/grpc/lib64:\$ORIGIN/../lib/rdc/grpc/lib64:\$ORIGIN/../lib64/rdc/grpc/lib64") - set(LIB_RUNPATH "${RDC_RUNPATH}:${GRPC_RUNPATH}:${GRPC_RUNPATH64}") + set(RDC_RUNPATH "\$ORIGIN:\$ORIGIN/..:\$ORIGIN/../lib:\$ORIGIN/../lib64") + set(GRPC_RUNPATH "\$ORIGIN/grpc/lib:\$ORIGIN/../grpc/lib:\$ORIGIN/../lib/grpc/lib:\$ORIGIN/../lib/rdc/grpc/lib:\$ORIGIN/../lib64/rdc/grpc/lib") + set(GRPC_RUNPATH64 "\$ORIGIN/grpc/lib64:\$ORIGIN/../grpc/lib64:\$ORIGIN/../lib/grpc/lib64:\$ORIGIN/../lib/rdc/grpc/lib64:\$ORIGIN/../lib64/rdc/grpc/lib64") + set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}:${RDC_RUNPATH}:${GRPC_RUNPATH}:${GRPC_RUNPATH64}") + + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--enable-new-dtags -Wl,--no-as-needed -Wl,-z,origin") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--enable-new-dtags -Wl,--no-as-needed -Wl,-z,origin") + set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) + set(CMAKE_SKIP_BUILD_RPATH TRUE) endif() set(COMMON_DIR "${CMAKE_CURRENT_SOURCE_DIR}/common") diff --git a/projects/rdc/rdc_libs/CMakeLists.txt b/projects/rdc/rdc_libs/CMakeLists.txt index 53a7d3304a..b1bcc58419 100755 --- a/projects/rdc/rdc_libs/CMakeLists.txt +++ b/projects/rdc/rdc_libs/CMakeLists.txt @@ -62,15 +62,6 @@ set(RDC_ROCR_LIB "rdc_rocr") set(RDC_ROCP_LIB "rdc_rocp") set(RDCCLIENT_LIB "rdc_client") -## Set RUNPATH if ROCM_RPATH is defined and passed by the environment -## RUNPATH should help to run "rdcd" without the usage of ldconfig -if(DEFINED ENV{ROCM_RPATH}) - set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--enable-new-dtags -Wl,--no-as-needed -Wl,-z,origin") - set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}:${LIB_RUNPATH}") - set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) - set(CMAKE_SKIP_BUILD_RPATH TRUE) -endif() - ################# Determine the library version ######################### ## Setup the SO version based on git tags. set(SO_VERSION_GIT_TAG_PREFIX "rdc_so_ver") @@ -90,9 +81,8 @@ set(CPACK_PACKAGE_FILE_NAME "${RDC_PACKAGE}-${VERSION_STRING}") set(CPACK_DEBIAN_PACKAGE_DEPENDS "rocm-core") set(CPACK_RPM_PACKAGE_REQUIRES "rocm-core") -# link grpc and ROCm to RSMI -#link_directories(${RSMI_LIB_DIR} "${GRPC_ROOT}/lib" "${GRPC_ROOT}/lib64" "${ROCM_DIR}/lib") -link_directories(${RSMI_LIB_DIR} "${GRPC_ROOT}/lib" "${GRPC_ROOT}/lib64") +# link RSMI +link_directories(${RSMI_LIB_DIR}) # add librdc_bootstrap.so add_subdirectory(bootstrap) diff --git a/projects/rdc/rdc_libs/rdc_client/CMakeLists.txt b/projects/rdc/rdc_libs/rdc_client/CMakeLists.txt index 16d1ff4a70..ec65a2fc43 100644 --- a/projects/rdc/rdc_libs/rdc_client/CMakeLists.txt +++ b/projects/rdc/rdc_libs/rdc_client/CMakeLists.txt @@ -21,8 +21,7 @@ set(RDCCLIENT_LIB_INC_LIST "${PROJECT_SOURCE_DIR}/include/rdc/rdc.h" message("RDCCLIENT_LIB_INC_LIST=${RDCCLIENT_LIB_INC_LIST}") add_library(${RDCCLIENT_LIB} SHARED ${RDCCLIENT_LIB_SRC_LIST} ${RDCCLIENT_LIB_INC_LIST}) -target_link_libraries(${RDCCLIENT_LIB} ${BOOTSTRAP_LIB} pthread rt grpc grpc++ grpc++_reflection - dl protobuf) +target_link_libraries(${RDCCLIENT_LIB} ${BOOTSTRAP_LIB} pthread rt gRPC::grpc++ dl) target_include_directories(${RDCCLIENT_LIB} PRIVATE "${GRPC_ROOT}/include" "${PROJECT_SOURCE_DIR}" diff --git a/projects/rdc/rdci/CMakeLists.txt b/projects/rdc/rdci/CMakeLists.txt index 199619e1cb..5d0d729d11 100644 --- a/projects/rdc/rdci/CMakeLists.txt +++ b/projects/rdc/rdci/CMakeLists.txt @@ -53,7 +53,6 @@ endif() set(SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src") set(INC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include") -set(LIB_BOOSTRAP_DIR "${PROJECT_BINARY_DIR}/rdc_libs") include_directories(${INC_DIR} ${PROJECT_SOURCE_DIR}/include "${GRPC_ROOT}/include" @@ -73,23 +72,9 @@ set(RDCI_SRC_LIST message("RDCI_SRC_LIST=${RDCI_SRC_LIST}") set(RDCI_EXE "rdci") -link_directories(${LIB_BOOSTRAP_DIR} "${GRPC_ROOT}/lib" "${GRPC_ROOT}/lib64") - add_executable(${RDCI_EXE} "${RDCI_SRC_LIST}") -## RUNPATH should help to run "rdci" without the usage of ldconfig -if(DEFINED ENV{ROCM_RPATH}) - set(CMAKE_EXE_LINKER_FLAGS "-Wl,--enable-new-dtags -Wl,--rpath,${LIB_RUNPATH} -Wl,--no-as-needed -Wl,-z,origin") - set(CMAKE_SKIP_BUILD_RPATH TRUE) - set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) - set(CMAKE_SKIP_RPATH TRUE) - - # Set other library - set(RDCD_EXTRA_LIB ${RDCD_EXTRA_LIB} address_sorting gpr upb ssl crypto - gRPC::grpc++) -endif() - -target_link_libraries(${RDCI_EXE} ${RDCD_EXTRA_LIB} pthread dl rdc_bootstrap) +target_link_libraries(${RDCI_EXE} pthread dl rdc_bootstrap gRPC::grpc++) ## Add the install directives for the rdci executable diff --git a/projects/rdc/server/CMakeLists.txt b/projects/rdc/server/CMakeLists.txt index 994aeda65f..2c8b7020ba 100755 --- a/projects/rdc/server/CMakeLists.txt +++ b/projects/rdc/server/CMakeLists.txt @@ -76,24 +76,12 @@ set(SERVER_DAEMON_EXE "rdcd") configure_file("rdc.service.in" "${PROJECT_BINARY_DIR}/rdc.service" @ONLY) set(SERVICE_FILE_NAME "rdc.service") -link_directories(${RSMI_LIB_DIR} "${GRPC_ROOT}/lib" "${GRPC_ROOT}/lib64") - -## Set RUNPATH if ROCM_RPATH is defined and passed by the environment -## RUNPATH should help to run "rdcd" without the usage of ldconfig -if(DEFINED ENV{ROCM_RPATH}) - set(CMAKE_EXE_LINKER_FLAGS "-Wl,--enable-new-dtags -Wl,--no-as-needed -Wl,-z,origin") - set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}:${LIB_RUNPATH}") - set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) - set(CMAKE_SKIP_BUILD_RPATH TRUE) - - # Set other library - set(RDCD_EXTRA_LIB ${RDCD_EXTRA_LIB} address_sorting gpr upb ssl crypto) -endif() +link_directories(${RSMI_LIB_DIR}) add_executable(${SERVER_DAEMON_EXE} "${SERVER_SRC_LIST}") target_link_libraries(${SERVER_DAEMON_EXE} pthread rt gRPC::grpc++ - cap dl rocm_smi64 rdc_bootstrap ${RDCD_EXTRA_LIB}) + cap dl rocm_smi64 rdc_bootstrap) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${SERVER_DAEMON_EXE} PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE GROUP_READ diff --git a/projects/rdc/tests/rdc_tests/CMakeLists.txt b/projects/rdc/tests/rdc_tests/CMakeLists.txt index cc4986ad41..5f67c46c8b 100755 --- a/projects/rdc/tests/rdc_tests/CMakeLists.txt +++ b/projects/rdc/tests/rdc_tests/CMakeLists.txt @@ -51,13 +51,6 @@ if(NOT GTest_FOUND STREQUAL "TRUE" OR NOT DEFINED GTest_VERSION) FetchContent_MakeAvailable(googletest) endif() -if(DEFINED ENV{ROCM_RPATH}) - set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--enable-new-dtags -Wl,--no-as-needed -Wl,-z,origin") - set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}:${LIB_RUNPATH}") - set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) - set(CMAKE_SKIP_BUILD_RPATH TRUE) -endif() - # Source files aux_source_directory(${SRC_DIR} rdctstSources)