Skip to content

[libc] Fix the GPU build when building inside the NATIVE project #118573

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 3 additions & 16 deletions libc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,9 @@ set(LIBC_NAMESPACE ${default_namespace}

# We will build the GPU utilities if we are not doing a runtimes build.
option(LIBC_BUILD_GPU_LOADER "Always build the GPU loader utilities" OFF)
if(LIBC_BUILD_GPU_LOADER OR NOT LLVM_RUNTIMES_BUILD)
foreach(_name ${LLVM_RUNTIME_TARGETS})
if("libc" IN_LIST RUNTIMES_${_name}_LLVM_ENABLE_RUNTIMES)
if("${_name}" STREQUAL "amdgcn-amd-amdhsa" OR "${_name}" STREQUAL "nvptx64-nvidia-cuda")
set(LIBC_NEED_LOADER_UTILS TRUE)
endif()
endif()
endforeach()
if("${LIBC_TARGET_TRIPLE}" STREQUAL "amdgcn-amd-amdhsa" OR
"${LIBC_TARGET_TRIPLE}" STREQUAL "nvptx64-nvidia-cuda")
set(LIBC_NEED_LOADER_UTILS TRUE)
endif()
if(LIBC_NEED_LOADER_UTILS)
add_subdirectory(utils/gpu)
return()
endif()
if(LIBC_BUILD_GPU_LOADER OR ((NOT LLVM_RUNTIMES_BUILD) AND LLVM_LIBC_GPU_BUILD))
add_subdirectory(utils/gpu)
return()
endif()

add_subdirectory(newhdrgen)
Expand Down
3 changes: 3 additions & 0 deletions llvm/cmake/modules/CrossCompile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ function(llvm_create_cross_target project_name target_name toolchain buildtype)
list(APPEND libc_flags -DLLVM_FORCE_BUILD_RUNTIME=ON)
endif()
endif()
if(LLVM_LIBC_GPU_BUILD)
list(APPEND libc_flags -DLLVM_LIBC_GPU_BUILD=ON)
endif()

add_custom_command(OUTPUT ${${project_name}_${target_name}_BUILD}/CMakeCache.txt
COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}"
Expand Down
Loading