Summary: The libc build has a few utilties that need to be built before we can do everything in the full build. The one requirement currently is the `libc-hdrgen` binary. If we are doing a full build runtimes mode we first add `libc` to the projects list and then only use the `projects` portion to buld the `libc` portion. We also use utilities for the GPU build, namely the loader utilities. Previously we would build these tools on-demand inside of the cross-build, which tool some hacky workarounds for the dependency finding and target triple. This patch instead just builds them similarly to libc-hdrgen and then passses them in. We now either pass it manually it it was built, or just look it up like we do with the other `clang` tools. Depends on https://github.com/llvm/llvm-project/pull/84664
47 lines
1.3 KiB
CMake
47 lines
1.3 KiB
CMake
add_library(gpu_loader OBJECT Main.cpp)
|
|
|
|
target_include_directories(gpu_loader PUBLIC
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
|
${LIBC_SOURCE_DIR}/include
|
|
${LIBC_SOURCE_DIR}
|
|
)
|
|
|
|
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()
|