Skip to content

Commit fbd7c50

Browse files
authored
[libc] Repurpose LIBC_GPU_BUILD option to enable the new format (#82848)
Summary: We previously used the `LIBC_GPU_BUILD` option to control whether or not the GPU build was enabled. This was recently replaced with a new format that allows treating the GPU targets more directly. However, the new format is somewhat difficult to use for people unfamiliar with the runtimes builds, and the removal of this option somewhat broke backward compatibility. This patch seeks to simplify enabling the GPU build by repurposing the old enabling option and convert it to the new interface. Unsure what the rules are here, since this is technically a `LIBC` option living in the LLVM location.
1 parent aa68e28 commit fbd7c50

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

libc/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ option(LLVM_LIBC_FULL_BUILD "Build and test LLVM libc as if it is the full libc"
134134
option(LLVM_LIBC_IMPLEMENTATION_DEFINED_TEST_BEHAVIOR "Build LLVM libc tests assuming our implementation-defined behavior" ON)
135135
option(LLVM_LIBC_ENABLE_LINTING "Enables linting of libc source files" OFF)
136136

137-
option(LIBC_GPU_BUILD "Build libc for the GPU. All CPU build options will be ignored." OFF)
138137
set(LIBC_TARGET_TRIPLE "" CACHE STRING "The target triple for the libc build.")
139138

140139
option(LIBC_CONFIG_PATH "The path to user provided folder that configures the build for the target system." OFF)

llvm/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,18 @@ foreach(proj IN LISTS LLVM_ENABLE_RUNTIMES)
159159
endif()
160160
endforeach()
161161

162+
# Set a shorthand option to enable the GPU build of the 'libc' project.
163+
option(LIBC_GPU_BUILD "Enable the 'libc' project targeting the GPU" OFF)
164+
if(LIBC_GPU_BUILD)
165+
if(LLVM_RUNTIME_TARGETS)
166+
list(APPEND LLVM_RUNTIME_TARGETS "nvptx64-nvidia-cuda" "amdgcn-amd-amdhsa")
167+
else()
168+
set(LLVM_RUNTIME_TARGETS "default;nvptx64-nvidia-cuda;amdgcn-amd-amdhsa")
169+
endif()
170+
list(APPEND RUNTIMES_nvptx64-nvidia-cuda_LLVM_ENABLE_RUNTIMES "libc")
171+
list(APPEND RUNTIMES_amdgcn-amd-amdhsa_LLVM_ENABLE_RUNTIMES "libc")
172+
endif()
173+
162174
set(NEED_LIBC_HDRGEN FALSE)
163175
if("libc" IN_LIST LLVM_ENABLE_RUNTIMES)
164176
set(NEED_LIBC_HDRGEN TRUE)

0 commit comments

Comments
 (0)