[libc-commits] [libc] [llvm] [libc] Fix the GPU build when building inside the NATIVE project (PR #118573)
Joseph Huber via libc-commits
libc-commits at lists.llvm.org
Tue Dec 3 17:12:00 PST 2024
https://github.com/jhuber6 created https://github.com/llvm/llvm-project/pull/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 https://github.com/llvm/llvm-project/issues/118558
>From 12da6261c88fec01bb852a1b217f5681bb079a50 Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Tue, 3 Dec 2024 19:09:47 -0600
Subject: [PATCH] [libc] Fix the GPU build when building inside the NATIVE
project
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 https://github.com/llvm/llvm-project/issues/118558
---
libc/CMakeLists.txt | 19 +++----------------
llvm/cmake/modules/CrossCompile.cmake | 3 +++
2 files changed, 6 insertions(+), 16 deletions(-)
diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt
index fd82359022cffd..11a355b1203602 100644
--- a/libc/CMakeLists.txt
+++ b/libc/CMakeLists.txt
@@ -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)
diff --git a/llvm/cmake/modules/CrossCompile.cmake b/llvm/cmake/modules/CrossCompile.cmake
index e36a71f522d82c..c22d185349dcc5 100644
--- a/llvm/cmake/modules/CrossCompile.cmake
+++ b/llvm/cmake/modules/CrossCompile.cmake
@@ -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}"
More information about the libc-commits
mailing list