Summary: This patch moves the RPC server handling to be a header only utility stored in the `shared/` directory. This is intended to be shared within LLVM for the loaders and `offload/` handling. Generally, this makes it easier to share code without weird cross-project binaries being plucked out of the build system. It also allows us to soon move the loader interface out of the `libc` project so that we don't need to bootstrap those and can build them in LLVM.
55 lines
1.5 KiB
CMake
55 lines
1.5 KiB
CMake
add_library(gpu_loader OBJECT Main.cpp)
|
|
|
|
include(FindLibcCommonUtils)
|
|
target_link_libraries(gpu_loader PUBLIC llvm-libc-common-utilities)
|
|
|
|
target_include_directories(gpu_loader PUBLIC
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
|
${LIBC_SOURCE_DIR}/include
|
|
${LIBC_SOURCE_DIR}
|
|
${LLVM_MAIN_INCLUDE_DIR}
|
|
${LLVM_BINARY_DIR}/include
|
|
)
|
|
if(NOT LLVM_ENABLE_RTTI)
|
|
target_compile_options(gpu_loader PUBLIC -fno-rtti)
|
|
endif()
|
|
|
|
find_package(hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS /opt/rocm)
|
|
if(hsa-runtime64_FOUND)
|
|
add_subdirectory(amdgpu)
|
|
endif()
|
|
|
|
# The CUDA loader requires LLVM to traverse the ELF image for symbols.
|
|
find_package(CUDAToolkit 11.2 QUIET)
|
|
if(CUDAToolkit_FOUND)
|
|
add_subdirectory(nvptx)
|
|
endif()
|
|
|
|
if(TARGET amdhsa-loader AND LIBC_TARGET_ARCHITECTURE_IS_AMDGPU)
|
|
add_custom_target(libc.utils.gpu.loader)
|
|
add_dependencies(libc.utils.gpu.loader amdhsa-loader)
|
|
set_target_properties(
|
|
libc.utils.gpu.loader
|
|
PROPERTIES
|
|
TARGET amdhsa-loader
|
|
EXECUTABLE "$<TARGET_FILE:amdhsa-loader>"
|
|
)
|
|
elseif(TARGET nvptx-loader AND LIBC_TARGET_ARCHITECTURE_IS_NVPTX)
|
|
add_custom_target(libc.utils.gpu.loader)
|
|
add_dependencies(libc.utils.gpu.loader nvptx-loader)
|
|
set_target_properties(
|
|
libc.utils.gpu.loader
|
|
PROPERTIES
|
|
TARGET nvptx-loader
|
|
EXECUTABLE "$<TARGET_FILE:nvptx-loader>"
|
|
)
|
|
endif()
|
|
|
|
foreach(gpu_loader_tgt amdhsa-loader nvptx-loader)
|
|
if(TARGET ${gpu_loader_tgt})
|
|
install(TARGETS ${gpu_loader_tgt}
|
|
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
COMPONENT libc)
|
|
endif()
|
|
endforeach()
|