Skip to content

Commit 88a931d

Browse files
update gpu build and docs
1 parent 9dcfa75 commit 88a931d

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

libc/CMakeLists.txt

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,28 @@ set(LIBC_NAMESPACE ${default_namespace}
5050
CACHE STRING "The namespace to use to enclose internal implementations. Must start with '__llvm_libc'."
5151
)
5252

53-
54-
add_subdirectory(newhdrgen)
55-
56-
5753
# We will build the GPU utilities if we are not doing a runtimes build.
5854
option(LIBC_BUILD_GPU_LOADER "Always build the GPU loader utilities" OFF)
59-
if(LIBC_BUILD_GPU_LOADER OR (LLVM_LIBC_GPU_BUILD AND NOT LLVM_RUNTIMES_BUILD))
60-
add_subdirectory(utils/gpu)
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()
6171
endif()
6272

73+
add_subdirectory(newhdrgen)
74+
6375
option(LIBC_CMAKE_VERBOSE_LOGGING
6476
"Log details warnings and notifications during CMake configuration." OFF)
6577

libc/docs/gpu/building.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ targeting the default host environment as well.
6363
Runtimes cross build
6464
--------------------
6565

66-
.. note::
67-
These instructions need to be updated for new headergen. They may be
68-
inaccurate.
69-
7066
For users wanting more direct control over the build process, the build steps
7167
can be done manually instead. This build closely follows the instructions in the
7268
:ref:`main documentation<full_cross_build>` but is specialized for the GPU

llvm/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ if("${LIBC_TARGET_TRIPLE}" STREQUAL "amdgcn-amd-amdhsa" OR
197197
"${LIBC_TARGET_TRIPLE}" STREQUAL "nvptx64-nvidia-cuda")
198198
set(LLVM_LIBC_GPU_BUILD ON)
199199
endif()
200+
if (NOT "libc" IN_LIST LLVM_ENABLE_PROJECTS AND LLVM_LIBC_GPU_BUILD)
201+
message(STATUS "Enabling libc project to build libc testing tools")
202+
list(APPEND LLVM_ENABLE_PROJECTS "libc")
203+
endif()
200204

201205
# LLVM_ENABLE_PROJECTS_USED is `ON` if the user has ever used the
202206
# `LLVM_ENABLE_PROJECTS` CMake cache variable. This exists for

0 commit comments

Comments
 (0)