Skip to content

Commit 3dc9755

Browse files
authored
[libc] Fix the GPU build when building inside the NATIVE project (#118573)
Summary: We use the NATIVE directory for cross-compiling tools that need to be run on the host. This was not forwarding the CMake arguments we used to check if this was a GPU compile that created its own tools. Forward that and simplify. Fixes #118558
1 parent caa8aa5 commit 3dc9755

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

libc/CMakeLists.txt

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,22 +52,9 @@ set(LIBC_NAMESPACE ${default_namespace}
5252

5353
# We will build the GPU utilities if we are not doing a runtimes build.
5454
option(LIBC_BUILD_GPU_LOADER "Always build the GPU loader utilities" OFF)
55-
if(LIBC_BUILD_GPU_LOADER OR NOT LLVM_RUNTIMES_BUILD)
56-
foreach(_name ${LLVM_RUNTIME_TARGETS})
57-
if("libc" IN_LIST RUNTIMES_${_name}_LLVM_ENABLE_RUNTIMES)
58-
if("${_name}" STREQUAL "amdgcn-amd-amdhsa" OR "${_name}" STREQUAL "nvptx64-nvidia-cuda")
59-
set(LIBC_NEED_LOADER_UTILS TRUE)
60-
endif()
61-
endif()
62-
endforeach()
63-
if("${LIBC_TARGET_TRIPLE}" STREQUAL "amdgcn-amd-amdhsa" OR
64-
"${LIBC_TARGET_TRIPLE}" STREQUAL "nvptx64-nvidia-cuda")
65-
set(LIBC_NEED_LOADER_UTILS TRUE)
66-
endif()
67-
if(LIBC_NEED_LOADER_UTILS)
68-
add_subdirectory(utils/gpu)
69-
return()
70-
endif()
55+
if(LIBC_BUILD_GPU_LOADER OR ((NOT LLVM_RUNTIMES_BUILD) AND LLVM_LIBC_GPU_BUILD))
56+
add_subdirectory(utils/gpu)
57+
return()
7158
endif()
7259

7360
add_subdirectory(newhdrgen)

llvm/cmake/modules/CrossCompile.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ function(llvm_create_cross_target project_name target_name toolchain buildtype)
7878
list(APPEND libc_flags -DLLVM_FORCE_BUILD_RUNTIME=ON)
7979
endif()
8080
endif()
81+
if(LLVM_LIBC_GPU_BUILD)
82+
list(APPEND libc_flags -DLLVM_LIBC_GPU_BUILD=ON)
83+
endif()
8184

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

0 commit comments

Comments
 (0)