Skip to content

Commit

Permalink
cmake: enable runpath instead of rpath
Browse files Browse the repository at this point in the history
- Switch to usage of RUNPATH instead of RPATH to have ability to override
  path with LD_LIBRARY_PATH. Enabled with linker flag "-Wl,--enable-new-dtags".
- Rename ENABLE_LINKER_RPATH -> ENABLE_LINKER_RUNPATH.
- Remove libfabric lib path from examples/tests cmake files.
  • Loading branch information
mshiryaev authored and Taru Doodi committed Aug 24, 2022
1 parent 03c500c commit 36bab17
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 17 deletions.
8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ option(ENABLE_OFI_HMEM "Enable support OFI HMEM support" FALSE)
option(ENABLE_OFI_OOT_PROV "Enable OFI out-of-tree providers support" FALSE)
option(ENABLE_ITT "Enable ITT profiling support" TRUE)
option(ENABLE_STUB_BACKEND "Enable stub backend" TRUE)
option(ENABLE_LINKER_RUNPATH "Enable linker runpath flags" FALSE)

option(USE_CODECOV_FLAGS "Calculate code coverage" FALSE)
option(WITH_ASAN "Use address sanitizer, can only be used in Debug build" FALSE)
Expand All @@ -80,7 +81,8 @@ message(STATUS "Enable SYCL interop event support: ${ENABLE_SYCL_INTEROP_EVENT}"
message(STATUS "Enable OFI HMEM support: ${ENABLE_OFI_HMEM}")
message(STATUS "Enable OFI out-of-tree providers support: ${ENABLE_OFI_OOT_PROV}")
message(STATUS "Enable ITT profiling support: ${ENABLE_ITT}")
message(STATUS "Enable stub backend" ${ENABLE_STUB_BACKEND})
message(STATUS "Enable stub backend: ${ENABLE_STUB_BACKEND}")
message(STATUS "Enable linker rpath flags: ${ENABLE_LINKER_RUNPATH}")

add_definitions(-DCCL_C_COMPILER="${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION}")
add_definitions(-DCCL_CXX_COMPILER="${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}")
Expand Down Expand Up @@ -226,8 +228,8 @@ enable_testing()

set(EXTERNAL_LIBS "")

set(EXAMPLES_INC_DIRS ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/examples/include ${MPI_INCLUDE_DIR} ${LEVEL_ZERO_INCLUDE_DIR})
set(EXAMPLES_LIB_DIRS ${MPI_LIB_DIR} ${LIBFABRIC_LIB_DIR})
set(EXAMPLES_INC_DIRS ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/examples/include ${MPI_INCLUDE_DIR})
set(EXAMPLES_LIB_DIRS ${MPI_LIB_DIR})

# allow `deprecated`
set(CMAKE_CLANG_FLAGS "${CMAKE_CLANG_FLAGS}")
Expand Down
2 changes: 0 additions & 2 deletions examples/benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ foreach(src ${sources})
target_link_libraries(${executable} PUBLIC dl)
target_link_libraries(${executable} PUBLIC -L${I_MPI_ROOT}/lib/release/)
target_link_libraries(${executable} PUBLIC mpi)
target_link_libraries(${executable} PUBLIC -L${LIBFABRIC_LIB_DIR})
target_link_libraries(${executable} PUBLIC fabric)
target_link_libraries(${executable} PUBLIC ${COMPUTE_BACKEND_TARGET_NAME})
install(TARGETS ${executable} RUNTIME DESTINATION ${CCL_INSTALL_EXAMPLES}/benchmark OPTIONAL)
endforeach()
4 changes: 0 additions & 4 deletions examples/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,5 @@ foreach(src ${sources})
target_link_libraries(${executable} PUBLIC rt)
target_link_libraries(${executable} PUBLIC m)
target_link_libraries(${executable} PUBLIC dl)
target_link_libraries(${executable} PUBLIC -L${I_MPI_ROOT}/lib/release/)
target_link_libraries(${executable} PUBLIC mpi)
target_link_libraries(${executable} PUBLIC -L${LIBFABRIC_LIB_DIR})
target_link_libraries(${executable} PUBLIC fabric)
install(TARGETS ${executable} RUNTIME DESTINATION ${CCL_INSTALL_EXAMPLES}/common OPTIONAL)
endforeach()
2 changes: 0 additions & 2 deletions examples/cpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ foreach(src ${sources})
target_link_libraries(${executable} PUBLIC stdc++)
target_link_libraries(${executable} PUBLIC -L${I_MPI_ROOT}/lib/release/)
target_link_libraries(${executable} PUBLIC mpi)
target_link_libraries(${executable} PUBLIC -L${LIBFABRIC_LIB_DIR})
target_link_libraries(${executable} PUBLIC fabric)
target_link_libraries(${executable} PUBLIC ${COMPUTE_BACKEND_TARGET_NAME})
install(TARGETS ${executable} RUNTIME DESTINATION ${CCL_INSTALL_EXAMPLES}/cpu OPTIONAL)
endforeach()
Expand Down
2 changes: 0 additions & 2 deletions examples/external_launcher/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ foreach(src ${sources})
target_link_libraries(${executable} PRIVATE ccl)
target_link_libraries(${executable} PUBLIC -L${I_MPI_ROOT}/lib/release/)
target_link_libraries(${executable} PUBLIC mpi)
target_link_libraries(${executable} PUBLIC -L${LIBFABRIC_LIB_DIR})
target_link_libraries(${executable} PUBLIC fabric)
target_link_libraries(${executable} PUBLIC ${COMPUTE_BACKEND_TARGET_NAME})
install(TARGETS ${executable} RUNTIME DESTINATION ${CCL_INSTALL_EXAMPLES}/external_launcher OPTIONAL)
endforeach()
Expand Down
2 changes: 0 additions & 2 deletions examples/sycl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ foreach(src ${sources})
target_link_libraries(${executable} PRIVATE ccl)
target_link_libraries(${executable} PUBLIC -L${I_MPI_ROOT}/lib/release/)
target_link_libraries(${executable} PUBLIC mpi)
target_link_libraries(${executable} PUBLIC -L${LIBFABRIC_LIB_DIR})
target_link_libraries(${executable} PUBLIC fabric)
target_link_libraries(${executable} PRIVATE ${COMPUTE_BACKEND_TARGET_NAME})
install(TARGETS ${executable} RUNTIME DESTINATION ${CCL_INSTALL_EXAMPLES}/sycl OPTIONAL)
endforeach()
4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,10 @@ if (USE_SECURITY_FLAGS)
endif()
endif()

if (ENABLE_LINKER_RUNPATH)
set(SRC_SHARED_LINKER_FLAGS "${SRC_SHARED_LINKER_FLAGS} -Wl,--enable-new-dtags -Wl,-rpath='$ORIGIN'")
endif()

set(SRC_SHARED_LINKER_FLAGS "${SRC_SHARED_LINKER_FLAGS} -Wl,--version-script=${PROJECT_SOURCE_DIR}/ccl.map")

if (${CMAKE_C_COMPILER_ID} STREQUAL "Intel" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
Expand Down
2 changes: 0 additions & 2 deletions tests/functional/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ foreach(src ${sources})
target_link_libraries(${executable} PUBLIC ccl)
target_link_libraries(${executable} PUBLIC -L${I_MPI_ROOT}/lib/release/)
target_link_libraries(${executable} PUBLIC mpi)
target_link_libraries(${executable} PUBLIC -L${LIBFABRIC_LIB_DIR})
target_link_libraries(${executable} PUBLIC fabric)
target_link_libraries(${executable} PUBLIC ${COMPUTE_BACKEND_TARGET_NAME})
install(TARGETS ${executable} RUNTIME DESTINATION ${CCL_INSTALL_TESTS} OPTIONAL)
add_test (NAME ${executable} CONFIGURATIONS default COMMAND mpiexec.hydra -l -n 2 -ppn 1 ${CCL_INSTALL_TESTS}/${executable} --gtest_output=xml:${CCL_INSTALL_TESTS}/${executable}_default_report.junit.xml)
Expand Down

0 comments on commit 36bab17

Please sign in to comment.